mirror of
https://github.com/kubernetes-sigs/kind.git
synced 2025-12-01 07:26:05 +07:00
move kubelet systemd to base image
This commit is contained in:
@@ -148,24 +148,6 @@ func (c *buildContext) buildImage(dir string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// setup kubelet systemd
|
||||
// create the kubelet service
|
||||
kubeletService := path.Join(ic.BasePath(), "systemd/kubelet.service")
|
||||
if err := createFile(cmder, kubeletService, kubeletServiceContents); err != nil {
|
||||
return errors.Wrap(err, "failed to create kubelet service file")
|
||||
}
|
||||
|
||||
// enable the kubelet service
|
||||
if err := cmder.Command("systemctl", "enable", kubeletService).Run(); err != nil {
|
||||
return errors.Wrap(err, "failed to enable kubelet service")
|
||||
}
|
||||
|
||||
// setup the kubelet dropin
|
||||
const kubeletDropin = "/etc/systemd/system/kubelet.service.d/10-kubeadm.conf"
|
||||
if err := createFile(cmder, kubeletDropin, kubeadm10conf); err != nil {
|
||||
return errors.Wrap(err, "failed to configure kubelet service")
|
||||
}
|
||||
|
||||
// ensure we don't fail if swap is enabled on the host
|
||||
if err = execInBuild("/bin/sh", "-c",
|
||||
`echo "KUBELET_EXTRA_ARGS=--fail-swap-on=false" >> /etc/default/kubelet`,
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
/*
|
||||
Copyright 2019 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.
|
||||
*/
|
||||
|
||||
package nodeimage
|
||||
|
||||
// slightly modified from
|
||||
// https://github.com/kubernetes/kubernetes/blob/ba8fcafaf8c502a454acd86b728c857932555315/build/debs/kubelet.service
|
||||
const kubeletServiceContents = `[Unit]
|
||||
Description=kubelet: The Kubernetes Node Agent
|
||||
Documentation=http://kubernetes.io/docs/
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/bin/kubelet
|
||||
Restart=always
|
||||
StartLimitInterval=0
|
||||
# NOTE: kind deviates from upstream here with a lower RestartSecuse
|
||||
RestartSec=1s
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
`
|
||||
|
||||
// https://github.com/kubernetes/kubernetes/blob/ba8fcafaf8c502a454acd86b728c857932555315/build/debs/10-kubeadm.conf
|
||||
const kubeadm10conf = `# Note: This dropin only works with kubeadm and kubelet v1.11+
|
||||
[Service]
|
||||
Environment="KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf"
|
||||
Environment="KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml"
|
||||
# This is a file that "kubeadm init" and "kubeadm join" generates at runtime, populating the KUBELET_KUBEADM_ARGS variable dynamically
|
||||
EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env
|
||||
# This is a file that the user can use for overrides of the kubelet args as a last resort. Preferably, the user should use
|
||||
# the .NodeRegistration.KubeletExtraArgs object in the configuration files instead. KUBELET_EXTRA_ARGS should be sourced from this file.
|
||||
EnvironmentFile=-/etc/default/kubelet
|
||||
ExecStart=
|
||||
ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS
|
||||
`
|
||||
Reference in New Issue
Block a user