mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-05 10:19:50 +00:00
Remove cmd/kubelet dependency from pkg/kubelet/volumemanager
This commit is contained in:
parent
26b11474ca
commit
2a2b0cbffa
@ -37,13 +37,6 @@ import (
|
|||||||
utiltaints "k8s.io/kubernetes/pkg/util/taints"
|
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:
|
// 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 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)
|
// - its value cannot be safely shared between nodes at the same time (e.g. a hostname)
|
||||||
|
@ -12,6 +12,7 @@ go_library(
|
|||||||
"apiserver.go",
|
"apiserver.go",
|
||||||
"common.go",
|
"common.go",
|
||||||
"config.go",
|
"config.go",
|
||||||
|
"defaults.go",
|
||||||
"doc.go",
|
"doc.go",
|
||||||
"file.go",
|
"file.go",
|
||||||
"file_unsupported.go",
|
"file_unsupported.go",
|
||||||
|
24
pkg/kubelet/config/defaults.go
Normal file
24
pkg/kubelet/config/defaults.go
Normal file
@ -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"
|
||||||
|
)
|
@ -27,8 +27,8 @@ import (
|
|||||||
|
|
||||||
"k8s.io/api/core/v1"
|
"k8s.io/api/core/v1"
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
"k8s.io/kubernetes/cmd/kubelet/app/options"
|
|
||||||
"k8s.io/kubernetes/pkg/kubelet/cm"
|
"k8s.io/kubernetes/pkg/kubelet/cm"
|
||||||
|
"k8s.io/kubernetes/pkg/kubelet/config"
|
||||||
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
|
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
|
||||||
utilfile "k8s.io/kubernetes/pkg/util/file"
|
utilfile "k8s.io/kubernetes/pkg/util/file"
|
||||||
utilnode "k8s.io/kubernetes/pkg/util/node"
|
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
|
// getPodsDir returns the full path to the directory under which pod
|
||||||
// directories are created.
|
// directories are created.
|
||||||
func (kl *Kubelet) getPodsDir() string {
|
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
|
// 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
|
// they need to persist. Plugins should create subdirectories under this named
|
||||||
// after their own names.
|
// after their own names.
|
||||||
func (kl *Kubelet) getPluginsDir() string {
|
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.
|
// 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
|
// which volumes are created for the specified pod. This directory may not
|
||||||
// exist if the pod does not exist.
|
// exist if the pod does not exist.
|
||||||
func (kl *Kubelet) getPodVolumesDir(podUID types.UID) string {
|
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
|
// 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
|
// which plugins may store data for the specified pod. This directory may not
|
||||||
// exist if the pod does not exist.
|
// exist if the pod does not exist.
|
||||||
func (kl *Kubelet) getPodPluginsDir(podUID types.UID) string {
|
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
|
// 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
|
// which container data is held for the specified pod. This directory may not
|
||||||
// exist if the pod or container does not exist.
|
// exist if the pod or container does not exist.
|
||||||
func (kl *Kubelet) getPodContainerDir(podUID types.UID, ctrName string) string {
|
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
|
// GetPods returns all pods bound to the kubelet and their spec, and the mirror
|
||||||
|
@ -10,7 +10,7 @@ go_library(
|
|||||||
name = "go_default_library",
|
name = "go_default_library",
|
||||||
srcs = ["reconciler.go"],
|
srcs = ["reconciler.go"],
|
||||||
deps = [
|
deps = [
|
||||||
"//cmd/kubelet/app/options:go_default_library",
|
"//pkg/kubelet/config:go_default_library",
|
||||||
"//pkg/kubelet/volumemanager/cache:go_default_library",
|
"//pkg/kubelet/volumemanager/cache:go_default_library",
|
||||||
"//pkg/util/file:go_default_library",
|
"//pkg/util/file:go_default_library",
|
||||||
"//pkg/util/goroutinemap/exponentialbackoff:go_default_library",
|
"//pkg/util/goroutinemap/exponentialbackoff:go_default_library",
|
||||||
|
@ -31,7 +31,7 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
"k8s.io/apimachinery/pkg/util/wait"
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
clientset "k8s.io/client-go/kubernetes"
|
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"
|
"k8s.io/kubernetes/pkg/kubelet/volumemanager/cache"
|
||||||
utilfile "k8s.io/kubernetes/pkg/util/file"
|
utilfile "k8s.io/kubernetes/pkg/util/file"
|
||||||
"k8s.io/kubernetes/pkg/util/goroutinemap/exponentialbackoff"
|
"k8s.io/kubernetes/pkg/util/goroutinemap/exponentialbackoff"
|
||||||
@ -574,7 +574,7 @@ func getVolumesFromPodDir(podDir string) ([]podVolume, error) {
|
|||||||
}
|
}
|
||||||
podName := podsDirInfo[i].Name()
|
podName := podsDirInfo[i].Name()
|
||||||
podDir := path.Join(podDir, podName)
|
podDir := path.Join(podDir, podName)
|
||||||
volumesDir := path.Join(podDir, options.DefaultKubeletVolumesDirName)
|
volumesDir := path.Join(podDir, config.DefaultKubeletVolumesDirName)
|
||||||
volumesDirInfo, err := ioutil.ReadDir(volumesDir)
|
volumesDirInfo, err := ioutil.ReadDir(volumesDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("Could not read volume directory %q: %v", volumesDir, err)
|
glog.Errorf("Could not read volume directory %q: %v", volumesDir, err)
|
||||||
|
Loading…
Reference in New Issue
Block a user