Skip to content

Commit 384a49a

Browse files
committed
fixup! feat: Add stable cluster UUID annotation
1 parent 3e62e85 commit 384a49a

File tree

29 files changed

+759
-315
lines changed

29 files changed

+759
-315
lines changed

.golangci.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,17 @@ issues:
108108
- text: "hugeParam: holderRef is heavy"
109109
linters:
110110
- gocritic
111+
# Admission request interface is defined by k8s
112+
- path: pkg/webhook
113+
text: "hugeParam: req is heavy"
114+
linters:
115+
- gocritic
116+
# This is not a problem in tests
117+
- path: internal/test/envtest
118+
text: "hugeParam: webhookInstallOptions is heavy"
119+
linters:
120+
- gocritic
121+
- path: internal/test/envtest
122+
text: "hugeParam: input is heavy"
123+
linters:
124+
- gocritic

api/v1alpha1/constants.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,6 @@ const (
3232
GlobalMirrorVariableName = "globalImageRegistryMirror"
3333
// ImageRegistriesVariableName is the image registries patch variable name.
3434
ImageRegistriesVariableName = "imageRegistries"
35+
36+
ClusterUUIDAnnotationKey = APIGroup + "/cluster-uuid"
3537
)
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Copyright 2024 Nutanix. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
apiVersion: v1
5+
kind: Service
6+
metadata:
7+
annotations:
8+
{{- with .Values.service.annotations }}
9+
{{ toYaml . | nindent 4 }}
10+
{{- end }}
11+
labels:
12+
{{- include "chart.labels" . | nindent 4 }}
13+
name: {{ template "chart.name" . }}-admission
14+
namespace: {{ .Release.Namespace }}
15+
spec:
16+
type: {{.Values.service.type}}
17+
ports:
18+
- name: https
19+
port: {{ .Values.service.port }}
20+
protocol: TCP
21+
targetPort: admission
22+
{{- if and .Values.service.nodePort (eq "NodePort" .Values.service.type) }}
23+
nodePort: {{ .Values.service.nodePort }}
24+
{{- end }}
25+
selector:
26+
{{- include "chart.selectorLabels" . | nindent 4 }}

charts/cluster-api-runtime-extensions-nutanix/templates/certificates.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,19 @@ spec:
1616
kind: {{ .Values.certificates.issuer.kind }}
1717
name: {{ template "chart.issuerName" . }}
1818
secretName: {{ template "chart.name" . }}-runtimehooks-tls
19+
---
20+
apiVersion: cert-manager.io/v1
21+
kind: Certificate
22+
metadata:
23+
name: {{ template "chart.name" . }}-admission-tls
24+
namespace: {{ .Release.Namespace }}
25+
labels:
26+
{{- include "chart.labels" . | nindent 4 }}
27+
spec:
28+
dnsNames:
29+
- {{ template "chart.name" . }}-admission.{{ .Release.Namespace }}.svc
30+
- {{ template "chart.name" . }}-admission.{{ .Release.Namespace }}.svc.cluster.local
31+
issuerRef:
32+
kind: {{ .Values.certificates.issuer.kind }}
33+
name: {{ template "chart.issuerName" . }}
34+
secretName: {{ template "chart.name" . }}-admission-tls

charts/cluster-api-runtime-extensions-nutanix/templates/cluster-autoscaler/manifests/helm-addon-installation.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ metadata:
99
data:
1010
values.yaml: |-
1111
---
12-
fullnameOverride: "cluster-autoscaler-{{ `{{ md5sum (printf "%s/%s" .Cluster.Namespace .Cluster.Name) }}` }}"
12+
fullnameOverride: "cluster-autoscaler-{{ `{{ index .Cluster.Annotations "caren.nutanix.com/cluster-uuid" }}` }}"
1313
1414
cloudProvider: clusterapi
1515

