Skip to content
This repository was archived by the owner on Aug 12, 2025. It is now read-only.

Commit efa6b9f

Browse files
committed
Move kubelet config from systemd to kubeadm_config.yaml
1 parent 3a0bdc1 commit efa6b9f

File tree

1 file changed

+26
-11
lines changed

1 file changed

+26
-11
lines changed

config/default/machine_configs.yaml

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -92,17 +92,6 @@ items:
9292
# kubeadm uses 10th IP as DNS server
9393
CLUSTER_DNS_SERVER=$(prips ${SERVICE_CIDR} | head -n 11 | tail -n 1)
9494
95-
# add cloud provider args.
96-
touch /etc/systemd/system/kubelet.service.d/20-kubelet.conf
97-
cat > /etc/systemd/system/kubelet.service.d/20-kubelet.conf <<EOF
98-
[Service]
99-
Environment="KUBELET_NETWORK_ARGS=--network-plugin=cni"
100-
Environment="KUBELET_DNS_ARGS=--resolv-conf=/run/systemd/resolve/resolv.conf --cluster-dns=${CLUSTER_DNS_SERVER} --cluster-domain=${CLUSTER_DNS_DOMAIN} --node-ip=${PRIVATEIP}"
101-
Environment="KUBELET_EXTRA_ARGS=--allow-privileged=true --cloud-provider=external --authentication-token-webhook=true --read-only-port=0"
102-
EOF
103-
systemctl daemon-reload
104-
systemctl restart kubelet.service
105-
10695
function install_custom_ca () {
10796
if [ ! -n "$MASTER_CA_CERTIFICATE" ]; then
10897
return
@@ -137,6 +126,15 @@ items:
137126
bindPort: ${PORT}
138127
nodeRegistration:
139128
name: ${HOSTNAME}
129+
kubeletExtraArgs:
130+
#resolv-conf: /run/systemd/resolve/resolv.conf
131+
cluster-dns: ${CLUSTER_DNS_SERVER}
132+
cluster-domain: ${CLUSTER_DNS_DOMAIN}
133+
node-ip: ${PRIVATEIP}
134+
allow-privileged: "true"
135+
cloud-provider: external
136+
authentication-token-webhook: "true"
137+
read-only-port: "0"
140138
---
141139
apiVersion: kubeadm.k8s.io/v1beta1
142140
kind: ClusterConfiguration
@@ -167,6 +165,23 @@ items:
167165
sleep 1
168166
done
169167
else
168+
touch /etc/kubernetes/kubeadm_config.yaml
169+
cat > /etc/kubernetes/kubeadm_config.yaml <<EOF
170+
apiVersion: kubeadm.k8s.io/v1beta1
171+
kind: JoinConfiguration
172+
nodeRegistration:
173+
name: ${HOSTNAME}
174+
kubeletExtraArgs:
175+
#resolv-conf: /run/systemd/resolve/resolv.conf
176+
cluster-dns: ${CLUSTER_DNS_SERVER}
177+
cluster-domain: ${CLUSTER_DNS_DOMAIN}
178+
node-ip: ${PRIVATEIP}
179+
allow-privileged: "true"
180+
cloud-provider: external
181+
authentication-token-webhook: "true"
182+
read-only-port: "0"
183+
EOF
184+
170185
export ENDPOINT=''
171186
if [ -n "$MASTER_PRIVATE" ]; then
172187
export ENDPOINT=$MASTER_PRIVATE

0 commit comments

Comments
 (0)