diff --git a/cmd/kubelet/app/options/options.go b/cmd/kubelet/app/options/options.go index 0cf139c4196..b82ee9cc357 100644 --- a/cmd/kubelet/app/options/options.go +++ b/cmd/kubelet/app/options/options.go @@ -37,13 +37,6 @@ import ( utiltaints "k8s.io/kubernetes/pkg/util/taints" ) -const ( - DefaultKubeletPodsDirName = "pods" - DefaultKubeletVolumesDirName = "volumes" - DefaultKubeletPluginsDirName = "plugins" - DefaultKubeletContainersDirName = "containers" -) - // A configuration field should go in KubeletFlags instead of KubeletConfiguration if any of these are true: // - its value will never, or cannot safely be changed during the lifetime of a node // - its value cannot be safely shared between nodes at the same time (e.g. a hostname) diff --git a/pkg/kubelet/config/BUILD b/pkg/kubelet/config/BUILD index defc45f72d3..4d575869de9 100644 --- a/pkg/kubelet/config/BUILD +++ b/pkg/kubelet/config/BUILD @@ -12,6 +12,7 @@ go_library( "apiserver.go", "common.go", "config.go", + "defaults.go", "doc.go", "file.go", "file_unsupported.go", diff --git a/pkg/kubelet/config/defaults.go b/pkg/kubelet/config/defaults.go new file mode 100644 index 00000000000..b000b60b11f --- /dev/null +++ b/pkg/kubelet/config/defaults.go @@ -0,0 +1,24 @@ +/* +Copyright 2017 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 config + +const ( + DefaultKubeletPodsDirName = "pods" + DefaultKubeletVolumesDirName = "volumes" + DefaultKubeletPluginsDirName = "plugins" + DefaultKubeletContainersDirName = "containers" +) diff --git a/pkg/kubelet/kubelet_getters.go b/pkg/kubelet/kubelet_getters.go index 7737229507e..525f94cb717 100644 --- a/pkg/kubelet/kubelet_getters.go +++ b/pkg/kubelet/kubelet_getters.go @@ -27,8 +27,8 @@ import ( "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" - "k8s.io/kubernetes/cmd/kubelet/app/options" "k8s.io/kubernetes/pkg/kubelet/cm" + "k8s.io/kubernetes/pkg/kubelet/config" kubecontainer "k8s.io/kubernetes/pkg/kubelet/container" utilfile "k8s.io/kubernetes/pkg/util/file" utilnode "k8s.io/kubernetes/pkg/util/node" @@ -46,7 +46,7 @@ func (kl *Kubelet) getRootDir() string { // getPodsDir returns the full path to the directory under which pod // directories are created. func (kl *Kubelet) getPodsDir() string { - return filepath.Join(kl.getRootDir(), options.DefaultKubeletPodsDirName) + return filepath.Join(kl.getRootDir(), config.DefaultKubeletPodsDirName) } // getPluginsDir returns the full path to the directory under which plugin @@ -54,7 +54,7 @@ func (kl *Kubelet) getPodsDir() string { // they need to persist. Plugins should create subdirectories under this named // after their own names. func (kl *Kubelet) getPluginsDir() string { - return filepath.Join(kl.getRootDir(), options.DefaultKubeletPluginsDirName) + return filepath.Join(kl.getRootDir(), config.DefaultKubeletPluginsDirName) } // getPluginDir returns a data directory name for a given plugin name. @@ -80,7 +80,7 @@ func (kl *Kubelet) getPodDir(podUID types.UID) string { // which volumes are created for the specified pod. This directory may not // exist if the pod does not exist. func (kl *Kubelet) getPodVolumesDir(podUID types.UID) string { - return filepath.Join(kl.getPodDir(podUID), options.DefaultKubeletVolumesDirName) + return filepath.Join(kl.getPodDir(podUID), config.DefaultKubeletVolumesDirName) } // getPodVolumeDir returns the full path to the directory which represents the @@ -94,7 +94,7 @@ func (kl *Kubelet) getPodVolumeDir(podUID types.UID, pluginName string, volumeNa // which plugins may store data for the specified pod. This directory may not // exist if the pod does not exist. func (kl *Kubelet) getPodPluginsDir(podUID types.UID) string { - return filepath.Join(kl.getPodDir(podUID), options.DefaultKubeletPluginsDirName) + return filepath.Join(kl.getPodDir(podUID), config.DefaultKubeletPluginsDirName) } // getPodPluginDir returns a data directory name for a given plugin name for a @@ -108,7 +108,7 @@ func (kl *Kubelet) getPodPluginDir(podUID types.UID, pluginName string) string { // which container data is held for the specified pod. This directory may not // exist if the pod or container does not exist. func (kl *Kubelet) getPodContainerDir(podUID types.UID, ctrName string) string { - return filepath.Join(kl.getPodDir(podUID), options.DefaultKubeletContainersDirName, ctrName) + return filepath.Join(kl.getPodDir(podUID), config.DefaultKubeletContainersDirName, ctrName) } // GetPods returns all pods bound to the kubelet and their spec, and the mirror diff --git a/pkg/kubelet/volumemanager/reconciler/BUILD b/pkg/kubelet/volumemanager/reconciler/BUILD index 97065574636..b4a1d36b0a2 100644 --- a/pkg/kubelet/volumemanager/reconciler/BUILD +++ b/pkg/kubelet/volumemanager/reconciler/BUILD @@ -10,7 +10,7 @@ go_library( name = "go_default_library", srcs = ["reconciler.go"], deps = [ - "//cmd/kubelet/app/options:go_default_library", + "//pkg/kubelet/config:go_default_library", "//pkg/kubelet/volumemanager/cache:go_default_library", "//pkg/util/file:go_default_library", "//pkg/util/goroutinemap/exponentialbackoff:go_default_library", diff --git a/pkg/kubelet/volumemanager/reconciler/reconciler.go b/pkg/kubelet/volumemanager/reconciler/reconciler.go index 73ac4da99c8..81642fb6a29 100644 --- a/pkg/kubelet/volumemanager/reconciler/reconciler.go +++ b/pkg/kubelet/volumemanager/reconciler/reconciler.go @@ -31,7 +31,7 @@ import ( "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/wait" clientset "k8s.io/client-go/kubernetes" - "k8s.io/kubernetes/cmd/kubelet/app/options" + "k8s.io/kubernetes/pkg/kubelet/config" "k8s.io/kubernetes/pkg/kubelet/volumemanager/cache" utilfile "k8s.io/kubernetes/pkg/util/file" "k8s.io/kubernetes/pkg/util/goroutinemap/exponentialbackoff" @@ -574,7 +574,7 @@ func getVolumesFromPodDir(podDir string) ([]podVolume, error) { } podName := podsDirInfo[i].Name() podDir := path.Join(podDir, podName) - volumesDir := path.Join(podDir, options.DefaultKubeletVolumesDirName) + volumesDir := path.Join(podDir, config.DefaultKubeletVolumesDirName) volumesDirInfo, err := ioutil.ReadDir(volumesDir) if err != nil { glog.Errorf("Could not read volume directory %q: %v", volumesDir, err)