mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 15:05:27 +00:00
Merge pull request #88287 from gab-satchi/master
Windows specific kubelet flags in kubeadm-flags.env
This commit is contained in:
commit
5c5faed39b
@ -267,9 +267,6 @@ const (
|
||||
// DefaultEtcdVersion indicates the default etcd version that kubeadm uses
|
||||
DefaultEtcdVersion = "3.4.3-0"
|
||||
|
||||
// PauseVersion indicates the default pause image version for kubeadm
|
||||
PauseVersion = "3.2"
|
||||
|
||||
// Etcd defines variable used internally when referring to etcd component
|
||||
Etcd = "etcd"
|
||||
// KubeAPIServer defines variable used internally when referring to kube-apiserver component
|
||||
|
@ -21,4 +21,7 @@ package constants
|
||||
const (
|
||||
// DefaultDockerCRISocket defines the default Docker CRI socket
|
||||
DefaultDockerCRISocket = "/var/run/dockershim.sock"
|
||||
|
||||
// PauseVersion indicates the default pause image version for kubeadm
|
||||
PauseVersion = "3.2"
|
||||
)
|
||||
|
@ -21,4 +21,7 @@ package constants
|
||||
const (
|
||||
// DefaultDockerCRISocket defines the default Docker CRI socket
|
||||
DefaultDockerCRISocket = "npipe:////./pipe/docker_engine"
|
||||
|
||||
// PauseVersion indicates the default pause image version for kubeadm
|
||||
PauseVersion = "1.3.0"
|
||||
)
|
||||
|
@ -8,14 +8,23 @@ load(
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["images.go"],
|
||||
srcs = [
|
||||
"images.go",
|
||||
"images_unix.go",
|
||||
"images_windows.go",
|
||||
],
|
||||
importpath = "k8s.io/kubernetes/cmd/kubeadm/app/images",
|
||||
deps = [
|
||||
"//cmd/kubeadm/app/apis/kubeadm:go_default_library",
|
||||
"//cmd/kubeadm/app/constants:go_default_library",
|
||||
"//cmd/kubeadm/app/util:go_default_library",
|
||||
"//vendor/k8s.io/klog:go_default_library",
|
||||
],
|
||||
] + select({
|
||||
"@io_bazel_rules_go//go/platform:windows": [
|
||||
"//cmd/kubeadm/app/apis/kubeadm/v1beta2:go_default_library",
|
||||
],
|
||||
"//conditions:default": [],
|
||||
}),
|
||||
)
|
||||
|
||||
go_test(
|
||||
|
@ -87,11 +87,6 @@ func GetEtcdImage(cfg *kubeadmapi.ClusterConfiguration) string {
|
||||
return GetGenericImage(etcdImageRepository, constants.Etcd, etcdImageTag)
|
||||
}
|
||||
|
||||
// GetPauseImage returns the image for the "pause" container
|
||||
func GetPauseImage(cfg *kubeadmapi.ClusterConfiguration) string {
|
||||
return GetGenericImage(cfg.ImageRepository, "pause", constants.PauseVersion)
|
||||
}
|
||||
|
||||
// GetControlPlaneImages returns a list of container images kubeadm expects to use on a control plane node
|
||||
func GetControlPlaneImages(cfg *kubeadmapi.ClusterConfiguration) []string {
|
||||
imgs := []string{}
|
||||
|
29
cmd/kubeadm/app/images/images_unix.go
Normal file
29
cmd/kubeadm/app/images/images_unix.go
Normal file
@ -0,0 +1,29 @@
|
||||
// +build !windows
|
||||
|
||||
/*
|
||||
Copyright 2020 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 images
|
||||
|
||||
import (
|
||||
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
||||
)
|
||||
|
||||
// GetPauseImage returns the image for the "pause" container
|
||||
func GetPauseImage(cfg *kubeadmapi.ClusterConfiguration) string {
|
||||
return GetGenericImage(cfg.ImageRepository, "pause", constants.PauseVersion)
|
||||
}
|
34
cmd/kubeadm/app/images/images_windows.go
Normal file
34
cmd/kubeadm/app/images/images_windows.go
Normal file
@ -0,0 +1,34 @@
|
||||
// +build windows
|
||||
|
||||
/*
|
||||
Copyright 2020 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 images
|
||||
|
||||
import (
|
||||
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
|
||||
kubeadmapiv1beta2 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta2"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
||||
)
|
||||
|
||||
// GetPauseImage returns the image for the "pause" container
|
||||
func GetPauseImage(cfg *kubeadmapi.ClusterConfiguration) string {
|
||||
//If user has configured the cluster to use a different image repository, use that for the Windows pause image.
|
||||
if cfg.ImageRepository != kubeadmapiv1beta2.DefaultImageRepository {
|
||||
return GetGenericImage(cfg.ImageRepository, "pause", constants.PauseVersion)
|
||||
}
|
||||
return GetGenericImage("mcr.microsoft.com/oss/kubernetes", "pause", constants.PauseVersion)
|
||||
}
|
@ -6,6 +6,8 @@ go_library(
|
||||
"config.go",
|
||||
"dynamic.go",
|
||||
"flags.go",
|
||||
"flags_unix.go",
|
||||
"flags_windows.go",
|
||||
"kubelet.go",
|
||||
],
|
||||
importpath = "k8s.io/kubernetes/cmd/kubeadm/app/phases/kubelet",
|
||||
|
@ -18,12 +18,8 @@ package kubelet
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"io/ioutil"
|
||||
"k8s.io/klog"
|
||||
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
||||
@ -32,6 +28,9 @@ import (
|
||||
kubeadmutil "k8s.io/kubernetes/cmd/kubeadm/app/util"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/util/initsystem"
|
||||
utilsexec "k8s.io/utils/exec"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type kubeletFlagsOpts struct {
|
||||
@ -85,20 +84,14 @@ func WriteKubeletDynamicEnvFile(cfg *kubeadmapi.ClusterConfiguration, nodeReg *k
|
||||
return writeKubeletFlagBytesToDisk([]byte(envFileContent), kubeletDir)
|
||||
}
|
||||
|
||||
// buildKubeletArgMap takes a kubeletFlagsOpts object and builds based on that a string-string map with flags
|
||||
// that should be given to the local kubelet daemon.
|
||||
func buildKubeletArgMap(opts kubeletFlagsOpts) map[string]string {
|
||||
//buildKubeletArgMapCommon takes a kubeletFlagsOpts object and builds based on that a string-string map with flags
|
||||
//that are common to both Linux and Windows
|
||||
func buildKubeletArgMapCommon(opts kubeletFlagsOpts) map[string]string {
|
||||
kubeletFlags := map[string]string{}
|
||||
|
||||
if opts.nodeRegOpts.CRISocket == constants.DefaultDockerCRISocket {
|
||||
// These flags should only be set when running docker
|
||||
kubeletFlags["network-plugin"] = "cni"
|
||||
driver, err := kubeadmutil.GetCgroupDriverDocker(opts.execer)
|
||||
if err != nil {
|
||||
klog.Warningf("cannot automatically assign a '--cgroup-driver' value when starting the Kubelet: %v\n", err)
|
||||
} else {
|
||||
kubeletFlags["cgroup-driver"] = driver
|
||||
}
|
||||
if opts.pauseImage != "" {
|
||||
kubeletFlags["pod-infra-container-image"] = opts.pauseImage
|
||||
}
|
||||
@ -116,14 +109,6 @@ func buildKubeletArgMap(opts kubeletFlagsOpts) map[string]string {
|
||||
kubeletFlags["register-with-taints"] = strings.Join(taintStrs, ",")
|
||||
}
|
||||
|
||||
ok, err := opts.isServiceActiveFunc("systemd-resolved")
|
||||
if err != nil {
|
||||
klog.Warningf("cannot determine if systemd-resolved is active: %v\n", err)
|
||||
}
|
||||
if ok {
|
||||
kubeletFlags["resolv-conf"] = "/run/systemd/resolve/resolv.conf"
|
||||
}
|
||||
|
||||
// Pass the "--hostname-override" flag to the kubelet only if it's different from the hostname
|
||||
nodeName, hostname, err := GetNodeNameAndHostname(opts.nodeRegOpts)
|
||||
if err != nil {
|
||||
@ -134,8 +119,6 @@ func buildKubeletArgMap(opts kubeletFlagsOpts) map[string]string {
|
||||
kubeletFlags["hostname-override"] = nodeName
|
||||
}
|
||||
|
||||
// TODO: Conditionally set `--cgroup-driver` to either `systemd` or `cgroupfs` for CRI other than Docker
|
||||
|
||||
// TODO: The following code should be removed after dual-stack is GA.
|
||||
// Note: The user still retains the ability to explicitly set feature-gates and that value will overwrite this base value.
|
||||
if enabled, present := opts.featureGates[features.IPv6DualStack]; present {
|
||||
|
51
cmd/kubeadm/app/phases/kubelet/flags_unix.go
Normal file
51
cmd/kubeadm/app/phases/kubelet/flags_unix.go
Normal file
@ -0,0 +1,51 @@
|
||||
// +build !windows
|
||||
|
||||
/*
|
||||
Copyright 2020 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 kubelet
|
||||
|
||||
import (
|
||||
"k8s.io/klog"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
||||
kubeadmutil "k8s.io/kubernetes/cmd/kubeadm/app/util"
|
||||
)
|
||||
|
||||
// buildKubeletArgMap takes a kubeletFlagsOpts object and builds based on that a string-string map with flags
|
||||
// that should be given to the local Linux kubelet daemon.
|
||||
func buildKubeletArgMap(opts kubeletFlagsOpts) map[string]string {
|
||||
kubeletFlags := buildKubeletArgMapCommon(opts)
|
||||
|
||||
// TODO: Conditionally set `--cgroup-driver` to either `systemd` or `cgroupfs` for CRI other than Docker
|
||||
if opts.nodeRegOpts.CRISocket == constants.DefaultDockerCRISocket {
|
||||
driver, err := kubeadmutil.GetCgroupDriverDocker(opts.execer)
|
||||
if err != nil {
|
||||
klog.Warningf("cannot automatically assign a '--cgroup-driver' value when starting the Kubelet: %v\n", err)
|
||||
} else {
|
||||
kubeletFlags["cgroup-driver"] = driver
|
||||
}
|
||||
}
|
||||
|
||||
ok, err := opts.isServiceActiveFunc("systemd-resolved")
|
||||
if err != nil {
|
||||
klog.Warningf("cannot determine if systemd-resolved is active: %v\n", err)
|
||||
}
|
||||
if ok {
|
||||
kubeletFlags["resolv-conf"] = "/run/systemd/resolve/resolv.conf"
|
||||
}
|
||||
|
||||
return kubeletFlags
|
||||
}
|
25
cmd/kubeadm/app/phases/kubelet/flags_windows.go
Normal file
25
cmd/kubeadm/app/phases/kubelet/flags_windows.go
Normal file
@ -0,0 +1,25 @@
|
||||
// +build windows
|
||||
|
||||
/*
|
||||
Copyright 2020 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 kubelet
|
||||
|
||||
// buildKubeletArgMap takes a kubeletFlagsOpts object and builds based on that a string-string map with flags
|
||||
// that should be given to the local Windows kubelet daemon.
|
||||
func buildKubeletArgMap(opts kubeletFlagsOpts) map[string]string {
|
||||
return buildKubeletArgMapCommon(opts)
|
||||
}
|
Loading…
Reference in New Issue
Block a user