Skip to content

Commit d7d3673

Browse files
aleolifra98
authored andcommitted
fix argocd install
1 parent 1c112cb commit d7d3673

File tree

16 files changed

+408
-199
lines changed

16 files changed

+408
-199
lines changed

cmd/webhook/main.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
"k8s.io/klog/v2"
2929
"k8s.io/utils/ptr"
3030
ctrl "sigs.k8s.io/controller-runtime"
31+
"sigs.k8s.io/controller-runtime/pkg/client"
3132
"sigs.k8s.io/controller-runtime/pkg/healthz"
3233
"sigs.k8s.io/controller-runtime/pkg/log"
3334
"sigs.k8s.io/controller-runtime/pkg/manager"
@@ -52,6 +53,7 @@ import (
5253
podwh "github.com/liqotech/liqo/pkg/webhooks/pod"
5354
resourceslicewh "github.com/liqotech/liqo/pkg/webhooks/resourceslice"
5455
routecfgwh "github.com/liqotech/liqo/pkg/webhooks/routeconfiguration"
56+
"github.com/liqotech/liqo/pkg/webhooks/secretcontroller"
5557
shadowpodswh "github.com/liqotech/liqo/pkg/webhooks/shadowpod"
5658
virtualnodewh "github.com/liqotech/liqo/pkg/webhooks/virtualnode"
5759
)
@@ -76,6 +78,7 @@ func main() {
7678
metricsAddr := pflag.String("metrics-address", ":8080", "The address the metric endpoint binds to")
7779
probeAddr := pflag.String("health-probe-address", ":8081", "The address the health probe endpoint binds to")
7880
leaderElection := pflag.Bool("enable-leader-election", false, "Enable leader election for the webhook pod")
81+
secretName := pflag.String("secret-name", "", "The name of the secret containing the webhook certificates")
7982

8083
// Global parameters
8184
clusterIDFlags := argsutils.NewClusterIDFlags(true, nil)
@@ -103,6 +106,34 @@ func main() {
103106

104107
config := restcfg.SetRateLimiter(ctrl.GetConfigOrDie())
105108

109+
// create a client used for configuration
110+
cl, err := client.New(config, client.Options{Scheme: scheme})
111+
if err != nil {
112+
klog.Error(err)
113+
os.Exit(1)
114+
}
115+
116+
// forge secret for the webhook
117+
if *secretName != "" {
118+
var secret corev1.Secret
119+
if err := cl.Get(ctx, client.ObjectKey{Namespace: *liqoNamespace, Name: *secretName}, &secret); err != nil {
120+
klog.Error(err)
121+
os.Exit(1)
122+
}
123+
124+
if err := secretcontroller.HandleSecret(ctx, cl, &secret); err != nil {
125+
klog.Error(err)
126+
os.Exit(1)
127+
}
128+
129+
if err := cl.Update(ctx, &secret); err != nil {
130+
klog.Error(err)
131+
os.Exit(1)
132+
}
133+
134+
klog.Info("webhook secret correctly enforced")
135+
}
136+
106137
// Create the main manager.
107138
mgr, err := ctrl.NewManager(config, ctrl.Options{
108139
MapperProvider: mapper.LiqoMapperProvider(scheme),
@@ -169,6 +200,14 @@ func main() {
169200
mgr.GetWebhookServer().Register("/mutate/firewallconfigurations", fwcfgwh.NewMutator())
170201
mgr.GetWebhookServer().Register("/validate/routeconfigurations", routecfgwh.NewValidator(mgr.GetClient()))
171202

203+
// Register the secret controller
204+
secretReconciler := secretcontroller.NewSecretReconciler(mgr.GetClient(), mgr.GetScheme(),
205+
mgr.GetEventRecorderFor("secret-controller"))
206+
if err := secretReconciler.SetupWithManager(mgr); err != nil {
207+
klog.Errorf("Unable to set up the secret controller: %v", err)
208+
os.Exit(1)
209+
}
210+
172211
if leaderElection != nil && *leaderElection {
173212
leaderelection.LabelerOnElection(ctx, mgr, &leaderelection.PodInfo{
174213
PodName: os.Getenv("POD_NAME"),

deployments/liqo/files/liqo-webhook-ClusterRole.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,28 @@ rules:
2525
- patch
2626
- update
2727
- watch
28+
- apiGroups:
29+
- ""
30+
resources:
31+
- secrets
32+
verbs:
33+
- create
34+
- delete
35+
- get
36+
- list
37+
- patch
38+
- update
39+
- watch
40+
- apiGroups:
41+
- admissionregistration.k8s.io
42+
resources:
43+
- mutatingwebhookconfigurations
44+
- validatingwebhookconfigurations
45+
verbs:
46+
- get
47+
- list
48+
- update
49+
- watch
2850
- apiGroups:
2951
- apps
3052
resources:

deployments/liqo/templates/liqo-controller-manager-deployment.yaml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,6 @@ spec:
156156
{{- end }}
157157
{{- end }}
158158
resources: {{- toYaml .Values.controllerManager.pod.resources | nindent 10 }}
159-
volumeMounts:
160-
- name: webhook-certs
161-
mountPath: /tmp/k8s-webhook-server/serving-certs/
162-
readOnly: true
163159
ports:
164160
- name: webhook
165161
containerPort: {{ .Values.webhook.port }}
@@ -174,11 +170,6 @@ spec:
174170
httpGet:
175171
path: /readyz
176172
port: healthz
177-
volumes:
178-
- name: webhook-certs
179-
secret:
180-
secretName: {{ include "liqo.prefixedName" $webhookConfig }}-certs
181-
defaultMode: 420
182173
{{- if ((.Values.common).nodeSelector) }}
183174
nodeSelector:
184175
{{- toYaml .Values.common.nodeSelector | nindent 8 }}

deployments/liqo/templates/liqo-webook-deployment.yaml renamed to deployments/liqo/templates/liqo-webhook-deployment.yaml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ spec:
5252
{{- end }}
5353
- --cluster-id=$(CLUSTER_ID)
5454
- --liqo-namespace=$(POD_NAMESPACE)
55+
- --secret-name={{ include "liqo.prefixedName" $webhookConfig }}-certs
5556
- --podcidr={{ .Values.ipam.podCIDR }}
5657
- --vk-options-default-template={{ .Release.Namespace }}/{{ printf "%s-default" $kubeletConfig.name }}
5758
{{- if .Values.controllerManager.config.enableResourceEnforcement }}
@@ -83,10 +84,6 @@ spec:
8384
- name: DEPLOYMENT_NAME
8485
value: {{ include "liqo.prefixedName" $webhookConfig }}
8586
resources: {{- toYaml .Values.webhook.pod.resources | nindent 10 }}
86-
volumeMounts:
87-
- name: webhook-certs
88-
mountPath: /tmp/k8s-webhook-server/serving-certs/
89-
readOnly: true
9087
ports:
9188
- name: webhook
9289
containerPort: {{ .Values.webhook.port }}
@@ -101,11 +98,12 @@ spec:
10198
httpGet:
10299
path: /readyz
103100
port: healthz
101+
volumeMounts:
102+
- name: webhook-certs
103+
mountPath: /tmp/k8s-webhook-server
104104
volumes:
105105
- name: webhook-certs
106-
secret:
107-
secretName: {{ include "liqo.prefixedName" $webhookConfig }}-certs
108-
defaultMode: 420
106+
emptyDir: {}
109107
{{- if ((.Values.common).nodeSelector) }}
110108
nodeSelector:
111109
{{- toYaml .Values.common.nodeSelector | nindent 8 }}

deployments/liqo/templates/webhooks/job-patch/job-create-secret.yaml

Lines changed: 0 additions & 50 deletions
This file was deleted.

deployments/liqo/templates/webhooks/job-patch/job-patch-webhook.yaml

Lines changed: 0 additions & 48 deletions
This file was deleted.

deployments/liqo/templates/webhooks/job-patch/rbac.yaml

Lines changed: 0 additions & 85 deletions
This file was deleted.

deployments/liqo/templates/webhooks/liqo-mutating-webhook.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ metadata:
66
name: {{ include "liqo.prefixedName" $webhookConfig }}
77
labels:
88
{{- include "liqo.labels" $webhookConfig | nindent 4 }}
9+
liqo.io/webhook: "true"
910
webhooks:
1011
- name: pod.mutate.liqo.io
1112
admissionReviewVersions:

deployments/liqo/templates/webhooks/liqo-validating-webhook.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ metadata:
66
name: {{ include "liqo.prefixedName" $webhookConfig }}
77
labels:
88
{{- include "liqo.labels" $webhookConfig | nindent 4 }}
9+
liqo.io/webhook: "true"
910
webhooks:
1011
- name: nsoff.validate.liqo.io
1112
admissionReviewVersions:
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{{- $webhookConfig := (merge (dict "name" "webhook" "module" "webhook") .) -}}
2+
3+
apiVersion: v1
4+
kind: Secret
5+
metadata:
6+
name: {{ include "liqo.prefixedName" $webhookConfig }}-certs
7+
labels:
8+
{{- include "liqo.labels" $webhookConfig | nindent 4 }}
9+
liqo.io/webhook: "true"
10+
annotations:
11+
liqo.io/webhook-service-name: {{ include "liqo.prefixedName" $webhookConfig }}
12+
type: opaque

0 commit comments

Comments
 (0)