Skip to content
This repository was archived by the owner on Apr 11, 2024. It is now read-only.

Commit 961ea9d

Browse files
committed
build: add scripts to sync Nutanix CCM manifests
1 parent 2a3de91 commit 961ea9d

File tree

8 files changed

+290
-1
lines changed

8 files changed

+290
-1
lines changed

charts/cluster-api-runtime-extensions-nutanix/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ A Helm chart for cluster-api-runtime-extensions-nutanix
3131
| deployDefaultClusterClasses | bool | `true` | |
3232
| deployment.replicas | int | `1` | |
3333
| env | object | `{}` | |
34+
| hooks.ccm.nutanix.crsStrategy.defaultInstallationConfigMap.name | string | `"nutanix-ccm"` | |
35+
| hooks.ccm.nutanix.helmAddonStrategy.defaultValueTemplateConfigMap.create | bool | `true` | |
36+
| hooks.ccm.nutanix.helmAddonStrategy.defaultValueTemplateConfigMap.name | string | `"default-nutanix-ccm-helm-values-template"` | |
3437
| hooks.clusterAutoscaler.crsStrategy.defaultInstallationConfigMap.name | string | `"cluster-autoscaler"` | |
3538
| hooks.clusterAutoscaler.helmAddonStrategy.defaultValueTemplateConfigMap.create | bool | `true` | |
3639
| hooks.clusterAutoscaler.helmAddonStrategy.defaultValueTemplateConfigMap.name | string | `"default-cluster-autoscaler-helm-values-template"` | |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Copyright 2024 D2iQ, Inc. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
{{- if .Values.hooks.clusterAutoscaler.helmAddonStrategy.defaultValueTemplateConfigMap.create }}
5+
apiVersion: v1
6+
kind: ConfigMap
7+
metadata:
8+
name: '{{ .Values.hooks.ccm.nutanix.helmAddonStrategy.defaultValueTemplateConfigMap.name }}'
9+
data:
10+
values.yaml: |-
11+
---
12+
prismCentralEndPoint: {{ `{{ .PrismCentralEndpoint.Host }}` }}
13+
prismCentralPort: {{ `{{ .PrismCentralEndpoint.Port }}` }}
14+
prismCentralInsecure: {{ `{{ .PrismCentralEndpoint.Insecure }}` }}
15+
prismCentralAdditionalTrustBundle: {{ `"{{ or .PrismCentralEndpoint.AdditionalTrustBundle "" }}"` }}
16+
17+
# The Secret containing the credentials will be created by the handler.
18+
createSecret: false
19+
secretName: nutanix-ccm-credentials
20+
{{- end -}}
Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
# Copyright 2023 D2iQ, Inc. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
#=================================================================
5+
# DO NOT EDIT THIS FILE
6+
# IT HAS BEEN GENERATED BY /hack/addons/nutanix-ccm.sh
7+
#=================================================================
8+
apiVersion: v1
9+
data:
10+
nutanix-ccm.yaml: |
11+
apiVersion: v1
12+
kind: ServiceAccount
13+
metadata:
14+
name: cloud-controller-manager
15+
namespace: kube-system
16+
---
17+
apiVersion: rbac.authorization.k8s.io/v1
18+
kind: ClusterRole
19+
metadata:
20+
annotations:
21+
rbac.authorization.kubernetes.io/autoupdate: "true"
22+
name: system:cloud-controller-manager
23+
rules:
24+
- apiGroups:
25+
- ""
26+
resources:
27+
- secrets
28+
verbs:
29+
- get
30+
- list
31+
- watch
32+
- apiGroups:
33+
- ""
34+
resources:
35+
- configmaps
36+
verbs:
37+
- get
38+
- list
39+
- watch
40+
- apiGroups:
41+
- ""
42+
resources:
43+
- events
44+
verbs:
45+
- create
46+
- patch
47+
- update
48+
- apiGroups:
49+
- ""
50+
resources:
51+
- nodes
52+
verbs:
53+
- '*'
54+
- apiGroups:
55+
- ""
56+
resources:
57+
- nodes/status
58+
verbs:
59+
- patch
60+
- apiGroups:
61+
- ""
62+
resources:
63+
- serviceaccounts
64+
verbs:
65+
- create
66+
- apiGroups:
67+
- ""
68+
resources:
69+
- endpoints
70+
verbs:
71+
- create
72+
- get
73+
- list
74+
- watch
75+
- update
76+
- apiGroups:
77+
- coordination.k8s.io
78+
resources:
79+
- leases
80+
verbs:
81+
- get
82+
- list
83+
- watch
84+
- create
85+
- update
86+
- patch
87+
- delete
88+
---
89+
apiVersion: rbac.authorization.k8s.io/v1
90+
kind: ClusterRoleBinding
91+
metadata:
92+
name: system:cloud-controller-manager
93+
roleRef:
94+
apiGroup: rbac.authorization.k8s.io
95+
kind: ClusterRole
96+
name: system:cloud-controller-manager
97+
subjects:
98+
- kind: ServiceAccount
99+
name: cloud-controller-manager
100+
namespace: kube-system
101+
---
102+
apiVersion: apps/v1
103+
kind: Deployment
104+
metadata:
105+
labels:
106+
k8s-app: nutanix-cloud-controller-manager
107+
name: nutanix-cloud-controller-manager
108+
namespace: kube-system
109+
spec:
110+
replicas: 1
111+
selector:
112+
matchLabels:
113+
k8s-app: nutanix-cloud-controller-manager
114+
strategy:
115+
type: Recreate
116+
template:
117+
metadata:
118+
labels:
119+
k8s-app: nutanix-cloud-controller-manager
120+
spec:
121+
affinity:
122+
podAntiAffinity:
123+
requiredDuringSchedulingIgnoredDuringExecution:
124+
- labelSelector:
125+
matchLabels:
126+
k8s-app: nutanix-cloud-controller-manager
127+
topologyKey: kubernetes.io/hostname
128+
containers:
129+
- args:
130+
- --leader-elect=true
131+
- --cloud-config=/etc/cloud/nutanix_config.json
132+
env:
133+
- name: POD_NAMESPACE
134+
valueFrom:
135+
fieldRef:
136+
fieldPath: metadata.namespace
137+
image: ghcr.io/nutanix-cloud-native/cloud-provider-nutanix/controller:v0.3.2
138+
imagePullPolicy: IfNotPresent
139+
name: nutanix-cloud-controller-manager
140+
resources:
141+
requests:
142+
cpu: 100m
143+
memory: 50Mi
144+
volumeMounts:
145+
- mountPath: /etc/cloud
146+
name: nutanix-config-volume
147+
readOnly: true
148+
dnsPolicy: Default
149+
hostNetwork: true
150+
nodeSelector:
151+
node-role.kubernetes.io/control-plane: ""
152+
priorityClassName: system-cluster-critical
153+
serviceAccountName: cloud-controller-manager
154+
tolerations:
155+
- effect: NoSchedule
156+
key: node-role.kubernetes.io/master
157+
operator: Exists
158+
- effect: NoSchedule
159+
key: node-role.kubernetes.io/control-plane
160+
operator: Exists
161+
- effect: NoExecute
162+
key: node.kubernetes.io/unreachable
163+
operator: Exists
164+
tolerationSeconds: 120
165+
- effect: NoExecute
166+
key: node.kubernetes.io/not-ready
167+
operator: Exists
168+
tolerationSeconds: 120
169+
- effect: NoSchedule
170+
key: node.cloudprovider.kubernetes.io/uninitialized
171+
operator: Exists
172+
- effect: NoSchedule
173+
key: node.kubernetes.io/not-ready
174+
operator: Exists
175+
volumes:
176+
- configMap:
177+
name: nutanix-config
178+
name: nutanix-config-volume
179+
kind: ConfigMap
180+
metadata:
181+
creationTimestamp: null
182+
name: '{{ .Values.hooks.ccm.nutanix.crsStrategy.defaultInstallationConfigMap.name
183+
}}'

