Skip to content

Commit

Permalink
Add workaround to support k8s v1.29
Browse files Browse the repository at this point in the history
  • Loading branch information
mcbenjemaa committed Feb 28, 2024
1 parent f94c648 commit 4895cde
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions templates/cluster-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ spec:
hostAliases:
- hostnames:
- kubernetes
- localhost
ip: 127.0.0.1
hostNetwork: true
volumes:
Expand All @@ -129,6 +130,54 @@ spec:
type: FileOrCreate
name: kubeconfig
status: {}
- path: /etc/kube-vip-prepare.sh
content: |
#!/bin/bash
# Copyright 2020 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -e
# Configure the workaround required for kubeadm init with kube-vip:
# xref: https://github.com/kube-vip/kube-vip/issues/684
# Nothing to do for kubernetes < v1.29
KUBEADM_MINOR="$(kubeadm version -o short | cut -d '.' -f 2)"
if [[ "$KUBEADM_MINOR" -lt "29" ]]; then
exit 0
fi
IS_KUBEADM_INIT="false"
# cloud-init kubeadm init
if [[ -f /run/kubeadm/kubeadm.yaml ]]; then
IS_KUBEADM_INIT="true"
fi
# ignition kubeadm init
if [[ -f /etc/kubeadm.sh ]] && grep -q -e "kubeadm init" /etc/kubeadm.sh; then
IS_KUBEADM_INIT="true"
fi
if [[ "$IS_KUBEADM_INIT" == "true" ]]; then
sed -i 's#path: /etc/kubernetes/admin.conf#path: /etc/kubernetes/super-admin.conf#' \
/etc/kubernetes/manifests/kube-vip.yaml
fi
owner: root:root
permissions: "0700"

preKubeadmCommands:
- rm /var/lib/dbus/machine-id /etc/machine-id # fix the machine id
- dbus-uuidgen --ensure=/etc/machine-id
Expand All @@ -138,6 +187,7 @@ spec:
- swapoff -a
- sed -i '/ swap / s/^/#/' /etc/fstab
- sysctl --system
- /etc/kube-vip-prepare.sh
postKubeadmCommands:
- >
systemctl disable --now udisks2 multipathd motd-news.timer fwupd-refresh.timer
Expand Down

0 comments on commit 4895cde

Please sign in to comment.