Skip to content

Commit d16bfc7

Browse files
authored
feat: Extract CAAPH values templates to files (#896)
This simplifies the Helm templating directives by not requiring inception-style escaping of templating braces, e.g. `{{ "{{" }}`` which are very hard to read and can introduce bugs. This PR also removes the duplicate helm values files currently being used to generate the CRS configmaps, and instead references the helm values that are in the charts directory, which ends up with a reduction in LOC in the project to maintain. I feel this is a simpler way to achieve the same goals as #819 but without duplicating files and keeping all chart source files in the charts directory. Blocked by #895.
1 parent de57106 commit d16bfc7

File tree

50 files changed

+296
-405
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+296
-405
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ repos:
7070
- id: check-yaml
7171
args: ["-m", "--unsafe"]
7272
stages: [commit]
73-
exclude: ^charts/.+/templates/
73+
exclude: ^charts/.+/(templates|addons)/.+\.ya?ml$
7474
- id: mixed-line-ending
7575
args: ["-f", "lf"]
7676
exclude: \.bat$
@@ -140,7 +140,7 @@ repos:
140140
name: License headers - YAML and Makefiles
141141
stages: [commit]
142142
files: (^Makefile|\.(ya?ml|mk))$
143-
exclude: ^(internal/test|pkg/handlers/.+/embedded|examples|charts/cluster-api-runtime-extensions-nutanix/defaultclusterclasses)/.+\.ya?ml|docs/static/helm/index\.yaml|charts/cluster-api-runtime-extensions-nutanix/templates/helm-config.yaml$
143+
exclude: ^(internal/test|pkg/handlers/.+/embedded|examples|charts/cluster-api-runtime-extensions-nutanix/(defaultclusterclasses|addons))/.+\.ya?ml|docs/static/helm/index\.yaml|charts/cluster-api-runtime-extensions-nutanix/templates/helm-config.yaml$
144144
args:
145145
- --license-filepath
146146
- hack/license-header.txt
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{{ $clusterSemver := semver .Cluster.spec.topology.version }}
2+
{{ $ccmVersion := get $k8sMinorVersionToCCMVersion ( print $clusterSemver.Major "." $clusterSemver.Minor ) }}
3+
image:
4+
tag: "{{ $ccmVersion }}"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
$k8sMinorVersionToCCMVersion := dict
2+
{{ range $k8sVersion, $ccmVersion := .Values.hooks.ccm.aws.k8sMinorVersionToCCMVersion -}}
3+
"{{ $k8sVersion }}" "{{ $ccmVersion }}"
4+
{{ end -}}
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
# Copyright 2024 Nutanix. All rights reserved.
2-
# SPDX-License-Identifier: Apache-2.0
3-
4-
---
51
# Starting in Kubernetes v1.29 the Kubelet no longer adds temporary addresses to the Node.
62
# See https://github.com/kubernetes/kubernetes/pull/121028
73
# This causes a deadlock with the AWS CCM and some CNI providers including Calico.
@@ -17,8 +13,8 @@ args:
1713
- --configure-cloud-routes=false
1814

1915
tolerations:
20-
- key: node.cloudprovider.kubernetes.io/uninitialized
21-
value: "true"
22-
effect: NoSchedule
23-
- key: node-role.kubernetes.io/control-plane
24-
effect: NoSchedule
16+
- key: node.cloudprovider.kubernetes.io/uninitialized
17+
value: "true"
18+
effect: NoSchedule
19+
- key: node-role.kubernetes.io/control-plane
20+
effect: NoSchedule
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
prismCentralEndPoint: {{ .PrismCentralHost }}
2+
prismCentralPort: {{ .PrismCentralPort }}
3+
prismCentralInsecure: {{ .PrismCentralInsecure }}
4+
{{- with .PrismCentralAdditionalTrustBundle }}
5+
prismCentralAdditionalTrustBundle: "{{ . }}"
6+
{{- end }}
7+
{{- with .ControlPlaneEndpointHost }}
8+
ignoredNodeIPs: [ {{ printf "%q" . }} ]
9+
{{- end }}
10+
11+
# The Secret containing the credentials will be created by the handler.
12+
createSecret: false
13+
secretName: nutanix-ccm-credentials

hack/addons/kustomize/cluster-autoscaler/helm-values.yaml renamed to charts/cluster-api-runtime-extensions-nutanix/addons/cluster-autoscaler/values-template.yaml

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
1-
# Copyright 2023 Nutanix. All rights reserved.
2-
# SPDX-License-Identifier: Apache-2.0
3-
4-
---
5-
# This is a hack, but because a single cluster-autoscaler deployment can only monitor a single Kubernetes cluster
6-
# we expect 'tmpl-clustername-tmpl' and 'tmpl-clusternamespace-tmpl'
7-
# to be replaced with the Cluster's name and namespace.
8-
fullnameOverride: cluster-autoscaler-tmpl-clusteruuid-tmpl
1+
fullnameOverride: "cluster-autoscaler-{{ index .Cluster.Annotations "caren.nutanix.com/cluster-uuid" }}"
92

103
cloudProvider: clusterapi
114

@@ -20,18 +13,18 @@ tolerations:
2013

2114
# Limit a single cluster-autoscaler Deployment to a single Cluster.
2215
autoDiscovery:
23-
clusterName: tmpl-clustername-tmpl
16+
clusterName: "{{ .Cluster.Name }}"
2417
# The controller failed with an RBAC error trying to watch CAPI objects at the cluster scope without this.
2518
labels:
26-
- namespace: tmpl-clusternamespace-tmpl
19+
- namespace: "{{ .Cluster.Namespace }}"
2720

2821
# For workload clusters it is not possible to use the in-cluster client.
2922
# To simplify the configuration, use the admin kubeconfig generated by CAPI for all clusters.
3023
clusterAPIMode: kubeconfig-incluster
3124
clusterAPIWorkloadKubeconfigPath: /cluster/kubeconfig
3225
extraVolumeSecrets:
3326
kubeconfig:
34-
name: tmpl-clustername-tmpl-kubeconfig
27+
name: "{{ .Cluster.Name }}-kubeconfig"
3528
mountPath: /cluster
3629
readOnly: true
3730
items:
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
installation:
2+
cni:
3+
type: Calico
4+
calicoNetwork:
5+
bgp: Enabled
6+
ipPools: {{ range $cidr := .Cluster.spec.clusterNetwork.pods.cidrBlocks }}
7+
- cidr: "{{ $cidr }}"
8+
encapsulation: None
9+
natOutgoing: Enabled
10+
nodeSelector: all(){{ end }}
11+
nodeMetricsPort: 9091
12+
typhaMetricsPort: 9093
13+
registry: quay.io/
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
installation:
2+
cni:
3+
type: Calico
4+
calicoNetwork:
5+
ipPools:{{ range $cidr := .Cluster.spec.clusterNetwork.pods.cidrBlocks }}
6+
- cidr: "{{ $cidr }}"
7+
encapsulation: None
8+
natOutgoing: Enabled
9+
nodeSelector: all(){{ end }}
10+
nodeMetricsPort: 9091
11+
typhaMetricsPort: 9093
12+
registry: quay.io/
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
installation:
2+
cni:
3+
type: Calico
4+
calicoNetwork:
5+
bgp: Enabled
6+
ipPools:{{ range $cidr := .Cluster.spec.clusterNetwork.pods.cidrBlocks }}
7+
- cidr: "{{ $cidr }}"
8+
encapsulation: None
9+
natOutgoing: Enabled
10+
nodeSelector: all(){{ end }}
11+
nodeMetricsPort: 9091
12+
typhaMetricsPort: 9093
13+
registry: quay.io/
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
cni:
2+
chainingMode: portmap
3+
exclusive: false
4+
hubble:
5+
enabled: true
6+
tls:
7+
auto:
8+
enabled: true # enable automatic TLS certificate generation
9+
method: cronJob # auto generate certificates using cronJob method
10+
certValidityDuration: 60 # certificates validity duration in days (default 2 months)
11+
schedule: "0 0 1 * *" # schedule on the 1st day regeneration of each month
12+
relay:
13+
enabled: true
14+
image:
15+
useDigest: false
16+
ipam:
17+
mode: kubernetes
18+
image:
19+
useDigest: false
20+
operator:
21+
image:
22+
useDigest: false
23+
certgen:
24+
image:
25+
useDigest: false
26+
socketLB:
27+
hostNamespaceOnly: true

0 commit comments

Comments
 (0)