charts/cluster-api-runtime-extensions-nutanix/values.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@ hooks:
4949
defaultValueTemplateConfigMap:
5050
create: true
5151
name: default-nutanix-csi-helm-values-template
52+
ccm:
53+
nutanix:
54+
crsStrategy:
55+
defaultInstallationConfigMap:
56+
name: nutanix-ccm
57+
helmAddonStrategy:
58+
defaultValueTemplateConfigMap:
59+
create: true
60+
name: default-nutanix-ccm-helm-values-template
5261
nfd:
5362
crsStrategy:
5463
defaultInstallationConfigMap:
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Copyright 2023 D2iQ, Inc. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
---
5+
# The Secret containing the credentials is expected to already exist.
6+
createSecret: false
7+
# The ConfigMap containing the PC details will be created by the handler.
8+
createConfig: false
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copyright 2023 D2iQ, Inc. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
apiVersion: kustomize.config.k8s.io/v1beta1
5+
kind: Kustomization
6+
7+
metadata:
8+
name: nutanix-ccm-kustomize
9+
10+
helmCharts:
11+
- name: nutanix-cloud-provider
12+
namespace: kube-system
13+
repo: https://nutanix.github.io/helm/
14+
releaseName: nutanix-ccm
15+
version: ${NUTANIX_CCM_CHART_VERSION}
16+
valuesFile: helm-values.yaml
17+
includeCRDs: true
18+
skipTests: true

