-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rebase 1.9.0 beta.1 #17576
rebase 1.9.0 beta.1 #17576
Changes from 1 commit
f0bb2b6
c671103
07c6b99
710998e
c8626b7
f3769c7
123246b
534c679
ca1b85f
9ff7f3f
d34b354
df449cc
f046a0b
3c7a135
3f45cdc
ee0f726
de36874
64974bc
bf64f2c
cf235c2
4bc612e
66d94ff
fc9b4e2
5b3859b
d1b5fe8
42a1e2c
d49083e
07e5313
ab033d4
32a0c9a
27ad23a
f490d38
2f11419
b3fa18d
22f0b91
0aedd29
7f86e08
99c59c6
afdcb87
2abedd5
5d40a0f
4383cd7
7ffc267
244afd3
30fe89a
de21f14
80cef2d
a92560d
a1cef1f
8454d7d
9344e48
062ffb1
93bd84a
0089bbb
ad7d2fc
60d3fa9
b15c3b6
1d18e82
31f33b0
2cf15a3
ee8266b
bb2ecf0
2db374f
a4d2794
ebc468c
7256949
6c58566
d4ee63c
9e3ca9a
6b39f30
2fa3a79
d826d91
a783419
5c42201
b80c0d2
088b81d
cdc12ca
b374cbd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,17 +9,17 @@ import ( | |
"path/filepath" | ||
"time" | ||
|
||
dockertypes "github.com/docker/docker/api/types" | ||
dockerclient "github.com/fsouza/go-dockerclient" | ||
"github.com/golang/glog" | ||
"k8s.io/kubernetes/pkg/kubelet/dockershim" | ||
dockertools "k8s.io/kubernetes/pkg/kubelet/dockershim/libdocker" | ||
|
||
kapiv1 "k8s.io/api/core/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
kubeletapp "k8s.io/kubernetes/cmd/kubelet/app" | ||
"k8s.io/kubernetes/pkg/kubelet/cadvisor" | ||
cadvisortesting "k8s.io/kubernetes/pkg/kubelet/cadvisor/testing" | ||
"k8s.io/kubernetes/pkg/kubelet/cm" | ||
dockertools "k8s.io/kubernetes/pkg/kubelet/dockershim/libdocker" | ||
"k8s.io/kubernetes/pkg/volume" | ||
|
||
configapi "github.com/openshift/origin/pkg/cmd/server/api" | ||
|
@@ -34,7 +34,7 @@ const minimumDockerAPIVersionWithPullByID = "1.22" | |
// All errors here are fatal. | ||
func (c *NodeConfig) EnsureKubeletAccess() { | ||
if _, err := os.Stat("/var/lib/docker"); os.IsPermission(err) { | ||
c.HandleDockerError("Unable to view the /var/lib/docker directory - are you running as root?") | ||
glog.Fatal("Unable to view the /var/lib/docker directory - are you running as root?") | ||
} | ||
if c.Containerized { | ||
if _, err := os.Stat("/rootfs"); os.IsPermission(err) || os.IsNotExist(err) { | ||
|
@@ -82,73 +82,67 @@ func (c *NodeConfig) EnsureDocker(docker *dockerutil.Helper) { | |
if c.KubeletServer.ContainerRuntime != "docker" { | ||
return | ||
} | ||
dockerClient, dockerAddr, err := docker.GetKubeClient(c.KubeletServer.RuntimeRequestTimeout.Duration, c.KubeletServer.ImagePullProgressDeadline.Duration) | ||
if err != nil { | ||
c.HandleDockerError(fmt.Sprintf("Unable to create a Docker client for %s - Docker must be installed and running to start containers.\n%v", dockerAddr, err)) | ||
return | ||
|
||
var endpoint string | ||
if len(os.Getenv("DOCKER_HOST")) > 0 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems better suited like a config variable rather than an env. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Pre-existing as upstream helpers were removed. This can't change without breaking previously working environments. |
||
endpoint = os.Getenv("DOCKER_HOST") | ||
} else { | ||
endpoint = "unix:///var/run/docker.sock" | ||
} | ||
|
||
dockerClientConfig := &dockershim.ClientConfig{ | ||
DockerEndpoint: endpoint, | ||
RuntimeRequestTimeout: c.KubeletServer.RuntimeRequestTimeout.Duration, | ||
ImagePullProgressDeadline: c.KubeletServer.ImagePullProgressDeadline.Duration, | ||
} | ||
if url, err := url.Parse(dockerAddr); err == nil && url.Scheme == "unix" && len(url.Path) > 0 { | ||
client := dockertools.ConnectToDockerOrDie(endpoint, c.KubeletServer.RuntimeRequestTimeout.Duration, c.KubeletServer.ImagePullProgressDeadline.Duration, false, false) | ||
dockerClient := &dockerutil.KubeDocker{client} | ||
|
||
if url, err := url.Parse(endpoint); err == nil && url.Scheme == "unix" && len(url.Path) > 0 { | ||
s, err := os.Stat(url.Path) | ||
switch { | ||
case os.IsNotExist(err): | ||
c.HandleDockerError(fmt.Sprintf("No Docker socket found at %s. Have you started the Docker daemon?", url.Path)) | ||
glog.Fatalf("No Docker socket found at %s. Have you started the Docker daemon?", url.Path) | ||
return | ||
case os.IsPermission(err): | ||
c.HandleDockerError(fmt.Sprintf("You do not have permission to connect to the Docker daemon (via %s). This process requires running as the root user.", url.Path)) | ||
glog.Fatalf("You do not have permission to connect to the Docker daemon (via %s). This process requires running as the root user.", url.Path) | ||
return | ||
case err == nil && s.IsDir(): | ||
c.HandleDockerError(fmt.Sprintf("The Docker socket at %s is a directory instead of a unix socket - check that you have configured your connection to the Docker daemon properly.", url.Path)) | ||
glog.Fatalf("The Docker socket at %s is a directory instead of a unix socket - check that you have configured your connection to the Docker daemon properly.", url.Path) | ||
return | ||
} | ||
} | ||
if err := dockerClient.Ping(); err != nil { | ||
c.HandleDockerError(fmt.Sprintf("Docker could not be reached at %s. Docker must be installed and running to start containers.\n%v", dockerAddr, err)) | ||
glog.Fatalf("Docker could not be reached at %s. Docker must be installed and running to start containers.\n%v", endpoint, err) | ||
return | ||
} | ||
|
||
glog.Infof("Connecting to Docker at %s", dockerAddr) | ||
glog.Infof("Connecting to Docker at %s", endpoint) | ||
|
||
version, err := dockerClient.Version() | ||
if err != nil { | ||
c.HandleDockerError(fmt.Sprintf("Unable to check for Docker server version.\n%v", err)) | ||
glog.Fatalf("Unable to check for Docker server version.\n%v", err) | ||
return | ||
} | ||
|
||
serverVersion, err := dockerclient.NewAPIVersion(version.APIVersion) | ||
if err != nil { | ||
c.HandleDockerError(fmt.Sprintf("Unable to determine Docker server version from %q.\n%v", version.APIVersion, err)) | ||
glog.Fatalf("Unable to determine Docker server version from %q.\n%v", version.APIVersion, err) | ||
return | ||
} | ||
|
||
minimumPullByIDVersion, err := dockerclient.NewAPIVersion(minimumDockerAPIVersionWithPullByID) | ||
if err != nil { | ||
c.HandleDockerError(fmt.Sprintf("Unable to check for Docker server version.\n%v", err)) | ||
glog.Fatalf("Unable to check for Docker server version.\n%v", err) | ||
return | ||
} | ||
|
||
if serverVersion.LessThan(minimumPullByIDVersion) { | ||
c.HandleDockerError(fmt.Sprintf("Docker 1.6 or later (server API version %s or later) required.", minimumDockerAPIVersionWithPullByID)) | ||
glog.Fatalf("Docker 1.6 or later (server API version %s or later) required.", minimumDockerAPIVersionWithPullByID) | ||
return | ||
} | ||
|
||
c.DockerClient = dockerClient | ||
} | ||
|
||
// HandleDockerError handles an an error from the docker daemon | ||
func (c *NodeConfig) HandleDockerError(message string) { | ||
if !c.AllowDisabledDocker { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why remove this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
kubelet removed the ability to pass the client through, so the responsibility for wiring a fake falls to kubelet. We can't wire it through any more. |
||
glog.Fatalf("error: %s", message) | ||
} | ||
glog.Errorf("WARNING: %s", message) | ||
c.DockerClient = &dockertools.FakeDockerClient{ | ||
VersionInfo: dockertypes.Version{ | ||
APIVersion: minimumDockerAPIVersionWithPullByID, | ||
Version: "1.13", | ||
}, | ||
Information: dockertypes.Info{ | ||
CgroupDriver: "systemd", | ||
}, | ||
} | ||
c.DockerClientConfig = dockerClientConfig | ||
} | ||
|
||
// EnsureVolumeDir attempts to convert the provided volume directory argument to | ||
|
@@ -251,7 +245,7 @@ func (c *NodeConfig) RunKubelet() { | |
} | ||
|
||
// only set when ContainerRuntime == "docker" | ||
c.KubeletDeps.DockerClient = c.DockerClient | ||
c.KubeletDeps.DockerClientConfig = c.DockerClientConfig | ||
// updated by NodeConfig.EnsureVolumeDir | ||
c.KubeletServer.RootDirectory = c.VolumeDir | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,12 +12,13 @@ import ( | |
"k8s.io/apiserver/pkg/util/flag" | ||
kubeproxyoptions "k8s.io/kubernetes/cmd/kube-proxy/app" | ||
kubeletoptions "k8s.io/kubernetes/cmd/kubelet/app/options" | ||
"k8s.io/kubernetes/pkg/apis/componentconfig" | ||
"k8s.io/kubernetes/pkg/cloudprovider" | ||
"k8s.io/kubernetes/pkg/cloudprovider/providers/fake" | ||
"k8s.io/kubernetes/pkg/kubelet/apis/kubeletconfig" | ||
"k8s.io/kubernetes/pkg/kubelet/config" | ||
"k8s.io/kubernetes/pkg/kubelet/rkt" | ||
kubetypes "k8s.io/kubernetes/pkg/kubelet/types" | ||
"k8s.io/kubernetes/pkg/proxy/apis/kubeproxyconfig" | ||
) | ||
|
||
func TestKubeletDefaults(t *testing.T) { | ||
|
@@ -29,18 +30,29 @@ func TestKubeletDefaults(t *testing.T) { | |
expectedDefaults := &kubeletoptions.KubeletServer{ | ||
KubeletFlags: kubeletoptions.KubeletFlags{ | ||
KubeConfig: flag.NewStringFlag("/var/lib/kubelet/kubeconfig"), | ||
ContainerRuntimeOptions: kubeletoptions.ContainerRuntimeOptions{ | ||
ContainerRuntimeOptions: config.ContainerRuntimeOptions{ | ||
DockershimRootDirectory: "/var/lib/dockershim", | ||
DockerExecHandlerName: "native", | ||
DockerEndpoint: "unix:///var/run/docker.sock", | ||
ImagePullProgressDeadline: metav1.Duration{Duration: 1 * time.Minute}, | ||
RktAPIEndpoint: rkt.DefaultRktAPIServiceEndpoint, | ||
PodSandboxImage: "gcr.io/google_containers/pause-" + goruntime.GOARCH + ":3.0", // overridden | ||
DockerDisableSharedPID: true, | ||
ContainerRuntime: "docker", | ||
}, | ||
CloudProvider: "auto-detect", | ||
RootDirectory: "/var/lib/kubelet", | ||
CertDirectory: "/var/lib/kubelet/pki", | ||
CloudProvider: "", // now disabled | ||
RootDirectory: "/var/lib/kubelet", | ||
CertDirectory: "/var/lib/kubelet/pki", | ||
RegisterNode: true, // this looks suspicious | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove comment... this is ok |
||
RemoteRuntimeEndpoint: "unix:///var/run/dockershim.sock", // overridden | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add |
||
VolumePluginDir: "/usr/libexec/kubernetes/kubelet-plugins/volume/exec/", | ||
SeccompProfileRoot: "/var/lib/kubelet/seccomp", | ||
MaxContainerCount: -1, | ||
MasterServiceNamespace: "default", | ||
ExperimentalQOSReserved: map[string]string{}, | ||
NodeLabels: map[string]string{}, | ||
MaxPerPodContainerCount: 1, | ||
RegisterSchedulable: true, | ||
NonMasqueradeCIDR: "10.0.0.0/8", | ||
}, | ||
|
||
KubeletConfiguration: kubeletconfig.KubeletConfiguration{ | ||
|
@@ -65,18 +77,21 @@ func TestKubeletDefaults(t *testing.T) { | |
VolumeStatsAggPeriod: metav1.Duration{Duration: time.Minute}, | ||
CgroupRoot: "", | ||
CgroupDriver: "cgroupfs", | ||
ClusterDNS: nil, // overridden | ||
ClusterDomain: "", // overridden | ||
ContainerRuntime: "docker", | ||
Containerized: false, // overridden based on OPENSHIFT_CONTAINERIZED | ||
CPUCFSQuota: true, // forced to true | ||
|
||
EventBurst: 10, | ||
EventRecordQPS: 5.0, | ||
EnableCustomMetrics: false, | ||
EnableDebuggingHandlers: true, | ||
EnableServer: true, | ||
EvictionHard: "memory.available<100Mi,nodefs.available<10%,nodefs.inodesFree<5%", | ||
ClusterDNS: nil, // overridden | ||
ClusterDomain: "", // overridden | ||
CPUCFSQuota: true, // forced to true | ||
|
||
EventBurst: 10, | ||
EventRecordQPS: 5.0, | ||
//EnableCustomMetrics: false, | ||
EnableDebuggingHandlers: true, | ||
EnableServer: true, | ||
EvictionHard: map[string]string{ | ||
"memory.available": "100Mi", | ||
"nodefs.available": "10%", | ||
"nodefs.inodesFree": "5%", | ||
"imagefs.available": "15%", | ||
}, | ||
FileCheckFrequency: metav1.Duration{Duration: 20 * time.Second}, // overridden | ||
HealthzBindAddress: "127.0.0.1", // disabled | ||
HealthzPort: 10248, // disabled | ||
|
@@ -92,31 +107,19 @@ func TestKubeletDefaults(t *testing.T) { | |
// TODO figure out where this moved | ||
// LowDiskSpaceThresholdMB: 0, // used to be 256. Overriden to have old behavior. 3.7 | ||
MakeIPTablesUtilChains: true, | ||
MasterServiceNamespace: "default", | ||
MaxContainerCount: -1, | ||
MaxPerPodContainerCount: 1, | ||
MaxOpenFiles: 1000000, | ||
MaxPods: 110, // overridden | ||
MinimumGCAge: metav1.Duration{}, | ||
NonMasqueradeCIDR: "10.0.0.0/8", | ||
VolumePluginDir: "/usr/libexec/kubernetes/kubelet-plugins/volume/exec/", | ||
NodeStatusUpdateFrequency: metav1.Duration{Duration: 10 * time.Second}, | ||
NodeLabels: nil, | ||
OOMScoreAdj: -999, | ||
LockFilePath: "", | ||
Port: 10250, // overridden | ||
ReadOnlyPort: 10255, // disabled | ||
RegisterNode: true, | ||
RegisterSchedulable: true, | ||
RegistryBurst: 10, | ||
RegistryPullQPS: 5.0, | ||
RemoteRuntimeEndpoint: "unix:///var/run/dockershim.sock", // overridden | ||
ResolverConfig: kubetypes.ResolvConfDefault, | ||
KubeletCgroups: "", | ||
CgroupsPerQOS: true, | ||
// TODO figure out where this moved | ||
// RootDirectory: "/var/lib/kubelet", // overridden | ||
RuntimeCgroups: "", | ||
//RuntimeCgroups: "", | ||
SerializeImagePulls: true, | ||
StreamingConnectionIdleTimeout: metav1.Duration{Duration: 4 * time.Hour}, | ||
SyncFrequency: metav1.Duration{Duration: 1 * time.Minute}, | ||
|
@@ -125,22 +128,15 @@ func TestKubeletDefaults(t *testing.T) { | |
TLSPrivateKeyFile: "", // overridden to prevent cert generation | ||
KubeAPIQPS: 5.0, | ||
KubeAPIBurst: 10, | ||
// TODO figure out where this moved | ||
// OutOfDiskTransitionFrequency: metav1.Duration{Duration: 5 * time.Minute}, | ||
HairpinMode: "promiscuous-bridge", | ||
SeccompProfileRoot: "/var/lib/kubelet/seccomp", | ||
// TODO figure out where this moved | ||
// CloudProvider: "auto-detect", | ||
RuntimeRequestTimeout: metav1.Duration{Duration: 2 * time.Minute}, | ||
ContentType: "application/vnd.kubernetes.protobuf", | ||
EnableControllerAttachDetach: true, | ||
ExperimentalQOSReserved: kubeletconfig.ConfigurationMap{}, | ||
HairpinMode: "promiscuous-bridge", | ||
RuntimeRequestTimeout: metav1.Duration{Duration: 2 * time.Minute}, | ||
ContentType: "application/vnd.kubernetes.protobuf", | ||
EnableControllerAttachDetach: true, | ||
|
||
EvictionPressureTransitionPeriod: metav1.Duration{Duration: 5 * time.Minute}, | ||
ExperimentalKernelMemcgNotification: false, | ||
EvictionPressureTransitionPeriod: metav1.Duration{Duration: 5 * time.Minute}, | ||
|
||
SystemReserved: kubeletconfig.ConfigurationMap{}, | ||
KubeReserved: kubeletconfig.ConfigurationMap{}, | ||
SystemReserved: nil, | ||
KubeReserved: nil, | ||
|
||
EnforceNodeAllocatable: []string{"pods"}, | ||
|
||
|
@@ -151,7 +147,7 @@ func TestKubeletDefaults(t *testing.T) { | |
} | ||
|
||
if goruntime.GOOS == "darwin" { | ||
expectedDefaults.KubeletConfiguration.RemoteRuntimeEndpoint = "" | ||
//expectedDefaults.KubeletConfiguration.RemoteRuntimeEndpoint = "" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. follow up to restore this, |
||
} | ||
|
||
if !reflect.DeepEqual(defaults, expectedDefaults) { | ||
|
@@ -166,33 +162,38 @@ func TestProxyConfig(t *testing.T) { | |
// Once we've reacted to the changes appropriately in buildKubeProxyConfig(), update this expected default to match the new upstream defaults | ||
oomScoreAdj := int32(-999) | ||
ipTablesMasqueratebit := int32(14) | ||
conntrackMin := int32(128 * 1024) | ||
conntrackMaxPerCore := int32(32 * 1024) | ||
|
||
expectedProxyConfig := &componentconfig.KubeProxyConfiguration{ | ||
expectedProxyConfig := &kubeproxyconfig.KubeProxyConfiguration{ | ||
BindAddress: "0.0.0.0", | ||
HealthzBindAddress: "0.0.0.0:10256", // disabled | ||
MetricsBindAddress: "127.0.0.1:10249", // disabled | ||
ClientConnection: componentconfig.ClientConnectionConfiguration{ | ||
ClientConnection: kubeproxyconfig.ClientConnectionConfiguration{ | ||
ContentType: "application/vnd.kubernetes.protobuf", | ||
QPS: 5, | ||
Burst: 10, | ||
}, | ||
IPTables: componentconfig.KubeProxyIPTablesConfiguration{ | ||
IPTables: kubeproxyconfig.KubeProxyIPTablesConfiguration{ | ||
MasqueradeBit: &ipTablesMasqueratebit, | ||
SyncPeriod: metav1.Duration{Duration: 30 * time.Second}, | ||
}, | ||
IPVS: kubeproxyconfig.KubeProxyIPVSConfiguration{ | ||
SyncPeriod: metav1.Duration{Duration: 30 * time.Second}, | ||
}, | ||
OOMScoreAdj: &oomScoreAdj, // disabled | ||
ResourceContainer: "/kube-proxy", // disabled | ||
UDPIdleTimeout: metav1.Duration{Duration: 250 * time.Millisecond}, | ||
Conntrack: componentconfig.KubeProxyConntrackConfiguration{ | ||
Min: 128 * 1024, | ||
MaxPerCore: 32 * 1024, | ||
TCPEstablishedTimeout: metav1.Duration{Duration: 86400 * time.Second}, // 1 day (1/5 default) | ||
TCPCloseWaitTimeout: metav1.Duration{Duration: 1 * time.Hour}, | ||
Conntrack: kubeproxyconfig.KubeProxyConntrackConfiguration{ | ||
Min: &conntrackMin, | ||
MaxPerCore: &conntrackMaxPerCore, | ||
TCPEstablishedTimeout: &metav1.Duration{Duration: 86400 * time.Second}, // 1 day (1/5 default) | ||
TCPCloseWaitTimeout: &metav1.Duration{Duration: 1 * time.Hour}, | ||
}, | ||
ConfigSyncPeriod: metav1.Duration{Duration: 15 * time.Minute}, | ||
} | ||
|
||
actualDefaultConfig, _ := kubeproxyoptions.NewOptions() | ||
actualDefaultConfig := kubeproxyoptions.NewOptions() | ||
actualConfig, _ := actualDefaultConfig.ApplyDefaults(actualDefaultConfig.GetConfig()) | ||
|
||
if !reflect.DeepEqual(expectedProxyConfig, actualConfig) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems like we should be moving away from these checks as we lean more on cri, not making them unconditionally fatal
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a pre-existing move. Not something net new.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or at least move this into EnsureDocker or protect with
if c.KubeletServer.ContainerRuntime == "docker" { ... }