Skip to content

Commit cbd401f

Browse files
dkoshkinjimmidyson
andauthored
feat: add kube-vip static Pod in a Nutanix handler (#558)
**What problem does this PR solve?**: Stacked on #554 This PR moves the responsibility of adding the control-plan kube-vip to CAREN away from infra providers. This has a big benefit of being able to keep this implementation and the image version consistent across the different providers. ~Because CAPX is always requires kube-vip to be installed there are no API changes, but in the future we can add support to disable or change the provider.~ Added an empty `virtualIP{}` struct to Nutanix `controlPlaneEndpoint`. ``` spec: topology: variables: - name: clusterConfig value: nutanix: controlPlaneEndpoint: host: x.x.x.x port: 6443 virtualIP: {} ``` **Which issue(s) this PR fixes**: Fixes https://jira.nutanix.com/browse/D2IQ-100364 **How Has This Been Tested?**: <!-- Please describe the tests that you ran to verify your changes. Provide output from the tests and any manual steps needed to replicate the tests. --> New unit tests, and tested manually too: ``` clusterctl describe cluster $CLUSTER_NAME NAME READY SEVERITY REASON SINCE MESSAGE Cluster/dkkonvoy-042324-nutanix-03 True 76m ├─ClusterInfrastructure - NutanixCluster/dkkonvoy-042324-nutanix-03-wvv6d ├─ControlPlane - KubeadmControlPlane/dkkonvoy-042324-nutanix-03-sv2zb True 76m │ └─Machine/dkkonvoy-042324-nutanix-03-sv2zb-ds5mv True 76m │ └─MachineInfrastructure - NutanixMachine/dkkonvoy-042324-nutanix-03-sv2zb-ds5mv └─Workers └─MachineDeployment/dkkonvoy-042324-nutanix-03-md-0-w6mls True 74m └─Machine/dkkonvoy-042324-nutanix-03-md-0-w6mls-979mw-c582s True 74m └─MachineInfrastructure - NutanixMachine/dkkonvoy-042324-nutanix-03-md-0-w6mls-979mw-c582s ``` **Special notes for your reviewer**: <!-- Use this to provide any additional information to the reviewers. This may include: - Best way to review the PR. - Where the author wants the most review attention on. - etc. --> --------- Co-authored-by: Jimmi Dyson <[email protected]>
1 parent cd3b732 commit cbd401f

File tree

26 files changed

+1163
-121
lines changed

26 files changed

+1163
-121
lines changed

api/v1alpha1/common_types.go

+14
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ package v1alpha1
55

66
const (
77
APIServerPort = 6443
8+
9+
VirtualIPProviderKubeVIP = "KubeVIP"
810
)
911

1012
// ObjectMeta is metadata that all persisted resources must have, which includes all objects
@@ -37,4 +39,16 @@ type ControlPlaneEndpointSpec struct {
3739
// +kubebuilder:validation:Minimum=1
3840
// +kubebuilder:validation:Maximum=65535
3941
Port int32 `json:"port"`
42+
43+
// Configuration for the virtual IP provider.
44+
// +optional
45+
VirtualIPSpec *ControlPlaneVirtualIPSpec `json:"virtualIP,omitempty"`
46+
}
47+
48+
type ControlPlaneVirtualIPSpec struct {
49+
// Virtual IP provider to deploy.
50+
// +kubebuilder:validation:Enum=KubeVIP
51+
// +kubebuilder:default=KubeVIP
52+
// +optional
53+
Provider string `json:"provider,omitempty"`
4054
}

api/v1alpha1/crds/caren.nutanix.com_nutanixclusterconfigs.yaml

+10
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,16 @@ spec:
476476
maximum: 65535
477477
minimum: 1
478478
type: integer
479+
virtualIP:
480+
description: Configuration for the virtual IP provider.
481+
properties:
482+
provider:
483+
default: KubeVIP
484+
description: Virtual IP provider to deploy.
485+
enum:
486+
- KubeVIP
487+
type: string
488+
type: object
479489
required:
480490
- host
481491
- port

api/v1alpha1/zz_generated.deepcopy.go

+21-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

+2
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ A Helm chart for cluster-api-runtime-extensions-nutanix
6262
| hooks.nfd.crsStrategy.defaultInstallationConfigMap.name | string | `"node-feature-discovery"` | |
6363
| hooks.nfd.helmAddonStrategy.defaultValueTemplateConfigMap.create | bool | `true` | |
6464
| hooks.nfd.helmAddonStrategy.defaultValueTemplateConfigMap.name | string | `"default-nfd-helm-values-template"` | |
65+
| hooks.virtualIP.kubeVip.defaultTemplateConfigMap.create | bool | `true` | |
66+
| hooks.virtualIP.kubeVip.defaultTemplateConfigMap.name | string | `"default-kube-vip-template"` | |
6567
| image.pullPolicy | string | `"IfNotPresent"` | |
6668
| image.repository | string | `"ghcr.io/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix"` | |
6769
| image.tag | string | `""` | |

charts/cluster-api-runtime-extensions-nutanix/defaultclusterclasses/nutanix-cluster-class.yaml

+1-82
Original file line numberDiff line numberDiff line change
@@ -132,72 +132,7 @@ spec:
132132
scheduler:
133133
extraArgs:
134134
tls-cipher-suites: TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256,TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256
135-
files:
136-
- content: |
137-
apiVersion: v1
138-
kind: Pod
139-
metadata:
140-
name: kube-vip
141-
namespace: kube-system
142-
spec:
143-
containers:
144-
- name: kube-vip
145-
image: ghcr.io/kube-vip/kube-vip:v0.6.4
146-
imagePullPolicy: IfNotPresent
147-
args:
148-
- manager
149-
env:
150-
- name: vip_arp
151-
value: "true"
152-
- name: address
153-
value: "control_plane_endpoint_ip"
154-
- name: port
155-
value: "control_plane_endpoint_port"
156-
- name: vip_cidr
157-
value: "32"
158-
- name: cp_enable
159-
value: "true"
160-
- name: cp_namespace
161-
value: kube-system
162-
- name: vip_ddns
163-
value: "false"
164-
- name: vip_leaderelection
165-
value: "true"
166-
- name: vip_leaseduration
167-
value: "15"
168-
- name: vip_renewdeadline
169-
value: "10"
170-
- name: vip_retryperiod
171-
value: "2"
172-
- name: svc_enable
173-
value: "false"
174-
- name: lb_enable
175-
value: "false"
176-
- name: enableServicesElection
177-
value: "false"
178-
securityContext:
179-
capabilities:
180-
add:
181-
- NET_ADMIN
182-
- SYS_TIME
183-
- NET_RAW
184-
volumeMounts:
185-
- mountPath: /etc/kubernetes/admin.conf
186-
name: kubeconfig
187-
resources: {}
188-
hostNetwork: true
189-
hostAliases:
190-
- hostnames:
191-
- kubernetes
192-
ip: 127.0.0.1
193-
volumes:
194-
- name: kubeconfig
195-
hostPath:
196-
type: FileOrCreate
197-
path: /etc/kubernetes/admin.conf
198-
status: {}
199-
owner: root:root
200-
path: /etc/kubernetes/manifests/kube-vip.yaml
135+
files: []
201136
initConfiguration:
202137
nodeRegistration:
203138
kubeletExtraArgs:
@@ -212,14 +147,6 @@ spec:
212147
tls-cipher-suites: TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256,TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256
213148
postKubeadmCommands:
214149
- echo export KUBECONFIG=/etc/kubernetes/admin.conf >> /root/.bashrc
215-
- |
216-
KUBERNETES_VERSION_NO_V=${KUBERNETES_VERSION#v}
217-
VERSION_TO_COMPARE=1.29.0
218-
if [ "$(printf '%s\n' "$KUBERNETES_VERSION_NO_V" "$VERSION_TO_COMPARE" | sort -V | head -n1)" != "$KUBERNETES_VERSION_NO_V" ]; then
219-
if [ -f /run/kubeadm/kubeadm.yaml ]; then
220-
sed -i 's#path: /etc/kubernetes/super-admin.conf#path: /etc/kubernetes/admin.conf#' /etc/kubernetes/manifests/kube-vip.yaml;
221-
fi
222-
fi
223150
- echo "after kubeadm call" > /var/log/postkubeadm.log
224151
preKubeadmCommands:
225152
- echo "before kubeadm call" > /var/log/prekubeadm.log
@@ -228,14 +155,6 @@ spec:
228155
- echo "127.0.0.1 localhost" >>/etc/hosts
229156
- echo "127.0.0.1 kubernetes" >>/etc/hosts
230157
- echo "127.0.0.1 {{ ds.meta_data.hostname }}" >> /etc/hosts
231-
- |
232-
KUBERNETES_VERSION_NO_V=${KUBERNETES_VERSION#v}
233-
VERSION_TO_COMPARE=1.29.0
234-
if [ "$(printf '%s\n' "$KUBERNETES_VERSION_NO_V" "$VERSION_TO_COMPARE" | sort -V | head -n1)" != "$KUBERNETES_VERSION_NO_V" ]; then
235-
if [ -f /run/kubeadm/kubeadm.yaml ]; then
236-
sed -i 's#path: /etc/kubernetes/admin.conf#path: /etc/kubernetes/super-admin.conf#' /etc/kubernetes/manifests/kube-vip.yaml;
237-
fi
238-
fi
239158
useExperimentalRetryJoin: true
240159
verbosity: 10
241160
---
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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/update-kube-vip-manifests.sh
7+
#=================================================================
8+
{{- if .Values.hooks.virtualIP.kubeVip.defaultTemplateConfigMap.create }}
9+
apiVersion: v1
10+
data:
11+
kube-vip.yaml: |
12+
apiVersion: v1
13+
kind: Pod
14+
metadata:
15+
name: kube-vip
16+
namespace: kube-system
17+
spec:
18+
containers:
19+
- args:
20+
- manager
21+
env:
22+
- name: vip_arp
23+
value: "true"
24+
- name: port
25+
value: '{{ `{{ .ControlPlaneEndpoint.Port }}` }}'
26+
- name: vip_nodename
27+
valueFrom:
28+
fieldRef:
29+
fieldPath: spec.nodeName
30+
- name: vip_cidr
31+
value: "32"
32+
- name: dns_mode
33+
value: first
34+
- name: cp_enable
35+
value: "true"
36+
- name: cp_namespace
37+
value: kube-system
38+
- name: vip_leaderelection
39+
value: "true"
40+
- name: vip_leasename
41+
value: plndr-cp-lock
42+
- name: vip_leaseduration
43+
value: "15"
44+
- name: vip_renewdeadline
45+
value: "10"
46+
- name: vip_retryperiod
47+
value: "2"
48+
- name: address
49+
value: '{{ `{{ .ControlPlaneEndpoint.Host }}` }}'
50+
image: ghcr.io/kube-vip/kube-vip:v0.8.0
51+
imagePullPolicy: IfNotPresent
52+
name: kube-vip
53+
resources: {}
54+
securityContext:
55+
capabilities:
56+
add:
57+
- NET_ADMIN
58+
- NET_RAW
59+
volumeMounts:
60+
- mountPath: /etc/kubernetes/admin.conf
61+
name: kubeconfig
62+
hostAliases:
63+
- hostnames:
64+
- kubernetes
65+
ip: 127.0.0.1
66+
hostNetwork: true
67+
volumes:
68+
- hostPath:
69+
path: /etc/kubernetes/admin.conf
70+
name: kubeconfig
71+
kind: ConfigMap
72+
metadata:
73+
creationTimestamp: null
74+
name: '{{ .Values.hooks.virtualIP.kubeVip.defaultTemplateConfigMap.name }}'
75+
{{- end -}}

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

+6
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ hooks:
7272
create: true
7373
name: default-cluster-autoscaler-helm-values-template
7474

75+
virtualIP:
76+
kubeVip:
77+
defaultTemplateConfigMap:
78+
create: true
79+
name: default-kube-vip-template
80+
7581
helmAddonsConfigMap: default-helm-addons-config
7682

7783
deployDefaultClusterClasses: true

docs/content/customization/nutanix/control-plane-endpoint.md

+32
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ spec:
2222
controlPlaneEndpoint:
2323
host: x.x.x.x
2424
port: 6443
25+
virtualIP: {}
2526
```
2627
2728
Applying this configuration will result in the following value being set:
@@ -36,3 +37,34 @@ spec:
3637
host: x.x.x.x
3738
port: 6443
3839
```
40+
41+
- `KubeadmControlPlaneTemplate`
42+
43+
```yaml
44+
spec:
45+
kubeadmConfigSpec:
46+
files:
47+
- content: |
48+
apiVersion: v1
49+
kind: Pod
50+
metadata:
51+
name: kube-vip
52+
namespace: kube-system
53+
spec:
54+
...
55+
owner: root:root
56+
path: /etc/kubernetes/manifests/kube-vip.yaml
57+
permissions: "0600"
58+
postKubeadmCommands:
59+
# Only added for clusters version >=v1.29.0
60+
- |-
61+
if [ -f /run/kubeadm/kubeadm.yaml ]; then
62+
sed -i 's#path: /etc/kubernetes/super-admin.conf#path: ...
63+
fi
64+
preKubeadmCommands:
65+
# Only added for clusters version >=v1.29.0
66+
- |-
67+
if [ -f /run/kubeadm/kubeadm.yaml ]; then
68+
sed -i 's#path: /etc/kubernetes/admin.conf#path: ...
69+
fi
70+
```

examples/capi-quick-start/nutanix-cluster-calico-crs.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ spec:
112112
controlPlaneEndpoint:
113113
host: ${CONTROL_PLANE_ENDPOINT_IP}
114114
port: 6443
115+
virtualIP:
116+
provider: KubeVIP
115117
prismCentralEndpoint:
116118
credentials:
117119
name: ${CLUSTER_NAME}-pc-creds

examples/capi-quick-start/nutanix-cluster-calico-helm-addon.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ spec:
112112
controlPlaneEndpoint:
113113
host: ${CONTROL_PLANE_ENDPOINT_IP}
114114
port: 6443
115+
virtualIP:
116+
provider: KubeVIP
115117
prismCentralEndpoint:
116118
credentials:
117119
name: ${CLUSTER_NAME}-pc-creds

examples/capi-quick-start/nutanix-cluster-cilium-crs.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ spec:
112112
controlPlaneEndpoint:
113113
host: ${CONTROL_PLANE_ENDPOINT_IP}
114114
port: 6443
115+
virtualIP:
116+
provider: KubeVIP
115117
prismCentralEndpoint:
116118
credentials:
117119
name: ${CLUSTER_NAME}-pc-creds

examples/capi-quick-start/nutanix-cluster-cilium-helm-addon.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ spec:
112112
controlPlaneEndpoint:
113113
host: ${CONTROL_PLANE_ENDPOINT_IP}
114114
port: 6443
115+
virtualIP:
116+
provider: KubeVIP
115117
prismCentralEndpoint:
116118
credentials:
117119
name: ${CLUSTER_NAME}-pc-creds

0 commit comments

Comments
 (0)