hack/addons/update-nutanix-ccm.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
IFS=$'\n\t'
4+
5+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6+
readonly SCRIPT_DIR
7+
8+
# shellcheck source=hack/common.sh
9+
source "${SCRIPT_DIR}/../common.sh"
10+
11+
if [ -z "${NUTANIX_CCM_CHART_VERSION:-}" ]; then
12+
echo "Missing argument: NUTANIX_CCM_CHART_VERSION"
13+
exit 1
14+
fi
15+
16+
ASSETS_DIR="$(mktemp -d -p "${TMPDIR:-/tmp}")"
17+
readonly ASSETS_DIR
18+
trap_add "rm -rf ${ASSETS_DIR}" EXIT
19+
20+
readonly FILE_NAME="nutanix-ccm.yaml"
21+
22+
readonly KUSTOMIZE_BASE_DIR="${SCRIPT_DIR}/kustomize/nutanix-ccm/"
23+
envsubst -no-unset <"${KUSTOMIZE_BASE_DIR}/kustomization.yaml.tmpl" >"${ASSETS_DIR}/kustomization.yaml"
24+
cp "${KUSTOMIZE_BASE_DIR}"/*.yaml "${ASSETS_DIR}"
25+
26+
kustomize build --enable-helm "${ASSETS_DIR}" >"${ASSETS_DIR}/${FILE_NAME}"
27+
28+
kubectl create configmap "{{ .Values.hooks.ccm.nutanix.crsStrategy.defaultInstallationConfigMap.name }}" --dry-run=client --output yaml \
29+
--from-file "${ASSETS_DIR}/${FILE_NAME}" \
30+
>"${ASSETS_DIR}/nutanix-ccm-configmap.yaml"
31+
32+
# add warning not to edit file directly
33+
cat <<EOF >"${GIT_REPO_ROOT}/charts/cluster-api-runtime-extensions-nutanix/templates/ccm/nutanix/manifests/nutanix-ccm-configmap.yaml"
34+
$(cat "${GIT_REPO_ROOT}/hack/license-header.yaml.txt")
35+
36+
#=================================================================
37+
# DO NOT EDIT THIS FILE
38+
# IT HAS BEEN GENERATED BY /hack/addons/nutanix-ccm.sh
39+
#=================================================================
40+
$(cat "${ASSETS_DIR}/nutanix-ccm-configmap.yaml")
41+
EOF

make/addons.mk

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,17 @@ export CLUSTER_AUTOSCALER_VERSION := 9.35.0
88
export AWS_CSI_SNAPSHOT_CONTROLLER_VERSION := v6.3.3
99
export AWS_EBS_CSI_CHART_VERSION := v2.28.1
1010
export NUTANIX_CSI_CHART_VERSION := v2.6.6
11+
1112
# a map of AWS CCM versions
1213
export AWS_CCM_VERSION_127 := v1.27.1
1314
export AWS_CCM_CHART_VERSION_127 := 0.0.8
1415
export AWS_CCM_VERSION_128 := v1.28.1
1516
export AWS_CCM_CHART_VERSION_128 := 0.0.8
1617

18+
export NUTANIX_CCM_CHART_VERSION := 0.3.3
19+
1720
.PHONY: addons.sync
18-
addons.sync: $(addprefix update-addon.,calico cilium nfd cluster-autoscaler aws-ebs-csi aws-ccm.127 aws-ccm.128)
21+
addons.sync: $(addprefix update-addon.,calico cilium nfd cluster-autoscaler aws-ebs-csi aws-ccm.127 aws-ccm.128 nutanix-ccm)
1922

2023
.PHONY: update-addon.calico
2124
update-addon.calico: ; $(info $(M) updating calico manifests)
@@ -44,3 +47,7 @@ update-addon.aws-ccm.%: ; $(info $(M) updating aws ccm $* manifests)
4447
.PHONY: update-addon.nutanix-csi
4548
update-addon.nutanix-csi: ; $(info $(M) updating nutanix csi manifests)
4649
./hack/addons/update-nutanix-csi.sh
50+
51+
.PHONY: update-addon.nutanix-ccm
52+
update-addon.nutanix-ccm: ; $(info $(M) updating nutanix ccm $* manifests)
53+
./hack/addons/update-nutanix-ccm.sh

0 commit comments

Comments
 (0)