Skip to content

Commit 5c5faed

Browse files
authored
Merge pull request kubernetes#88287 from gab-satchi/master
Windows specific kubelet flags in kubeadm-flags.env
2 parents e4e3d72 + 9fabafd commit 5c5faed

File tree

11 files changed

+165
-34
lines changed

11 files changed

+165
-34
lines changed

cmd/kubeadm/app/constants/constants.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,6 @@ const (
267267
// DefaultEtcdVersion indicates the default etcd version that kubeadm uses
268268
DefaultEtcdVersion = "3.4.3-0"
269269

270-
// PauseVersion indicates the default pause image version for kubeadm
271-
PauseVersion = "3.2"
272-
273270
// Etcd defines variable used internally when referring to etcd component
274271
Etcd = "etcd"
275272
// KubeAPIServer defines variable used internally when referring to kube-apiserver component

cmd/kubeadm/app/constants/constants_unix.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,7 @@ package constants
2121
const (
2222
// DefaultDockerCRISocket defines the default Docker CRI socket
2323
DefaultDockerCRISocket = "/var/run/dockershim.sock"
24+
25+
// PauseVersion indicates the default pause image version for kubeadm
26+
PauseVersion = "3.2"
2427
)

cmd/kubeadm/app/constants/constants_windows.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,7 @@ package constants
2121
const (
2222
// DefaultDockerCRISocket defines the default Docker CRI socket
2323
DefaultDockerCRISocket = "npipe:////./pipe/docker_engine"
24+
25+
// PauseVersion indicates the default pause image version for kubeadm
26+
PauseVersion = "1.3.0"
2427
)

cmd/kubeadm/app/images/BUILD

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,23 @@ load(
88

99
go_library(
1010
name = "go_default_library",
11-
srcs = ["images.go"],
11+
srcs = [
12+
"images.go",
13+
"images_unix.go",
14+
"images_windows.go",
15+
],
1216
importpath = "k8s.io/kubernetes/cmd/kubeadm/app/images",
1317
deps = [
1418
"//cmd/kubeadm/app/apis/kubeadm:go_default_library",
1519
"//cmd/kubeadm/app/constants:go_default_library",
1620
"//cmd/kubeadm/app/util:go_default_library",
1721
"//vendor/k8s.io/klog:go_default_library",
18-
],
22+
] + select({
23+
"@io_bazel_rules_go//go/platform:windows": [
24+
"//cmd/kubeadm/app/apis/kubeadm/v1beta2:go_default_library",
25+
],
26+
"//conditions:default": [],
27+
}),
1928
)
2029

2130
go_test(

cmd/kubeadm/app/images/images.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,6 @@ func GetEtcdImage(cfg *kubeadmapi.ClusterConfiguration) string {
8787
return GetGenericImage(etcdImageRepository, constants.Etcd, etcdImageTag)
8888
}
8989

90-
// GetPauseImage returns the image for the "pause" container
91-
func GetPauseImage(cfg *kubeadmapi.ClusterConfiguration) string {
92-
return GetGenericImage(cfg.ImageRepository, "pause", constants.PauseVersion)
93-
}
94-
9590
// GetControlPlaneImages returns a list of container images kubeadm expects to use on a control plane node
9691
func GetControlPlaneImages(cfg *kubeadmapi.ClusterConfiguration) []string {
9792
imgs := []string{}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// +build !windows
2+
3+
/*
4+
Copyright 2020 The Kubernetes Authors.
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
*/
18+
19+
package images
20+
21+
import (
22+
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
23+
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
24+
)
25+
26+
// GetPauseImage returns the image for the "pause" container
27+
func GetPauseImage(cfg *kubeadmapi.ClusterConfiguration) string {
28+
return GetGenericImage(cfg.ImageRepository, "pause", constants.PauseVersion)
29+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// +build windows
2+
3+
/*
4+
Copyright 2020 The Kubernetes Authors.
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
*/
18+
19+
package images
20+
21+
import (
22+
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
23+
kubeadmapiv1beta2 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta2"
24+
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
25+
)
26+
27+
// GetPauseImage returns the image for the "pause" container
28+
func GetPauseImage(cfg *kubeadmapi.ClusterConfiguration) string {
29+
//If user has configured the cluster to use a different image repository, use that for the Windows pause image.
30+
if cfg.ImageRepository != kubeadmapiv1beta2.DefaultImageRepository {
31+
return GetGenericImage(cfg.ImageRepository, "pause", constants.PauseVersion)
32+
}
33+
return GetGenericImage("mcr.microsoft.com/oss/kubernetes", "pause", constants.PauseVersion)
34+
}

cmd/kubeadm/app/phases/kubelet/BUILD

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ go_library(
66
"config.go",
77
"dynamic.go",
88
"flags.go",
9+
"flags_unix.go",
10+
"flags_windows.go",
911
"kubelet.go",
1012
],
1113
importpath = "k8s.io/kubernetes/cmd/kubeadm/app/phases/kubelet",

cmd/kubeadm/app/phases/kubelet/flags.go

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,8 @@ package kubelet
1818

1919
import (
2020
"fmt"
21-
"io/ioutil"
22-
"os"
23-
"path/filepath"
24-
"strings"
25-
2621
"github.com/pkg/errors"
22+
"io/ioutil"
2723
"k8s.io/klog"
2824
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
2925
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
@@ -32,6 +28,9 @@ import (
3228
kubeadmutil "k8s.io/kubernetes/cmd/kubeadm/app/util"
3329
"k8s.io/kubernetes/cmd/kubeadm/app/util/initsystem"
3430
utilsexec "k8s.io/utils/exec"
31+
"os"
32+
"path/filepath"
33+
"strings"
3534
)
3635

3736
type kubeletFlagsOpts struct {
@@ -85,20 +84,14 @@ func WriteKubeletDynamicEnvFile(cfg *kubeadmapi.ClusterConfiguration, nodeReg *k
8584
return writeKubeletFlagBytesToDisk([]byte(envFileContent), kubeletDir)
8685
}
8786

88-
// buildKubeletArgMap takes a kubeletFlagsOpts object and builds based on that a string-string map with flags
89-
// that should be given to the local kubelet daemon.
90-
func buildKubeletArgMap(opts kubeletFlagsOpts) map[string]string {
87+
//buildKubeletArgMapCommon takes a kubeletFlagsOpts object and builds based on that a string-string map with flags
88+
//that are common to both Linux and Windows
89+
func buildKubeletArgMapCommon(opts kubeletFlagsOpts) map[string]string {
9190
kubeletFlags := map[string]string{}
9291

9392
if opts.nodeRegOpts.CRISocket == constants.DefaultDockerCRISocket {
9493
// These flags should only be set when running docker
9594
kubeletFlags["network-plugin"] = "cni"
96-
driver, err := kubeadmutil.GetCgroupDriverDocker(opts.execer)
97-
if err != nil {
98-
klog.Warningf("cannot automatically assign a '--cgroup-driver' value when starting the Kubelet: %v\n", err)
99-
} else {
100-
kubeletFlags["cgroup-driver"] = driver
101-
}
10295
if opts.pauseImage != "" {
10396
kubeletFlags["pod-infra-container-image"] = opts.pauseImage
10497
}
@@ -116,14 +109,6 @@ func buildKubeletArgMap(opts kubeletFlagsOpts) map[string]string {
116109
kubeletFlags["register-with-taints"] = strings.Join(taintStrs, ",")
117110
}
118111

119-
ok, err := opts.isServiceActiveFunc("systemd-resolved")
120-
if err != nil {
121-
klog.Warningf("cannot determine if systemd-resolved is active: %v\n", err)
122-
}
123-
if ok {
124-
kubeletFlags["resolv-conf"] = "/run/systemd/resolve/resolv.conf"
125-
}
126-
127112
// Pass the "--hostname-override" flag to the kubelet only if it's different from the hostname
128113
nodeName, hostname, err := GetNodeNameAndHostname(opts.nodeRegOpts)
129114
if err != nil {
@@ -134,8 +119,6 @@ func buildKubeletArgMap(opts kubeletFlagsOpts) map[string]string {
134119
kubeletFlags["hostname-override"] = nodeName
135120
}
136121

137-
// TODO: Conditionally set `--cgroup-driver` to either `systemd` or `cgroupfs` for CRI other than Docker
138-
139122
// TODO: The following code should be removed after dual-stack is GA.
140123
// Note: The user still retains the ability to explicitly set feature-gates and that value will overwrite this base value.
141124
if enabled, present := opts.featureGates[features.IPv6DualStack]; present {
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// +build !windows
2+
3+
/*
4+
Copyright 2020 The Kubernetes Authors.
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
*/
18+
19+
package kubelet
20+
21+
import (
22+
"k8s.io/klog"
23+
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
24+
kubeadmutil "k8s.io/kubernetes/cmd/kubeadm/app/util"
25+
)
26+
27+
// buildKubeletArgMap takes a kubeletFlagsOpts object and builds based on that a string-string map with flags
28+
// that should be given to the local Linux kubelet daemon.
29+
func buildKubeletArgMap(opts kubeletFlagsOpts) map[string]string {
30+
kubeletFlags := buildKubeletArgMapCommon(opts)
31+
32+
// TODO: Conditionally set `--cgroup-driver` to either `systemd` or `cgroupfs` for CRI other than Docker
33+
if opts.nodeRegOpts.CRISocket == constants.DefaultDockerCRISocket {
34+
driver, err := kubeadmutil.GetCgroupDriverDocker(opts.execer)
35+
if err != nil {
36+
klog.Warningf("cannot automatically assign a '--cgroup-driver' value when starting the Kubelet: %v\n", err)
37+
} else {
38+
kubeletFlags["cgroup-driver"] = driver
39+
}
40+
}
41+
42+
ok, err := opts.isServiceActiveFunc("systemd-resolved")
43+
if err != nil {
44+
klog.Warningf("cannot determine if systemd-resolved is active: %v\n", err)
45+
}
46+
if ok {
47+
kubeletFlags["resolv-conf"] = "/run/systemd/resolve/resolv.conf"
48+
}
49+
50+
return kubeletFlags
51+
}

0 commit comments

Comments
 (0)