charts/cluster-api-runtime-extensions-nutanix/templates/deployment.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ spec:
4444
{{- range $k, $v := .Values.hooks.ccm.aws.k8sMinorVersionToCCMVersion }}
4545
- --ccm.aws.aws-ccm-versions={{ $k }}={{ $v }}
4646
{{- end }}
47+
- --admission-webhook-cert-dir=/admission-certs/
4748
{{- range $key, $value := .Values.extraArgs }}
4849
- --{{ $key }}={{ $value }}
4950
{{- end }}
@@ -57,6 +58,9 @@ spec:
5758
- containerPort: 9443
5859
name: runtimehooks
5960
protocol: TCP
61+
- containerPort: 9444
62+
name: admission
63+
protocol: TCP
6064
- containerPort: 8080
6165
name: metrics
6266
protocol: TCP
@@ -76,6 +80,9 @@ spec:
7680
- mountPath: /runtimehooks-certs
7781
name: runtimehooks-cert
7882
readOnly: true
83+
- mountPath: /admission-certs
84+
name: admission-cert
85+
readOnly: true
7986
livenessProbe:
8087
httpGet:
8188
port: probes
@@ -96,3 +103,7 @@ spec:
96103
secret:
97104
defaultMode: 420
98105
secretName: {{ template "chart.name" . }}-runtimehooks-tls
106+
- name: admission-cert
107+
secret:
108+
defaultMode: 420
109+
secretName: {{ template "chart.name" . }}-admission-tls

charts/cluster-api-runtime-extensions-nutanix/templates/role.yaml

