Created
October 20, 2022 13:24
kubelet config patch DaemonSet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: v1 | |
kind: ConfigMap | |
metadata: | |
name: kubelet-entrypoint.sh | |
labels: | |
app: kubelet-init | |
data: | |
entrypoint.sh: | | |
#!/bin/sh | |
set -euo pipefail | |
HOST_MOUNT_DIR="${HOST_MOUNT_DIR:-/host}" | |
echo "Patching kubelet config" | |
VERSION=v4.28.2; BINARY=yq_linux_amd64 | |
wget https://github.com/mikefarah/yq/releases/download/${VERSION}/${BINARY}.tar.gz -O - | tar xz | |
${BINARY} ' | |
.containerLogMaxSize = "50Mi" | | |
.containerLogMaxFiles = 5 | |
' -i "${HOST_MOUNT_DIR}/home/kubernetes/kubelet-config.yaml" | |
echo "Restart kubelet" | |
chroot "${HOST_MOUNT_DIR}" systemctl daemon-reload | |
chroot "${HOST_MOUNT_DIR}" systemctl restart kubelet | |
--- | |
apiVersion: apps/v1 | |
kind: DaemonSet | |
metadata: | |
name: kubelet-initializer | |
spec: | |
updateStrategy: | |
type: RollingUpdate | |
selector: | |
matchLabels: | |
app: kubelet-init | |
template: | |
metadata: | |
labels: | |
app: kubelet-init | |
spec: | |
hostIPC: true | |
hostPID: true | |
hostNetwork: true | |
volumes: | |
- name: host-mount | |
hostPath: | |
path: / | |
- name: entrypoint | |
configMap: | |
name: kubelet-entrypoint.sh | |
defaultMode: 0744 | |
initContainers: | |
- name: kubelet-patch | |
image: alpine:3.7 | |
command: ["/scripts/entrypoint.sh"] | |
env: | |
- name: ROOT_MOUNT_DIR | |
value: /root | |
securityContext: | |
privileged: true | |
volumeMounts: | |
- name: host-mount | |
mountPath: /root | |
- name: entrypoint | |
mountPath: /scripts | |
containers: | |
- image: "gcr.io/google-containers/pause:2.0" | |
name: pause |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment