Skip to content

Commit

Permalink
reduce cloud-init size, use script for kubeadm
Browse files Browse the repository at this point in the history
  • Loading branch information
rahulait committed May 28, 2024
1 parent 239d421 commit c753e6a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 48 deletions.
25 changes: 1 addition & 24 deletions templates/flavors/kubeadm/default/kubeadmConfigTemplate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,6 @@ spec:
template:
spec:
files:
- path: /etc/containerd/config.toml
content: |
version = 2
imports = ["/etc/containerd/conf.d/*.toml"]
[plugins]
[plugins."io.containerd.grpc.v1.cri"]
sandbox_image = "registry.k8s.io/pause:3.9"
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc]
runtime_type = "io.containerd.runc.v2"
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc.options]
SystemdCgroup = true
- path: /etc/modules-load.d/k8s.conf
content: |
overlay
br_netfilter
- path: /etc/sysctl.d/k8s.conf
content: |
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.ipv4.ip_forward = 1
net.ipv6.conf.all.forwarding = 1
- path: /kubeadm-pre-init.sh
content: |
#!/bin/bash
Expand All @@ -36,14 +15,12 @@ spec:
mkdir -p -m 755 /etc/apt/keyrings
PATCH_VERSION=$${1#[v]}
VERSION=$${PATCH_VERSION%.*}
curl -fsSL https://raw.githubusercontent.com/linode/cluster-api-provider-linode/869bcdad9cf7daae533023c7869f62683d2a7f47/scripts/add-kubeadm-required-files.sh | bash
curl -fsSL "https://pkgs.k8s.io/core:/stable:/v$VERSION/deb/Release.key" | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
echo "deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v$VERSION/deb/ /" | sudo tee /etc/apt/sources.list.d/kubernetes.list
apt-get update -y
apt-get install -y kubelet=$PATCH_VERSION* kubeadm=$PATCH_VERSION* kubectl=$PATCH_VERSION* containerd
apt-mark hold kubelet kubeadm kubectl containerd
modprobe overlay
modprobe br_netfilter
sysctl --system
if [ -d "/sys/class/net/eth1" ]; then
IPADDR=$(ip a s eth1 |grep 'inet ' |cut -d' ' -f6|cut -d/ -f1)
sed -i "s/kubeletExtraArgs:/kubeletExtraArgs:\n node-ip: $IPADDR/g" /run/kubeadm/kubeadm.yaml
Expand Down
25 changes: 1 addition & 24 deletions templates/flavors/kubeadm/default/kubeadmControlPlane.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,6 @@ spec:
name: ${CLUSTER_NAME}-control-plane
kubeadmConfigSpec:
files:
- path: /etc/containerd/config.toml
content: |
version = 2
imports = ["/etc/containerd/conf.d/*.toml"]
[plugins]
[plugins."io.containerd.grpc.v1.cri"]
sandbox_image = "registry.k8s.io/pause:3.9"
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc]
runtime_type = "io.containerd.runc.v2"
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc.options]
SystemdCgroup = true
- path: /etc/modules-load.d/k8s.conf
content: |
overlay
br_netfilter
- path: /etc/sysctl.d/k8s.conf
content: |
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.ipv4.ip_forward = 1
net.ipv6.conf.all.forwarding = 1
- path: /kubeadm-pre-init.sh
content: |
#!/bin/bash
Expand All @@ -41,14 +20,12 @@ spec:
mkdir -p -m 755 /etc/apt/keyrings
PATCH_VERSION=$${1#[v]}
VERSION=$${PATCH_VERSION%.*}
curl -fsSL https://raw.githubusercontent.com/linode/cluster-api-provider-linode/869bcdad9cf7daae533023c7869f62683d2a7f47/scripts/add-kubeadm-required-files.sh | bash
curl -fsSL "https://pkgs.k8s.io/core:/stable:/v$VERSION/deb/Release.key" | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
echo "deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v$VERSION/deb/ /" | sudo tee /etc/apt/sources.list.d/kubernetes.list
apt-get update -y
apt-get install -y kubelet=$PATCH_VERSION* kubeadm=$PATCH_VERSION* kubectl=$PATCH_VERSION* containerd
apt-mark hold kubelet kubeadm kubectl containerd
modprobe overlay
modprobe br_netfilter
sysctl --system
if [ -d "/sys/class/net/eth1" ]; then
IPADDR=$(ip a s eth1 |grep 'inet ' |cut -d' ' -f6|cut -d/ -f1)
sed -i "s/kubeletExtraArgs:/kubeletExtraArgs:\n node-ip: $IPADDR/g" /run/kubeadm/kubeadm.yaml
Expand Down

0 comments on commit c753e6a

Please sign in to comment.