Lines changed: 102 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -4,106 +4,106 @@
44
apiVersion: rbac.authorization.k8s.io/v1
55
kind: ClusterRole
66
metadata:
7-
name: {{ include "chart.name" . }}-manager-role
7+
name: '{{ include "chart.name" . }}-manager-role'
88
rules:
9-
- apiGroups:
10-
- ""
11-
resources:
12-
- configmaps
13-
verbs:
14-
- create
15-
- delete
16-
- get
17-
- list
18-
- patch
19-
- update
20-
- watch
21-
- apiGroups:
22-
- ""
23-
resources:
24-
- namespaces
25-
verbs:
26-
- get
27-
- list
28-
- watch
29-
- apiGroups:
30-
- ""
31-
resources:
32-
- nodes
33-
verbs:
34-
- get
35-
- list
36-
- watch
37-
- apiGroups:
38-
- ""
39-
resources:
40-
- secrets
41-
verbs:
42-
- create
43-
- get
44-
- list
45-
- patch
46-
- update
47-
- watch
48-
- apiGroups:
49-
- addons.cluster.x-k8s.io
50-
resources:
51-
- clusterresourcesets
52-
verbs:
53-
- create
54-
- delete
55-
- get
56-
- list
57-
- patch
58-
- update
59-
- watch
60-
- apiGroups:
61-
- addons.cluster.x-k8s.io
62-
resources:
63-
- helmchartproxies
64-
verbs:
65-
- create
66-
- delete
67-
- get
68-
- list
69-
- patch
70-
- update
71-
- watch
72-
- apiGroups:
73-
- bootstrap.cluster.x-k8s.io
74-
- controlplane.cluster.x-k8s.io
75-
- infrastructure.cluster.x-k8s.io
76-
resources:
77-
- '*'
78-
verbs:
79-
- create
80-
- get
81-
- list
82-
- watch
83-
- apiGroups:
84-
- cluster.x-k8s.io
85-
resources:
86-
- clusterclasses
87-
verbs:
88-
- create
89-
- get
90-
- list
91-
- watch
92-
- apiGroups:
93-
- cluster.x-k8s.io
94-
resources:
95-
- clusters
96-
verbs:
97-
- get
98-
- list
99-
- watch
100-
- apiGroups:
101-
- storage.k8s.io
102-
resources:
103-
- storageclasses
104-
verbs:
105-
- create
106-
- get
107-
- list
108-
- patch
109-
- update
9+
- apiGroups:
10+
- ""
11+
resources:
12+
- configmaps
13+
verbs:
14+
- create
15+
- delete
16+
- get
17+
- list
18+
- patch
19+
- update
20+
- watch
21+
- apiGroups:
22+
- ""
23+
resources:
24+
- namespaces
25+
verbs:
26+
- get
27+
- list
28+
- watch
29+
- apiGroups:
30+
- ""
31+
resources:
32+
- nodes
33+
verbs:
34+
- get
35+
- list
36+
- watch
37+
- apiGroups:
38+
- ""
39+
resources:
40+
- secrets
41+
verbs:
42+
- create
43+
- get
44+
- list
45+
- patch
46+
- update
47+
- watch
48+
- apiGroups:
49+
- addons.cluster.x-k8s.io
50+
resources:
51+
- clusterresourcesets
52+
verbs:
53+
- create
54+
- delete
55+
- get
56+
- list
57+
- patch
58+
- update
59+
- watch
60+
- apiGroups:
61+
- addons.cluster.x-k8s.io
62+
resources:
63+
- helmchartproxies
64+
verbs:
65+
- create
66+
- delete
67+
- get
68+
- list
69+
- patch
70+
- update
71+
- watch
72+
- apiGroups:
73+
- bootstrap.cluster.x-k8s.io
74+
- controlplane.cluster.x-k8s.io
75+
- infrastructure.cluster.x-k8s.io
76+
resources:
77+
- '*'
78+
verbs:
79+
- create
80+
- get
81+
- list
82+
- watch
83+
- apiGroups:
84+
- cluster.x-k8s.io
85+
resources:
86+
- clusterclasses
87+
verbs:
88+
- create
89+
- get
90+
- list
91+
- watch
92+
- apiGroups:
93+
- cluster.x-k8s.io
94+
resources:
95+
- clusters
96+
verbs:
97+
- get
98+
- list
99+
- watch
100+
- apiGroups:
101+
- storage.k8s.io
102+
resources:
103+
- storageclasses
104+
verbs:
105+
- create
106+
- get
107+
- list
108+
- patch
109+
- update
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Copyright 2024 Nutanix. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
---
4+
apiVersion: admissionregistration.k8s.io/v1
5+
kind: MutatingWebhookConfiguration
6+
metadata:
7+
name: '{{ include "chart.name" . }}-mutating-webhook-configuration'
8+
annotations:
9+
cert-manager.io/inject-ca-from: '{{ .Release.Namespace}}/{{ template "chart.name" . }}-admission-tls'
10+
webhooks:
11+
- admissionReviewVersions:
12+
- v1
13+
clientConfig:
14+
service:
15+
name: '{{ include "chart.name" . }}-admission'
16+
namespace: '{{ .Release.Namespace }}'
17+
path: /mutate-v1beta1-cluster
18+
failurePolicy: Fail
19+
name: cluster-defaulter.caren.nutanix.com
20+
rules:
21+
- apiGroups:
22+
- cluster.x-k8s.io
23+
apiVersions:
24+
- '*'
25+
operations:
26+
- CREATE
27+
- UPDATE
28+
resources:
29+
- clusters
30+
sideEffects: None
31+
---
32+
apiVersion: admissionregistration.k8s.io/v1
33+
kind: ValidatingWebhookConfiguration
34+
metadata:
35+
name: '{{ include "chart.name" . }}-validating-webhook-configuration'
36+
annotations:
37+
cert-manager.io/inject-ca-from: '{{ .Release.Namespace}}/{{ template "chart.name" . }}-admission-tls'
38+
webhooks:
39+
- admissionReviewVersions:
40+
- v1
41+
clientConfig:
42+
service:
43+
name: '{{ include "chart.name" . }}-admission'
44+
namespace: '{{ .Release.Namespace }}'
45+
path: /validate-v1beta1-cluster
46+
failurePolicy: Fail
47+
name: cluster-validator.caren.nutanix.com
48+
rules:
49+
- apiGroups:
50+
- cluster.x-k8s.io
51+
apiVersions:
52+
- '*'
53+
operations:
54+
- CREATE
55+
- UPDATE
56+
resources:
57+
- clusters
58+
sideEffects: None

0 commit comments

Comments
 (0)