Skip to content

Commit

Permalink
Add support for Kubernetes v1.29 clusters
Browse files Browse the repository at this point in the history
This required two changes:
- Remove hostAliases from kube-vip podspec
    This is addressed by adding entries directly to the /etc/hosts
- Do a super-admin.conf switcheroo for the kube-vip static pod
    Add pre and post kubeadm commands for handling kubernetes
    versions v1.29.0+. The prekubeadm command checks if kubeadm
    init has been run and if it is, it replaces the kubeconfig
    hostPath in kube-vip static pod from admin.conf to the
    super-admin.conf. The postkubeadm command checks if
    kubeadm init has been run and if it is, it changes the
    hostPath in kube-vip static pod from super-admin.conf
    back to admin.conf.
  • Loading branch information
thunderboltsid committed Feb 22, 2024
1 parent 974299f commit ab65e15
Show file tree
Hide file tree
Showing 6 changed files with 721 additions and 218 deletions.
24 changes: 20 additions & 4 deletions templates/base/kcp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,6 @@ spec:
name: kubeconfig
resources: {}
hostNetwork: true
hostAliases:
- hostnames:
- kubernetes
ip: 127.0.0.1
volumes:
- name: kubeconfig
hostPath:
Expand Down Expand Up @@ -116,8 +112,28 @@ spec:
preKubeadmCommands:
- echo "before kubeadm call" > /var/log/prekubeadm.log
- hostnamectl set-hostname "{{ ds.meta_data.hostname }}"
- echo "::1 ipv6-localhost ipv6-loopback" >/etc/hosts
- echo "127.0.0.1 localhost" >>/etc/hosts
- echo "127.0.0.1 kubernetes" >>/etc/hosts
- echo "127.0.0.1 {{ ds.meta_data.hostname }}" >> /etc/hosts
- |
KUBERNETES_VERSION_NO_V=${KUBERNETES_VERSION#v}
VERSION_TO_COMPARE=1.29.0
if [ "$(printf '%s\n' "$KUBERNETES_VERSION_NO_V" "$VERSION_TO_COMPARE" | sort -V | head -n1)" != "$KUBERNETES_VERSION_NO_V" ]; then
if [ -f /run/kubeadm/kubeadm.yaml ]; then
sed -i 's#path: /etc/kubernetes/admin.conf#path: /etc/kubernetes/super-admin.conf#' /etc/kubernetes/manifests/kube-vip.yaml;
fi
fi
postKubeadmCommands:
- echo export KUBECONFIG=/etc/kubernetes/admin.conf >> /root/.bashrc
- |
KUBERNETES_VERSION_NO_V=${KUBERNETES_VERSION#v}
VERSION_TO_COMPARE=1.29.0
if [ "$(printf '%s\n' "$KUBERNETES_VERSION_NO_V" "$VERSION_TO_COMPARE" | sort -V | head -n1)" != "$KUBERNETES_VERSION_NO_V" ]; then
if [ -f /run/kubeadm/kubeadm.yaml ]; then
sed -i 's#path: /etc/kubernetes/super-admin.conf#path: /etc/kubernetes/admin.conf#' /etc/kubernetes/manifests/kube-vip.yaml;
fi
fi
- echo "after kubeadm call" > /var/log/postkubeadm.log
useExperimentalRetryJoin: true
verbosity: 10
60 changes: 52 additions & 8 deletions templates/cluster-template-clusterclass.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -231,21 +231,45 @@ metadata:
name: ${CLUSTER_NAME}
namespace: ${NAMESPACE}
stringData:
credentials: "[\n {\n \"type\": \"basic_auth\", \n \"data\": { \n \"prismCentral\":{\n
\ \"username\": \"${NUTANIX_USER}\", \n \"password\": \"${NUTANIX_PASSWORD}\"\n
\ }\n }\n }\n]\n"
credentials: |
[
{
"type": "basic_auth",
"data": {
"prismCentral":{
"username": "${NUTANIX_USER}",
"password": "${NUTANIX_PASSWORD}"
}
}
}
]
---
apiVersion: v1
kind: Secret
metadata:
name: nutanix-ccm-secret
namespace: ${NAMESPACE}
stringData:
nutanix-ccm-secret.yaml: "apiVersion: v1\nkind: Secret\nmetadata:\n name: nutanix-creds\n
\ namespace: kube-system\nstringData:\n credentials: |\n [\n {\n \"type\":
\"basic_auth\", \n \"data\": { \n \"prismCentral\":{\n \"username\":
\"${NUTANIX_USER}\",\n \"password\": \"${NUTANIX_PASSWORD}\"\n },\n
\ \"prismElements\": null\n }\n }\n ]\n"
nutanix-ccm-secret.yaml: |
apiVersion: v1
kind: Secret
metadata:
name: nutanix-creds
namespace: kube-system
stringData:
credentials: |
[
{
"type": "basic_auth",
"data": {
"prismCentral":{
"username": "${NUTANIX_USER}",
"password": "${NUTANIX_PASSWORD}"
},
"prismElements": null
}
}
]
type: addons.cluster.x-k8s.io/resource-set
---
apiVersion: addons.cluster.x-k8s.io/v1beta1
Expand Down Expand Up @@ -698,10 +722,30 @@ spec:
tls-cipher-suites: ${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}
postKubeadmCommands:
- echo export KUBECONFIG=/etc/kubernetes/admin.conf >> /root/.bashrc
- |
KUBERNETES_VERSION_NO_V=${KUBERNETES_VERSION#v}
VERSION_TO_COMPARE=1.29.0
if [ "$(printf '%s\n' "$KUBERNETES_VERSION_NO_V" "$VERSION_TO_COMPARE" | sort -V | head -n1)" != "$KUBERNETES_VERSION_NO_V" ]; then
if [ -f /run/kubeadm/kubeadm.yaml ]; then
sed -i 's#path: /etc/kubernetes/super-admin.conf#path: /etc/kubernetes/admin.conf#' /etc/kubernetes/manifests/kube-vip.yaml;
fi
fi
- echo "after kubeadm call" > /var/log/postkubeadm.log
preKubeadmCommands:
- echo "before kubeadm call" > /var/log/prekubeadm.log
- hostnamectl set-hostname "{{ ds.meta_data.hostname }}"
- echo "::1 ipv6-localhost ipv6-loopback" >/etc/hosts
- echo "127.0.0.1 localhost" >>/etc/hosts
- echo "127.0.0.1 kubernetes" >>/etc/hosts
- echo "127.0.0.1 {{ ds.meta_data.hostname }}" >> /etc/hosts
- |
KUBERNETES_VERSION_NO_V=${KUBERNETES_VERSION#v}
VERSION_TO_COMPARE=1.29.0
if [ "$(printf '%s\n' "$KUBERNETES_VERSION_NO_V" "$VERSION_TO_COMPARE" | sort -V | head -n1)" != "$KUBERNETES_VERSION_NO_V" ]; then
if [ -f /run/kubeadm/kubeadm.yaml ]; then
sed -i 's#path: /etc/kubernetes/admin.conf#path: /etc/kubernetes/super-admin.conf#' /etc/kubernetes/manifests/kube-vip.yaml;
fi
fi
useExperimentalRetryJoin: true
verbosity: 10
---
Expand Down
Loading

0 comments on commit ab65e15

Please sign in to comment.