|
| 1 | +# Kubelet Configuration |
| 2 | + |
| 3 | +CAPBK has several ways to configure kubelet. |
| 4 | + |
| 5 | +- [`cloud-init` files](#cloud-init-files) |
| 6 | +- [`kubeletExtraArgs`](#set-kubelet-flags-via-kubeletextraargs) |
| 7 | +- [`kubeletconfiguration` patch target](#use-the-kubeletconfiguration-patch-target) |
| 8 | + |
| 9 | +## Pass `KubeletConfiguration` file via `cloud-init` files |
| 10 | + |
| 11 | +You can use `cloud-init` files to put any files on nodes. |
| 12 | + |
| 13 | +### KubeadmControlPlaneTemplate |
| 14 | + |
| 15 | +```yaml |
| 16 | +apiVersion: controlplane.cluster.x-k8s.io/v1beta1 |
| 17 | +kind: KubeadmControlPlaneTemplate |
| 18 | +metadata: |
| 19 | + name: cloudinit-control-plane |
| 20 | + namespace: default |
| 21 | +spec: |
| 22 | + template: |
| 23 | + spec: |
| 24 | + kubeadmConfigSpec: |
| 25 | + files: |
| 26 | + - path: /etc/kubernetes/kubelet/config.yaml |
| 27 | + owner: "root:root" |
| 28 | + permissions: "0644" |
| 29 | + content: | |
| 30 | + apiVersion: kubelet.config.k8s.io/v1beta1 |
| 31 | + kind: KubeletConfiguration |
| 32 | + evictionHard: |
| 33 | + nodefs.available: "0%" |
| 34 | + nodefs.inodesFree: "0%" |
| 35 | + imagefs.available: "0%" |
| 36 | + authentication: |
| 37 | + anonymous: |
| 38 | + enabled: false |
| 39 | + webhook: |
| 40 | + cacheTTL: 0s |
| 41 | + enabled: true |
| 42 | + x509: |
| 43 | + clientCAFile: /etc/kubernetes/pki/ca.crt |
| 44 | + authorization: |
| 45 | + mode: Webhook |
| 46 | + webhook: |
| 47 | + cacheAuthorizedTTL: 0s |
| 48 | + cacheUnauthorizedTTL: 0s |
| 49 | + cgroupDriver: systemd |
| 50 | + clusterDNS: |
| 51 | + - 10.128.0.10 |
| 52 | + clusterDomain: cluster.local |
| 53 | + containerRuntimeEndpoint: "" |
| 54 | + cpuManagerReconcilePeriod: 0s |
| 55 | + evictionPressureTransitionPeriod: 0s |
| 56 | + fileCheckFrequency: 0s |
| 57 | + healthzBindAddress: 127.0.0.1 |
| 58 | + healthzPort: 10248 |
| 59 | + httpCheckFrequency: 0s |
| 60 | + imageMinimumGCAge: 0s |
| 61 | + logging: |
| 62 | + flushFrequency: 0 |
| 63 | + options: |
| 64 | + json: |
| 65 | + infoBufferSize: "0" |
| 66 | + verbosity: 0 |
| 67 | + memorySwap: {} |
| 68 | + nodeStatusReportFrequency: 0s |
| 69 | + nodeStatusUpdateFrequency: 0s |
| 70 | + rotateCertificates: true |
| 71 | + runtimeRequestTimeout: 0s |
| 72 | + shutdownGracePeriod: 0s |
| 73 | + shutdownGracePeriodCriticalPods: 0s |
| 74 | + staticPodPath: /etc/kubernetes/manifests |
| 75 | + streamingConnectionIdleTimeout: 0s |
| 76 | + syncFrequency: 0s |
| 77 | + volumeStatsAggPeriod: 0s |
| 78 | + clusterConfiguration: |
| 79 | + controllerManager: |
| 80 | + extraArgs: |
| 81 | + enable-hostpath-provisioner: "true" |
| 82 | + initConfiguration: |
| 83 | + nodeRegistration: |
| 84 | + criSocket: unix:///var/run/containerd/containerd.sock |
| 85 | + kubeletExtraArgs: |
| 86 | + config: "/etc/kubernetes/kubelet/config.yaml" |
| 87 | + joinConfiguration: |
| 88 | + nodeRegistration: |
| 89 | + criSocket: unix:///var/run/containerd/containerd.sock |
| 90 | + kubeletExtraArgs: |
| 91 | + config: "/etc/kubernetes/kubelet/config.yaml" |
| 92 | +``` |
| 93 | +
|
| 94 | +### KubeadmConfigTemplate |
| 95 | +
|
| 96 | +``` |
| 97 | +``` |
| 98 | + |
| 99 | +## Set kubelet flags via `kubeletExtraArgs` |
| 100 | + |
| 101 | +```yaml |
| 102 | +apiVersion: controlplane.cluster.x-k8s.io/v1beta1 |
| 103 | +kind: KubeadmControlPlaneTemplate |
| 104 | +metadata: |
| 105 | + name: kubelet-extra-args-control-plane |
| 106 | + namespace: default |
| 107 | +spec: |
| 108 | + template: |
| 109 | + spec: |
| 110 | + kubeadmConfigSpec: |
| 111 | + clusterConfiguration: |
| 112 | + controllerManager: |
| 113 | + extraArgs: |
| 114 | + enable-hostpath-provisioner: "true" |
| 115 | + initConfiguration: |
| 116 | + nodeRegistration: |
| 117 | + criSocket: unix:///var/run/containerd/containerd.sock |
| 118 | + kubeletExtraArgs: |
| 119 | + eviction-hard: nodefs.available<0%,nodefs.inodesFree<0%,imagefs.available<0% |
| 120 | + joinConfiguration: |
| 121 | + nodeRegistration: |
| 122 | + criSocket: unix:///var/run/containerd/containerd.sock |
| 123 | + kubeletExtraArgs: |
| 124 | + eviction-hard: nodefs.available<0%,nodefs.inodesFree<0%,imagefs.available<0% |
| 125 | +``` |
| 126 | +
|
| 127 | +## Use the `kubeletconfiguration` patch target |
| 128 | + |
| 129 | +```yaml |
| 130 | +apiVersion: controlplane.cluster.x-k8s.io/v1beta1 |
| 131 | +kind: KubeadmControlPlaneTemplate |
| 132 | +metadata: |
| 133 | + name: kubeadm-config-template-control-plane |
| 134 | + namespace: default |
| 135 | +spec: |
| 136 | + template: |
| 137 | + spec: |
| 138 | + kubeadmConfigSpec: |
| 139 | + files: |
| 140 | + - path: /etc/kubernetes/patches/kubeletconfiguration0+strategic.json |
| 141 | + owner: "root:root" |
| 142 | + permissions: "0644" |
| 143 | + content: | |
| 144 | + { |
| 145 | + "apiVersion": "kubelet.config.k8s.io/v1beta1", |
| 146 | + "kind": "KubeletConfiguration", |
| 147 | + "evictionHard": { |
| 148 | + "nodefs.available": "0%", |
| 149 | + "nodefs.inodesFree": "0%", |
| 150 | + "imagefs.available": "0%", |
| 151 | + }, |
| 152 | + } |
| 153 | + clusterConfiguration: |
| 154 | + controllerManager: |
| 155 | + extraArgs: |
| 156 | + enable-hostpath-provisioner: "true" |
| 157 | + initConfiguration: |
| 158 | + nodeRegistration: |
| 159 | + criSocket: unix:///var/run/containerd/containerd.sock |
| 160 | + patches: |
| 161 | + directory: /etc/kubernetes/patches |
| 162 | + joinConfiguration: |
| 163 | + nodeRegistration: |
| 164 | + criSocket: unix:///var/run/containerd/containerd.sock |
| 165 | + patches: |
| 166 | + directory: /etc/kubernetes/patches |
| 167 | +``` |
0 commit comments