Replace godep with dep
This commit is contained in:
parent
1e7489927c
commit
bf5616c65b
14883 changed files with 3937406 additions and 361781 deletions
46
vendor/k8s.io/kubernetes/cmd/kubelet/BUILD
generated
vendored
Normal file
46
vendor/k8s.io/kubernetes/cmd/kubelet/BUILD
generated
vendored
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_binary",
|
||||
"go_library",
|
||||
)
|
||||
load("//pkg/version:def.bzl", "version_x_defs")
|
||||
|
||||
go_binary(
|
||||
name = "kubelet",
|
||||
library = ":go_default_library",
|
||||
x_defs = version_x_defs(),
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["kubelet.go"],
|
||||
deps = [
|
||||
"//cmd/kubelet/app:go_default_library",
|
||||
"//cmd/kubelet/app/options:go_default_library",
|
||||
"//pkg/client/metrics/prometheus:go_default_library",
|
||||
"//pkg/version/prometheus:go_default_library",
|
||||
"//pkg/version/verflag:go_default_library",
|
||||
"//vendor/github.com/spf13/pflag:go_default_library",
|
||||
"//vendor/k8s.io/apiserver/pkg/util/feature:go_default_library",
|
||||
"//vendor/k8s.io/apiserver/pkg/util/flag:go_default_library",
|
||||
"//vendor/k8s.io/apiserver/pkg/util/logs:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [
|
||||
":package-srcs",
|
||||
"//cmd/kubelet/app:all-srcs",
|
||||
],
|
||||
tags = ["automanaged"],
|
||||
)
|
||||
8
vendor/k8s.io/kubernetes/cmd/kubelet/OWNERS
generated
vendored
Normal file
8
vendor/k8s.io/kubernetes/cmd/kubelet/OWNERS
generated
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
approvers:
|
||||
- dchen1107
|
||||
- derekwaynecarr
|
||||
- Random-Liu
|
||||
- vishh
|
||||
- yujuhong
|
||||
reviewers:
|
||||
- sig-node-reviewers
|
||||
146
vendor/k8s.io/kubernetes/cmd/kubelet/app/BUILD
generated
vendored
Normal file
146
vendor/k8s.io/kubernetes/cmd/kubelet/app/BUILD
generated
vendored
Normal file
|
|
@ -0,0 +1,146 @@
|
|||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_library",
|
||||
"go_test",
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["server_test.go"],
|
||||
library = ":go_default_library",
|
||||
deps = ["//pkg/kubelet/apis/kubeletconfig:go_default_library"],
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"auth.go",
|
||||
"plugins.go",
|
||||
"server.go",
|
||||
"server_unsupported.go",
|
||||
] + select({
|
||||
"@io_bazel_rules_go//go/platform:linux_amd64": [
|
||||
"server_linux.go",
|
||||
],
|
||||
"//conditions:default": [],
|
||||
}),
|
||||
deps = [
|
||||
"//cmd/kubelet/app/options:go_default_library",
|
||||
"//pkg/api:go_default_library",
|
||||
"//pkg/capabilities:go_default_library",
|
||||
"//pkg/client/chaosclient:go_default_library",
|
||||
"//pkg/cloudprovider:go_default_library",
|
||||
"//pkg/cloudprovider/providers:go_default_library",
|
||||
"//pkg/credentialprovider:go_default_library",
|
||||
"//pkg/credentialprovider/aws:go_default_library",
|
||||
"//pkg/credentialprovider/azure:go_default_library",
|
||||
"//pkg/credentialprovider/gcp:go_default_library",
|
||||
"//pkg/credentialprovider/rancher:go_default_library",
|
||||
"//pkg/features:go_default_library",
|
||||
"//pkg/kubelet:go_default_library",
|
||||
"//pkg/kubelet/apis/kubeletconfig:go_default_library",
|
||||
"//pkg/kubelet/apis/kubeletconfig/scheme:go_default_library",
|
||||
"//pkg/kubelet/apis/kubeletconfig/v1alpha1:go_default_library",
|
||||
"//pkg/kubelet/cadvisor:go_default_library",
|
||||
"//pkg/kubelet/certificate:go_default_library",
|
||||
"//pkg/kubelet/certificate/bootstrap:go_default_library",
|
||||
"//pkg/kubelet/cm:go_default_library",
|
||||
"//pkg/kubelet/config:go_default_library",
|
||||
"//pkg/kubelet/container:go_default_library",
|
||||
"//pkg/kubelet/dockershim:go_default_library",
|
||||
"//pkg/kubelet/dockershim/libdocker:go_default_library",
|
||||
"//pkg/kubelet/dockershim/remote:go_default_library",
|
||||
"//pkg/kubelet/eviction:go_default_library",
|
||||
"//pkg/kubelet/eviction/api:go_default_library",
|
||||
"//pkg/kubelet/kubeletconfig:go_default_library",
|
||||
"//pkg/kubelet/network:go_default_library",
|
||||
"//pkg/kubelet/network/cni:go_default_library",
|
||||
"//pkg/kubelet/network/kubenet:go_default_library",
|
||||
"//pkg/kubelet/server:go_default_library",
|
||||
"//pkg/kubelet/server/streaming:go_default_library",
|
||||
"//pkg/kubelet/types:go_default_library",
|
||||
"//pkg/util/configz:go_default_library",
|
||||
"//pkg/util/flock:go_default_library",
|
||||
"//pkg/util/io:go_default_library",
|
||||
"//pkg/util/mount:go_default_library",
|
||||
"//pkg/util/node:go_default_library",
|
||||
"//pkg/util/oom:go_default_library",
|
||||
"//pkg/util/rlimit:go_default_library",
|
||||
"//pkg/version:go_default_library",
|
||||
"//pkg/volume:go_default_library",
|
||||
"//pkg/volume/aws_ebs:go_default_library",
|
||||
"//pkg/volume/azure_dd:go_default_library",
|
||||
"//pkg/volume/azure_file:go_default_library",
|
||||
"//pkg/volume/cephfs:go_default_library",
|
||||
"//pkg/volume/cinder:go_default_library",
|
||||
"//pkg/volume/configmap:go_default_library",
|
||||
"//pkg/volume/downwardapi:go_default_library",
|
||||
"//pkg/volume/empty_dir:go_default_library",
|
||||
"//pkg/volume/fc:go_default_library",
|
||||
"//pkg/volume/flexvolume:go_default_library",
|
||||
"//pkg/volume/flocker:go_default_library",
|
||||
"//pkg/volume/gce_pd:go_default_library",
|
||||
"//pkg/volume/git_repo:go_default_library",
|
||||
"//pkg/volume/glusterfs:go_default_library",
|
||||
"//pkg/volume/host_path:go_default_library",
|
||||
"//pkg/volume/iscsi:go_default_library",
|
||||
"//pkg/volume/local:go_default_library",
|
||||
"//pkg/volume/nfs:go_default_library",
|
||||
"//pkg/volume/photon_pd:go_default_library",
|
||||
"//pkg/volume/portworx:go_default_library",
|
||||
"//pkg/volume/projected:go_default_library",
|
||||
"//pkg/volume/quobyte:go_default_library",
|
||||
"//pkg/volume/rbd:go_default_library",
|
||||
"//pkg/volume/scaleio:go_default_library",
|
||||
"//pkg/volume/secret:go_default_library",
|
||||
"//pkg/volume/storageos:go_default_library",
|
||||
"//pkg/volume/vsphere_volume:go_default_library",
|
||||
"//vendor/github.com/golang/glog:go_default_library",
|
||||
"//vendor/github.com/spf13/cobra:go_default_library",
|
||||
"//vendor/github.com/spf13/pflag:go_default_library",
|
||||
"//vendor/k8s.io/api/core/v1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/api/resource:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/types:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/runtime:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/wait:go_default_library",
|
||||
"//vendor/k8s.io/apiserver/pkg/authentication/authenticator:go_default_library",
|
||||
"//vendor/k8s.io/apiserver/pkg/authentication/authenticatorfactory:go_default_library",
|
||||
"//vendor/k8s.io/apiserver/pkg/authorization/authorizer:go_default_library",
|
||||
"//vendor/k8s.io/apiserver/pkg/authorization/authorizerfactory:go_default_library",
|
||||
"//vendor/k8s.io/apiserver/pkg/server/healthz:go_default_library",
|
||||
"//vendor/k8s.io/apiserver/pkg/util/feature:go_default_library",
|
||||
"//vendor/k8s.io/apiserver/pkg/util/flag:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/authentication/v1beta1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/authorization/v1beta1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/core/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/rest:go_default_library",
|
||||
"//vendor/k8s.io/client-go/tools/clientcmd:go_default_library",
|
||||
"//vendor/k8s.io/client-go/tools/record:go_default_library",
|
||||
"//vendor/k8s.io/client-go/util/cert:go_default_library",
|
||||
] + select({
|
||||
"@io_bazel_rules_go//go/platform:linux_amd64": [
|
||||
"//vendor/golang.org/x/exp/inotify:go_default_library",
|
||||
],
|
||||
"//conditions:default": [],
|
||||
}),
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [
|
||||
":package-srcs",
|
||||
"//cmd/kubelet/app/options:all-srcs",
|
||||
],
|
||||
tags = ["automanaged"],
|
||||
)
|
||||
2
vendor/k8s.io/kubernetes/cmd/kubelet/app/OWNERS
generated
vendored
Executable file
2
vendor/k8s.io/kubernetes/cmd/kubelet/app/OWNERS
generated
vendored
Executable file
|
|
@ -0,0 +1,2 @@
|
|||
reviewers:
|
||||
- sig-node-reviewers
|
||||
107
vendor/k8s.io/kubernetes/cmd/kubelet/app/auth.go
generated
vendored
Normal file
107
vendor/k8s.io/kubernetes/cmd/kubelet/app/auth.go
generated
vendored
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
/*
|
||||
Copyright 2016 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 app
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"reflect"
|
||||
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/apiserver/pkg/authentication/authenticator"
|
||||
"k8s.io/apiserver/pkg/authentication/authenticatorfactory"
|
||||
"k8s.io/apiserver/pkg/authorization/authorizer"
|
||||
"k8s.io/apiserver/pkg/authorization/authorizerfactory"
|
||||
clientset "k8s.io/client-go/kubernetes"
|
||||
authenticationclient "k8s.io/client-go/kubernetes/typed/authentication/v1beta1"
|
||||
authorizationclient "k8s.io/client-go/kubernetes/typed/authorization/v1beta1"
|
||||
|
||||
"k8s.io/kubernetes/pkg/kubelet/apis/kubeletconfig"
|
||||
"k8s.io/kubernetes/pkg/kubelet/server"
|
||||
)
|
||||
|
||||
// BuildAuth creates an authenticator, an authorizer, and a matching authorizer attributes getter compatible with the kubelet's needs
|
||||
func BuildAuth(nodeName types.NodeName, client clientset.Interface, config kubeletconfig.KubeletConfiguration) (server.AuthInterface, error) {
|
||||
// Get clients, if provided
|
||||
var (
|
||||
tokenClient authenticationclient.TokenReviewInterface
|
||||
sarClient authorizationclient.SubjectAccessReviewInterface
|
||||
)
|
||||
if client != nil && !reflect.ValueOf(client).IsNil() {
|
||||
tokenClient = client.AuthenticationV1beta1().TokenReviews()
|
||||
sarClient = client.AuthorizationV1beta1().SubjectAccessReviews()
|
||||
}
|
||||
|
||||
authenticator, err := BuildAuthn(tokenClient, config.Authentication)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
attributes := server.NewNodeAuthorizerAttributesGetter(nodeName)
|
||||
|
||||
authorizer, err := BuildAuthz(sarClient, config.Authorization)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return server.NewKubeletAuth(authenticator, attributes, authorizer), nil
|
||||
}
|
||||
|
||||
// BuildAuthn creates an authenticator compatible with the kubelet's needs
|
||||
func BuildAuthn(client authenticationclient.TokenReviewInterface, authn kubeletconfig.KubeletAuthentication) (authenticator.Request, error) {
|
||||
authenticatorConfig := authenticatorfactory.DelegatingAuthenticatorConfig{
|
||||
Anonymous: authn.Anonymous.Enabled,
|
||||
CacheTTL: authn.Webhook.CacheTTL.Duration,
|
||||
ClientCAFile: authn.X509.ClientCAFile,
|
||||
}
|
||||
|
||||
if authn.Webhook.Enabled {
|
||||
if client == nil {
|
||||
return nil, errors.New("no client provided, cannot use webhook authentication")
|
||||
}
|
||||
authenticatorConfig.TokenAccessReviewClient = client
|
||||
}
|
||||
|
||||
authenticator, _, err := authenticatorConfig.New()
|
||||
return authenticator, err
|
||||
}
|
||||
|
||||
// BuildAuthz creates an authorizer compatible with the kubelet's needs
|
||||
func BuildAuthz(client authorizationclient.SubjectAccessReviewInterface, authz kubeletconfig.KubeletAuthorization) (authorizer.Authorizer, error) {
|
||||
switch authz.Mode {
|
||||
case kubeletconfig.KubeletAuthorizationModeAlwaysAllow:
|
||||
return authorizerfactory.NewAlwaysAllowAuthorizer(), nil
|
||||
|
||||
case kubeletconfig.KubeletAuthorizationModeWebhook:
|
||||
if client == nil {
|
||||
return nil, errors.New("no client provided, cannot use webhook authorization")
|
||||
}
|
||||
authorizerConfig := authorizerfactory.DelegatingAuthorizerConfig{
|
||||
SubjectAccessReviewClient: client,
|
||||
AllowCacheTTL: authz.Webhook.CacheAuthorizedTTL.Duration,
|
||||
DenyCacheTTL: authz.Webhook.CacheUnauthorizedTTL.Duration,
|
||||
}
|
||||
return authorizerConfig.New()
|
||||
|
||||
case "":
|
||||
return nil, fmt.Errorf("No authorization mode specified")
|
||||
|
||||
default:
|
||||
return nil, fmt.Errorf("Unknown authorization mode %s", authz.Mode)
|
||||
|
||||
}
|
||||
}
|
||||
40
vendor/k8s.io/kubernetes/cmd/kubelet/app/options/BUILD
generated
vendored
Normal file
40
vendor/k8s.io/kubernetes/cmd/kubelet/app/options/BUILD
generated
vendored
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_library",
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"container_runtime.go",
|
||||
"options.go",
|
||||
],
|
||||
deps = [
|
||||
"//pkg/apis/componentconfig:go_default_library",
|
||||
"//pkg/features:go_default_library",
|
||||
"//pkg/kubelet/apis/kubeletconfig:go_default_library",
|
||||
"//pkg/kubelet/apis/kubeletconfig/scheme:go_default_library",
|
||||
"//pkg/kubelet/apis/kubeletconfig/v1alpha1:go_default_library",
|
||||
"//pkg/kubelet/apis/kubeletconfig/validation:go_default_library",
|
||||
"//pkg/util/taints:go_default_library",
|
||||
"//vendor/github.com/spf13/pflag:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
"//vendor/k8s.io/apiserver/pkg/util/feature:go_default_library",
|
||||
"//vendor/k8s.io/apiserver/pkg/util/flag:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
)
|
||||
148
vendor/k8s.io/kubernetes/cmd/kubelet/app/options/container_runtime.go
generated
vendored
Normal file
148
vendor/k8s.io/kubernetes/cmd/kubelet/app/options/container_runtime.go
generated
vendored
Normal file
|
|
@ -0,0 +1,148 @@
|
|||
/*
|
||||
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 options
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
"time"
|
||||
|
||||
"github.com/spf13/pflag"
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
const (
|
||||
// When these values are updated, also update test/e2e/framework/util.go
|
||||
defaultPodSandboxImageName = "gcr.io/google_containers/pause"
|
||||
defaultPodSandboxImageVersion = "3.0"
|
||||
// From pkg/kubelet/rkt/rkt.go to avoid circular import
|
||||
defaultRktAPIServiceEndpoint = "localhost:15441"
|
||||
)
|
||||
|
||||
var (
|
||||
defaultPodSandboxImage = defaultPodSandboxImageName +
|
||||
"-" + runtime.GOARCH + ":" +
|
||||
defaultPodSandboxImageVersion
|
||||
)
|
||||
|
||||
type ContainerRuntimeOptions struct {
|
||||
// Docker-specific options.
|
||||
|
||||
// DockershimRootDirectory is the path to the dockershim root directory. Defaults to
|
||||
// /var/lib/dockershim if unset. Exposed for integration testing (e.g. in OpenShift).
|
||||
DockershimRootDirectory string
|
||||
// Enable dockershim only mode.
|
||||
ExperimentalDockershim bool
|
||||
// This flag, if set, disables use of a shared PID namespace for pods running in the docker CRI runtime.
|
||||
// A shared PID namespace is the only option in non-docker runtimes and is required by the CRI. The ability to
|
||||
// disable it for docker will be removed unless a compelling use case is discovered with widespread use.
|
||||
// TODO: Remove once we no longer support disabling shared PID namespace (https://issues.k8s.io/41938)
|
||||
DockerDisableSharedPID bool
|
||||
// PodSandboxImage is the image whose network/ipc namespaces
|
||||
// containers in each pod will use.
|
||||
PodSandboxImage string
|
||||
// DockerEndpoint is the path to the docker endpoint to communicate with.
|
||||
DockerEndpoint string
|
||||
// DockerExecHandlerName is the handler to use when executing a command
|
||||
// in a container. Valid values are 'native' and 'nsenter'. Defaults to
|
||||
// 'native'.
|
||||
DockerExecHandlerName string
|
||||
// If no pulling progress is made before the deadline imagePullProgressDeadline,
|
||||
// the image pulling will be cancelled. Defaults to 1m0s.
|
||||
// +optional
|
||||
ImagePullProgressDeadline metav1.Duration
|
||||
|
||||
// Network plugin options.
|
||||
|
||||
// networkPluginName is the name of the network plugin to be invoked for
|
||||
// various events in kubelet/pod lifecycle
|
||||
NetworkPluginName string
|
||||
// NetworkPluginMTU is the MTU to be passed to the network plugin,
|
||||
// and overrides the default MTU for cases where it cannot be automatically
|
||||
// computed (such as IPSEC).
|
||||
NetworkPluginMTU int32
|
||||
// NetworkPluginDir is the full path of the directory in which to search
|
||||
// for network plugins (and, for backwards-compat, CNI config files)
|
||||
NetworkPluginDir string
|
||||
// CNIConfDir is the full path of the directory in which to search for
|
||||
// CNI config files
|
||||
CNIConfDir string
|
||||
// CNIBinDir is the full path of the directory in which to search for
|
||||
// CNI plugin binaries
|
||||
CNIBinDir string
|
||||
|
||||
// rkt-specific options.
|
||||
|
||||
// rktPath is the path of rkt binary. Leave empty to use the first rkt in $PATH.
|
||||
RktPath string
|
||||
// rktApiEndpoint is the endpoint of the rkt API service to communicate with.
|
||||
RktAPIEndpoint string
|
||||
// rktStage1Image is the image to use as stage1. Local paths and
|
||||
// http/https URLs are supported.
|
||||
RktStage1Image string
|
||||
}
|
||||
|
||||
// NewContainerRuntimeOptions will create a new ContainerRuntimeOptions with
|
||||
// default values.
|
||||
func NewContainerRuntimeOptions() *ContainerRuntimeOptions {
|
||||
dockerEndpoint := ""
|
||||
if runtime.GOOS != "windows" {
|
||||
dockerEndpoint = "unix:///var/run/docker.sock"
|
||||
}
|
||||
|
||||
return &ContainerRuntimeOptions{
|
||||
DockerEndpoint: dockerEndpoint,
|
||||
DockershimRootDirectory: "/var/lib/dockershim",
|
||||
DockerExecHandlerName: "native",
|
||||
DockerDisableSharedPID: true,
|
||||
PodSandboxImage: defaultPodSandboxImage,
|
||||
ImagePullProgressDeadline: metav1.Duration{Duration: 1 * time.Minute},
|
||||
RktAPIEndpoint: defaultRktAPIServiceEndpoint,
|
||||
ExperimentalDockershim: false,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *ContainerRuntimeOptions) AddFlags(fs *pflag.FlagSet) {
|
||||
// Docker-specific settings.
|
||||
fs.BoolVar(&s.ExperimentalDockershim, "experimental-dockershim", s.ExperimentalDockershim, "Enable dockershim only mode. In this mode, kubelet will only start dockershim without any other functionalities. This flag only serves test purpose, please do not use it unless you are conscious of what you are doing. [default=false]")
|
||||
fs.MarkHidden("experimental-dockershim")
|
||||
fs.StringVar(&s.DockershimRootDirectory, "experimental-dockershim-root-directory", s.DockershimRootDirectory, "Path to the dockershim root directory.")
|
||||
fs.MarkHidden("experimental-dockershim-root-directory")
|
||||
fs.BoolVar(&s.DockerDisableSharedPID, "docker-disable-shared-pid", s.DockerDisableSharedPID, "The Container Runtime Interface (CRI) defaults to using a shared PID namespace for containers in a pod when running with Docker 1.13.1 or higher. Setting this flag reverts to the previous behavior of isolated PID namespaces. This ability will be removed in a future Kubernetes release.")
|
||||
fs.StringVar(&s.PodSandboxImage, "pod-infra-container-image", s.PodSandboxImage, "The image whose network/ipc namespaces containers in each pod will use.")
|
||||
fs.StringVar(&s.DockerEndpoint, "docker-endpoint", s.DockerEndpoint, "Use this for the docker endpoint to communicate with")
|
||||
// TODO(#40229): Remove the docker-exec-handler flag.
|
||||
fs.StringVar(&s.DockerExecHandlerName, "docker-exec-handler", s.DockerExecHandlerName, "Handler to use when executing a command in a container. Valid values are 'native' and 'nsenter'. Defaults to 'native'.")
|
||||
fs.MarkDeprecated("docker-exec-handler", "this flag will be removed and only the 'native' handler will be supported in the future.")
|
||||
fs.DurationVar(&s.ImagePullProgressDeadline.Duration, "image-pull-progress-deadline", s.ImagePullProgressDeadline.Duration, "If no pulling progress is made before this deadline, the image pulling will be cancelled.")
|
||||
|
||||
// Network plugin settings. Shared by both docker and rkt.
|
||||
fs.StringVar(&s.NetworkPluginName, "network-plugin", s.NetworkPluginName, "<Warning: Alpha feature> The name of the network plugin to be invoked for various events in kubelet/pod lifecycle")
|
||||
//TODO(#46410): Remove the network-plugin-dir flag.
|
||||
fs.StringVar(&s.NetworkPluginDir, "network-plugin-dir", s.NetworkPluginDir, "<Warning: Alpha feature> The full path of the directory in which to search for network plugins or CNI config")
|
||||
fs.MarkDeprecated("network-plugin-dir", "Use --cni-bin-dir instead. This flag will be removed in a future version.")
|
||||
fs.StringVar(&s.CNIConfDir, "cni-conf-dir", s.CNIConfDir, "<Warning: Alpha feature> The full path of the directory in which to search for CNI config files. Default: /etc/cni/net.d")
|
||||
fs.StringVar(&s.CNIBinDir, "cni-bin-dir", s.CNIBinDir, "<Warning: Alpha feature> The full path of the directory in which to search for CNI plugin binaries. Default: /opt/cni/bin")
|
||||
fs.Int32Var(&s.NetworkPluginMTU, "network-plugin-mtu", s.NetworkPluginMTU, "<Warning: Alpha feature> The MTU to be passed to the network plugin, to override the default. Set to 0 to use the default 1460 MTU.")
|
||||
|
||||
// Rkt-specific settings.
|
||||
fs.StringVar(&s.RktPath, "rkt-path", s.RktPath, "Path of rkt binary. Leave empty to use the first rkt in $PATH. Only used if --container-runtime='rkt'.")
|
||||
fs.StringVar(&s.RktAPIEndpoint, "rkt-api-endpoint", s.RktAPIEndpoint, "The endpoint of the rkt API service to communicate with. Only used if --container-runtime='rkt'.")
|
||||
fs.StringVar(&s.RktStage1Image, "rkt-stage1-image", s.RktStage1Image, "image to use as stage1. Local paths and http/https URLs are supported. If empty, the 'stage1.aci' in the same directory as '--rkt-path' will be used.")
|
||||
fs.MarkDeprecated("rkt-stage1-image", "Will be removed in a future version. The default stage1 image will be specified by the rkt configurations, see https://github.com/coreos/rkt/blob/master/Documentation/configuration.md for more details.")
|
||||
|
||||
}
|
||||
390
vendor/k8s.io/kubernetes/cmd/kubelet/app/options/options.go
generated
vendored
Normal file
390
vendor/k8s.io/kubernetes/cmd/kubelet/app/options/options.go
generated
vendored
Normal file
|
|
@ -0,0 +1,390 @@
|
|||
/*
|
||||
Copyright 2015 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 options contains all of the primary arguments for a kubelet.
|
||||
package options
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
_ "net/http/pprof"
|
||||
"strings"
|
||||
|
||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||
"k8s.io/apiserver/pkg/util/flag"
|
||||
utilflag "k8s.io/apiserver/pkg/util/flag"
|
||||
"k8s.io/kubernetes/pkg/apis/componentconfig"
|
||||
"k8s.io/kubernetes/pkg/features"
|
||||
"k8s.io/kubernetes/pkg/kubelet/apis/kubeletconfig"
|
||||
kubeletscheme "k8s.io/kubernetes/pkg/kubelet/apis/kubeletconfig/scheme"
|
||||
"k8s.io/kubernetes/pkg/kubelet/apis/kubeletconfig/v1alpha1"
|
||||
kubeletconfigvalidation "k8s.io/kubernetes/pkg/kubelet/apis/kubeletconfig/validation"
|
||||
utiltaints "k8s.io/kubernetes/pkg/util/taints"
|
||||
|
||||
"github.com/spf13/pflag"
|
||||
)
|
||||
|
||||
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)
|
||||
// KubeletConfiguration is intended to be shared between nodes
|
||||
// In general, please try to avoid adding flags or configuration fields,
|
||||
// we already have a confusingly large amount of them.
|
||||
type KubeletFlags struct {
|
||||
KubeConfig flag.StringFlag
|
||||
BootstrapKubeconfig string
|
||||
RotateCertificates bool
|
||||
|
||||
// RequireKubeConfig is deprecated! A valid KubeConfig is now required if --kubeconfig is provided.
|
||||
RequireKubeConfig bool
|
||||
|
||||
// Insert a probability of random errors during calls to the master.
|
||||
ChaosChance float64
|
||||
// Crash immediately, rather than eating panics.
|
||||
ReallyCrashForTesting bool
|
||||
|
||||
// TODO(mtaufen): It is increasingly looking like nobody actually uses the
|
||||
// Kubelet's runonce mode anymore, so it may be a candidate
|
||||
// for deprecation and removal.
|
||||
// If runOnce is true, the Kubelet will check the API server once for pods,
|
||||
// run those in addition to the pods specified by the local manifest, and exit.
|
||||
RunOnce bool
|
||||
|
||||
// HostnameOverride is the hostname used to identify the kubelet instead
|
||||
// of the actual hostname.
|
||||
HostnameOverride string
|
||||
// NodeIP is IP address of the node.
|
||||
// If set, kubelet will use this IP address for the node.
|
||||
NodeIP string
|
||||
|
||||
// This flag, if set, sets the unique id of the instance that an external provider (i.e. cloudprovider)
|
||||
// can use to identify a specific node
|
||||
ProviderID string
|
||||
|
||||
// Container-runtime-specific options.
|
||||
ContainerRuntimeOptions
|
||||
|
||||
// certDirectory is the directory where the TLS certs are located (by
|
||||
// default /var/run/kubernetes). If tlsCertFile and tlsPrivateKeyFile
|
||||
// are provided, this flag will be ignored.
|
||||
CertDirectory string
|
||||
|
||||
// cloudProvider is the provider for cloud services.
|
||||
// +optional
|
||||
CloudProvider string
|
||||
|
||||
// cloudConfigFile is the path to the cloud provider configuration file.
|
||||
// +optional
|
||||
CloudConfigFile string
|
||||
|
||||
// rootDirectory is the directory path to place kubelet files (volume
|
||||
// mounts,etc).
|
||||
RootDirectory string
|
||||
|
||||
// The Kubelet will use this directory for checkpointing downloaded configurations and tracking configuration health.
|
||||
// The Kubelet will create this directory if it does not already exist.
|
||||
// The path may be absolute or relative; relative paths are under the Kubelet's current working directory.
|
||||
// Providing this flag enables dynamic kubelet configuration.
|
||||
// To use this flag, the DynamicKubeletConfig feature gate must be enabled.
|
||||
DynamicConfigDir flag.StringFlag
|
||||
|
||||
// The Kubelet will look in this directory for an init configuration.
|
||||
// The path may be absolute or relative; relative paths are under the Kubelet's current working directory.
|
||||
// Omit this flag to use the combination of built-in default configuration values and flags.
|
||||
// To use this flag, the DynamicKubeletConfig feature gate must be enabled.
|
||||
InitConfigDir flag.StringFlag
|
||||
}
|
||||
|
||||
// NewKubeletFlags will create a new KubeletFlags with default values
|
||||
func NewKubeletFlags() *KubeletFlags {
|
||||
return &KubeletFlags{
|
||||
// TODO(#41161:v1.10.0): Remove the default kubeconfig path and --require-kubeconfig.
|
||||
RequireKubeConfig: false,
|
||||
KubeConfig: flag.NewStringFlag("/var/lib/kubelet/kubeconfig"),
|
||||
ContainerRuntimeOptions: *NewContainerRuntimeOptions(),
|
||||
CertDirectory: "/var/run/kubernetes",
|
||||
RootDirectory: v1alpha1.DefaultRootDir,
|
||||
// DEPRECATED: auto detecting cloud providers goes against the initiative
|
||||
// for out-of-tree cloud providers as we'll now depend on cAdvisor integrations
|
||||
// with cloud providers instead of in the core repo.
|
||||
// More details here: https://github.com/kubernetes/kubernetes/issues/50986
|
||||
CloudProvider: v1alpha1.AutoDetectCloudProvider,
|
||||
RotateCertificates: false,
|
||||
}
|
||||
}
|
||||
|
||||
func ValidateKubeletFlags(f *KubeletFlags) error {
|
||||
// ensure that nobody sets DynamicConfigDir if the dynamic config feature gate is turned off
|
||||
if f.DynamicConfigDir.Provided() && !utilfeature.DefaultFeatureGate.Enabled(features.DynamicKubeletConfig) {
|
||||
return fmt.Errorf("the DynamicKubeletConfig feature gate must be enabled in order to use the --dynamic-config-dir flag")
|
||||
}
|
||||
// ensure that nobody sets InitConfigDir if the dynamic config feature gate is turned off
|
||||
if f.InitConfigDir.Provided() && !utilfeature.DefaultFeatureGate.Enabled(features.KubeletConfigFile) {
|
||||
return fmt.Errorf("the KubeletConfigFile feature gate must be enabled in order to use the --init-config-dir flag")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewKubeletConfiguration will create a new KubeletConfiguration with default values
|
||||
func NewKubeletConfiguration() (*kubeletconfig.KubeletConfiguration, error) {
|
||||
scheme, _, err := kubeletscheme.NewSchemeAndCodecs()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
versioned := &v1alpha1.KubeletConfiguration{}
|
||||
scheme.Default(versioned)
|
||||
config := &kubeletconfig.KubeletConfiguration{}
|
||||
if err := scheme.Convert(versioned, config, nil); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return config, nil
|
||||
}
|
||||
|
||||
// KubeletServer encapsulates all of the parameters necessary for starting up
|
||||
// a kubelet. These can either be set via command line or directly.
|
||||
type KubeletServer struct {
|
||||
KubeletFlags
|
||||
kubeletconfig.KubeletConfiguration
|
||||
}
|
||||
|
||||
// NewKubeletServer will create a new KubeletServer with default values.
|
||||
func NewKubeletServer() (*KubeletServer, error) {
|
||||
config, err := NewKubeletConfiguration()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &KubeletServer{
|
||||
KubeletFlags: *NewKubeletFlags(),
|
||||
KubeletConfiguration: *config,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// validateKubeletServer validates configuration of KubeletServer and returns an error if the input configuration is invalid
|
||||
func ValidateKubeletServer(s *KubeletServer) error {
|
||||
// please add any KubeletConfiguration validation to the kubeletconfigvalidation.ValidateKubeletConfiguration function
|
||||
if err := kubeletconfigvalidation.ValidateKubeletConfiguration(&s.KubeletConfiguration); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := ValidateKubeletFlags(&s.KubeletFlags); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// AddFlags adds flags for a specific KubeletServer to the specified FlagSet
|
||||
func (s *KubeletServer) AddFlags(fs *pflag.FlagSet) {
|
||||
s.KubeletFlags.AddFlags(fs)
|
||||
AddKubeletConfigFlags(fs, &s.KubeletConfiguration)
|
||||
}
|
||||
|
||||
// AddFlags adds flags for a specific KubeletFlags to the specified FlagSet
|
||||
func (f *KubeletFlags) AddFlags(fs *pflag.FlagSet) {
|
||||
f.ContainerRuntimeOptions.AddFlags(fs)
|
||||
|
||||
fs.Var(&f.KubeConfig, "kubeconfig", "Path to a kubeconfig file, specifying how to connect to the API server.")
|
||||
// TODO(#41161:v1.10.0): Remove the default kubeconfig path and --require-kubeconfig.
|
||||
fs.BoolVar(&f.RequireKubeConfig, "require-kubeconfig", f.RequireKubeConfig, "This flag is no longer necessary. It has been deprecated and will be removed in a future version.")
|
||||
fs.MarkDeprecated("require-kubeconfig", "You no longer need to use --require-kubeconfig. This will be removed in a future version. Providing --kubeconfig enables API server mode, omitting --kubeconfig enables standalone mode unless --require-kubeconfig=true is also set. In the latter case, the legacy default kubeconfig path will be used until --require-kubeconfig is removed.")
|
||||
|
||||
fs.MarkDeprecated("experimental-bootstrap-kubeconfig", "Use --bootstrap-kubeconfig")
|
||||
fs.StringVar(&f.BootstrapKubeconfig, "experimental-bootstrap-kubeconfig", f.BootstrapKubeconfig, "deprecated: use --bootstrap-kubeconfig")
|
||||
fs.StringVar(&f.BootstrapKubeconfig, "bootstrap-kubeconfig", f.BootstrapKubeconfig, "Path to a kubeconfig file that will be used to get client certificate for kubelet. "+
|
||||
"If the file specified by --kubeconfig does not exist, the bootstrap kubeconfig is used to request a client certificate from the API server. "+
|
||||
"On success, a kubeconfig file referencing the generated client certificate and key is written to the path specified by --kubeconfig. "+
|
||||
"The client certificate and key file will be stored in the directory pointed by --cert-dir.")
|
||||
fs.BoolVar(&f.RotateCertificates, "rotate-certificates", f.RotateCertificates, "<Warning: Beta feature> Auto rotate the kubelet client certificates by requesting new certificates from the kube-apiserver when the certificate expiration approaches.")
|
||||
|
||||
fs.BoolVar(&f.ReallyCrashForTesting, "really-crash-for-testing", f.ReallyCrashForTesting, "If true, when panics occur crash. Intended for testing.")
|
||||
fs.Float64Var(&f.ChaosChance, "chaos-chance", f.ChaosChance, "If > 0.0, introduce random client errors and latency. Intended for testing.")
|
||||
|
||||
fs.BoolVar(&f.RunOnce, "runonce", f.RunOnce, "If true, exit after spawning pods from local manifests or remote urls. Exclusive with --enable-server")
|
||||
|
||||
fs.StringVar(&f.HostnameOverride, "hostname-override", f.HostnameOverride, "If non-empty, will use this string as identification instead of the actual hostname.")
|
||||
|
||||
fs.StringVar(&f.NodeIP, "node-ip", f.NodeIP, "IP address of the node. If set, kubelet will use this IP address for the node")
|
||||
|
||||
fs.StringVar(&f.ProviderID, "provider-id", f.ProviderID, "Unique identifier for identifying the node in a machine database, i.e cloudprovider")
|
||||
|
||||
fs.StringVar(&f.CertDirectory, "cert-dir", f.CertDirectory, "The directory where the TLS certs are located. "+
|
||||
"If --tls-cert-file and --tls-private-key-file are provided, this flag will be ignored.")
|
||||
|
||||
fs.StringVar(&f.CloudProvider, "cloud-provider", f.CloudProvider, "The provider for cloud services. By default, kubelet will attempt to auto-detect the cloud provider (deprecated). Specify empty string for running with no cloud provider, this will be the default in upcoming releases.")
|
||||
fs.StringVar(&f.CloudConfigFile, "cloud-config", f.CloudConfigFile, "The path to the cloud provider configuration file. Empty string for no configuration file.")
|
||||
|
||||
fs.StringVar(&f.RootDirectory, "root-dir", f.RootDirectory, "Directory path for managing kubelet files (volume mounts,etc).")
|
||||
|
||||
fs.Var(&f.DynamicConfigDir, "dynamic-config-dir", "The Kubelet will use this directory for checkpointing downloaded configurations and tracking configuration health. The Kubelet will create this directory if it does not already exist. The path may be absolute or relative; relative paths start at the Kubelet's current working directory. Providing this flag enables dynamic Kubelet configuration. Presently, you must also enable the DynamicKubeletConfig feature gate to pass this flag.")
|
||||
fs.Var(&f.InitConfigDir, "init-config-dir", "The Kubelet will look in this directory for the init configuration. The path may be absolute or relative; relative paths start at the Kubelet's current working directory. Omit this argument to use the built-in default configuration values. Presently, you must also enable the DynamicKubeletConfig feature gate to pass this flag.")
|
||||
}
|
||||
|
||||
// AddKubeletConfigFlags adds flags for a specific kubeletconfig.KubeletConfiguration to the specified FlagSet
|
||||
func AddKubeletConfigFlags(fs *pflag.FlagSet, c *kubeletconfig.KubeletConfiguration) {
|
||||
fs.BoolVar(&c.FailSwapOn, "fail-swap-on", true, "Makes the Kubelet fail to start if swap is enabled on the node. ")
|
||||
fs.BoolVar(&c.FailSwapOn, "experimental-fail-swap-on", true, "DEPRECATED: please use --fail-swap-on instead.")
|
||||
fs.MarkDeprecated("experimental-fail-swap-on", "This flag is deprecated and will be removed in future releases. please use --fail-swap-on instead.")
|
||||
|
||||
fs.StringVar(&c.PodManifestPath, "pod-manifest-path", c.PodManifestPath, "Path to to the directory containing pod manifest files to run, or the path to a single pod manifest file. Files starting with dots will be ignored.")
|
||||
fs.DurationVar(&c.SyncFrequency.Duration, "sync-frequency", c.SyncFrequency.Duration, "Max period between synchronizing running containers and config")
|
||||
fs.DurationVar(&c.FileCheckFrequency.Duration, "file-check-frequency", c.FileCheckFrequency.Duration, "Duration between checking config files for new data")
|
||||
fs.DurationVar(&c.HTTPCheckFrequency.Duration, "http-check-frequency", c.HTTPCheckFrequency.Duration, "Duration between checking http for new data")
|
||||
fs.StringVar(&c.ManifestURL, "manifest-url", c.ManifestURL, "URL for accessing the container manifest")
|
||||
fs.StringVar(&c.ManifestURLHeader, "manifest-url-header", c.ManifestURLHeader, "HTTP header to use when accessing the manifest URL, with the key separated from the value with a ':', as in 'key:value'")
|
||||
fs.BoolVar(&c.EnableServer, "enable-server", c.EnableServer, "Enable the Kubelet's server")
|
||||
fs.Var(componentconfig.IPVar{Val: &c.Address}, "address", "The IP address for the Kubelet to serve on (set to 0.0.0.0 for all interfaces)")
|
||||
fs.Int32Var(&c.Port, "port", c.Port, "The port for the Kubelet to serve on.")
|
||||
fs.Int32Var(&c.ReadOnlyPort, "read-only-port", c.ReadOnlyPort, "The read-only port for the Kubelet to serve on with no authentication/authorization (set to 0 to disable)")
|
||||
|
||||
// Authentication
|
||||
fs.BoolVar(&c.Authentication.Anonymous.Enabled, "anonymous-auth", c.Authentication.Anonymous.Enabled, ""+
|
||||
"Enables anonymous requests to the Kubelet server. Requests that are not rejected by another "+
|
||||
"authentication method are treated as anonymous requests. Anonymous requests have a username "+
|
||||
"of system:anonymous, and a group name of system:unauthenticated.")
|
||||
fs.BoolVar(&c.Authentication.Webhook.Enabled, "authentication-token-webhook", c.Authentication.Webhook.Enabled, ""+
|
||||
"Use the TokenReview API to determine authentication for bearer tokens.")
|
||||
fs.DurationVar(&c.Authentication.Webhook.CacheTTL.Duration, "authentication-token-webhook-cache-ttl", c.Authentication.Webhook.CacheTTL.Duration, ""+
|
||||
"The duration to cache responses from the webhook token authenticator.")
|
||||
fs.StringVar(&c.Authentication.X509.ClientCAFile, "client-ca-file", c.Authentication.X509.ClientCAFile, ""+
|
||||
"If set, any request presenting a client certificate signed by one of the authorities in the client-ca-file "+
|
||||
"is authenticated with an identity corresponding to the CommonName of the client certificate.")
|
||||
|
||||
// Authorization
|
||||
fs.StringVar((*string)(&c.Authorization.Mode), "authorization-mode", string(c.Authorization.Mode), ""+
|
||||
"Authorization mode for Kubelet server. Valid options are AlwaysAllow or Webhook. "+
|
||||
"Webhook mode uses the SubjectAccessReview API to determine authorization.")
|
||||
fs.DurationVar(&c.Authorization.Webhook.CacheAuthorizedTTL.Duration, "authorization-webhook-cache-authorized-ttl", c.Authorization.Webhook.CacheAuthorizedTTL.Duration, ""+
|
||||
"The duration to cache 'authorized' responses from the webhook authorizer.")
|
||||
fs.DurationVar(&c.Authorization.Webhook.CacheUnauthorizedTTL.Duration, "authorization-webhook-cache-unauthorized-ttl", c.Authorization.Webhook.CacheUnauthorizedTTL.Duration, ""+
|
||||
"The duration to cache 'unauthorized' responses from the webhook authorizer.")
|
||||
|
||||
fs.StringVar(&c.TLSCertFile, "tls-cert-file", c.TLSCertFile, ""+
|
||||
"File containing x509 Certificate used for serving HTTPS (with intermediate certs, if any, concatenated after server cert). "+
|
||||
"If --tls-cert-file and --tls-private-key-file are not provided, a self-signed certificate and key "+
|
||||
"are generated for the public address and saved to the directory passed to --cert-dir.")
|
||||
fs.StringVar(&c.TLSPrivateKeyFile, "tls-private-key-file", c.TLSPrivateKeyFile, "File containing x509 private key matching --tls-cert-file.")
|
||||
|
||||
fs.StringVar(&c.SeccompProfileRoot, "seccomp-profile-root", c.SeccompProfileRoot, "Directory path for seccomp profiles.")
|
||||
fs.BoolVar(&c.AllowPrivileged, "allow-privileged", c.AllowPrivileged, "If true, allow containers to request privileged mode.")
|
||||
fs.StringSliceVar(&c.HostNetworkSources, "host-network-sources", c.HostNetworkSources, "Comma-separated list of sources from which the Kubelet allows pods to use of host network.")
|
||||
fs.StringSliceVar(&c.HostPIDSources, "host-pid-sources", c.HostPIDSources, "Comma-separated list of sources from which the Kubelet allows pods to use the host pid namespace.")
|
||||
fs.StringSliceVar(&c.HostIPCSources, "host-ipc-sources", c.HostIPCSources, "Comma-separated list of sources from which the Kubelet allows pods to use the host ipc namespace.")
|
||||
fs.Int32Var(&c.RegistryPullQPS, "registry-qps", c.RegistryPullQPS, "If > 0, limit registry pull QPS to this value. If 0, unlimited.")
|
||||
fs.Int32Var(&c.RegistryBurst, "registry-burst", c.RegistryBurst, "Maximum size of a bursty pulls, temporarily allows pulls to burst to this number, while still not exceeding registry-qps. Only used if --registry-qps > 0")
|
||||
fs.Int32Var(&c.EventRecordQPS, "event-qps", c.EventRecordQPS, "If > 0, limit event creations per second to this value. If 0, unlimited.")
|
||||
fs.Int32Var(&c.EventBurst, "event-burst", c.EventBurst, "Maximum size of a bursty event records, temporarily allows event records to burst to this number, while still not exceeding event-qps. Only used if --event-qps > 0")
|
||||
|
||||
fs.BoolVar(&c.EnableDebuggingHandlers, "enable-debugging-handlers", c.EnableDebuggingHandlers, "Enables server endpoints for log collection and local running of containers and commands")
|
||||
fs.BoolVar(&c.EnableContentionProfiling, "contention-profiling", false, "Enable lock contention profiling, if profiling is enabled")
|
||||
fs.DurationVar(&c.MinimumGCAge.Duration, "minimum-container-ttl-duration", c.MinimumGCAge.Duration, "Minimum age for a finished container before it is garbage collected. Examples: '300ms', '10s' or '2h45m'")
|
||||
fs.MarkDeprecated("minimum-container-ttl-duration", "Use --eviction-hard or --eviction-soft instead. Will be removed in a future version.")
|
||||
fs.Int32Var(&c.MaxPerPodContainerCount, "maximum-dead-containers-per-container", c.MaxPerPodContainerCount, "Maximum number of old instances to retain per container. Each container takes up some disk space.")
|
||||
fs.MarkDeprecated("maximum-dead-containers-per-container", "Use --eviction-hard or --eviction-soft instead. Will be removed in a future version.")
|
||||
fs.Int32Var(&c.MaxContainerCount, "maximum-dead-containers", c.MaxContainerCount, "Maximum number of old instances of containers to retain globally. Each container takes up some disk space. To disable, set to a negative number.")
|
||||
fs.MarkDeprecated("maximum-dead-containers", "Use --eviction-hard or --eviction-soft instead. Will be removed in a future version.")
|
||||
fs.Int32Var(&c.CAdvisorPort, "cadvisor-port", c.CAdvisorPort, "The port of the localhost cAdvisor endpoint (set to 0 to disable)")
|
||||
fs.Int32Var(&c.HealthzPort, "healthz-port", c.HealthzPort, "The port of the localhost healthz endpoint (set to 0 to disable)")
|
||||
fs.Var(componentconfig.IPVar{Val: &c.HealthzBindAddress}, "healthz-bind-address", "The IP address for the healthz server to serve on. (set to 0.0.0.0 for all interfaces)")
|
||||
fs.Int32Var(&c.OOMScoreAdj, "oom-score-adj", c.OOMScoreAdj, "The oom-score-adj value for kubelet process. Values must be within the range [-1000, 1000]")
|
||||
fs.BoolVar(&c.RegisterNode, "register-node", c.RegisterNode, "Register the node with the apiserver. If --kubeconfig is not provided, this flag is irrelevant, as the Kubelet won't have an apiserver to register with. Default=true.")
|
||||
fs.StringVar(&c.ClusterDomain, "cluster-domain", c.ClusterDomain, "Domain for this cluster. If set, kubelet will configure all containers to search this domain in addition to the host's search domains")
|
||||
fs.StringVar(&c.MasterServiceNamespace, "master-service-namespace", c.MasterServiceNamespace, "The namespace from which the kubernetes master services should be injected into pods")
|
||||
fs.MarkDeprecated("master-service-namespace", "This flag will be removed in a future version.")
|
||||
fs.StringSliceVar(&c.ClusterDNS, "cluster-dns", c.ClusterDNS, "Comma-separated list of DNS server IP address. This value is used for containers DNS server in case of Pods with \"dnsPolicy=ClusterFirst\". Note: all DNS servers appearing in the list MUST serve the same set of records otherwise name resolution within the cluster may not work correctly. There is no guarantee as to which DNS server may be contacted for name resolution.")
|
||||
fs.DurationVar(&c.StreamingConnectionIdleTimeout.Duration, "streaming-connection-idle-timeout", c.StreamingConnectionIdleTimeout.Duration, "Maximum time a streaming connection can be idle before the connection is automatically closed. 0 indicates no timeout. Example: '5m'")
|
||||
fs.DurationVar(&c.NodeStatusUpdateFrequency.Duration, "node-status-update-frequency", c.NodeStatusUpdateFrequency.Duration, "Specifies how often kubelet posts node status to master. Note: be cautious when changing the constant, it must work with nodeMonitorGracePeriod in nodecontroller.")
|
||||
c.NodeLabels = make(map[string]string)
|
||||
bindableNodeLabels := utilflag.ConfigurationMap(c.NodeLabels)
|
||||
fs.Var(&bindableNodeLabels, "node-labels", "<Warning: Alpha feature> Labels to add when registering the node in the cluster. Labels must be key=value pairs separated by ','.")
|
||||
fs.DurationVar(&c.ImageMinimumGCAge.Duration, "minimum-image-ttl-duration", c.ImageMinimumGCAge.Duration, "Minimum age for an unused image before it is garbage collected. Examples: '300ms', '10s' or '2h45m'.")
|
||||
fs.Int32Var(&c.ImageGCHighThresholdPercent, "image-gc-high-threshold", c.ImageGCHighThresholdPercent, "The percent of disk usage after which image garbage collection is always run.")
|
||||
fs.Int32Var(&c.ImageGCLowThresholdPercent, "image-gc-low-threshold", c.ImageGCLowThresholdPercent, "The percent of disk usage before which image garbage collection is never run. Lowest disk usage to garbage collect to.")
|
||||
fs.DurationVar(&c.VolumeStatsAggPeriod.Duration, "volume-stats-agg-period", c.VolumeStatsAggPeriod.Duration, "Specifies interval for kubelet to calculate and cache the volume disk usage for all pods and volumes. To disable volume calculations, set to 0.")
|
||||
fs.StringVar(&c.VolumePluginDir, "volume-plugin-dir", c.VolumePluginDir, "<Warning: Alpha feature> The full path of the directory in which to search for additional third party volume plugins")
|
||||
fs.StringVar(&c.FeatureGates, "feature-gates", c.FeatureGates, "A set of key=value pairs that describe feature gates for alpha/experimental features. "+
|
||||
"Options are:\n"+strings.Join(utilfeature.DefaultFeatureGate.KnownFeatures(), "\n"))
|
||||
|
||||
fs.StringVar(&c.KubeletCgroups, "kubelet-cgroups", c.KubeletCgroups, "Optional absolute name of cgroups to create and run the Kubelet in.")
|
||||
fs.StringVar(&c.SystemCgroups, "system-cgroups", c.SystemCgroups, "Optional absolute name of cgroups in which to place all non-kernel processes that are not already inside a cgroup under `/`. Empty for no container. Rolling back the flag requires a reboot.")
|
||||
|
||||
fs.BoolVar(&c.CgroupsPerQOS, "cgroups-per-qos", c.CgroupsPerQOS, "Enable creation of QoS cgroup hierarchy, if true top level QoS and pod cgroups are created.")
|
||||
fs.StringVar(&c.CgroupDriver, "cgroup-driver", c.CgroupDriver, "Driver that the kubelet uses to manipulate cgroups on the host. Possible values: 'cgroupfs', 'systemd'")
|
||||
fs.StringVar(&c.CgroupRoot, "cgroup-root", c.CgroupRoot, "Optional root cgroup to use for pods. This is handled by the container runtime on a best effort basis. Default: '', which means use the container runtime default.")
|
||||
fs.StringVar(&c.CPUManagerPolicy, "cpu-manager-policy", c.CPUManagerPolicy, "<Warning: Alpha feature> CPU Manager policy to use. Possible values: 'none', 'static'. Default: 'none'")
|
||||
fs.DurationVar(&c.CPUManagerReconcilePeriod.Duration, "cpu-manager-reconcile-period", c.CPUManagerReconcilePeriod.Duration, "<Warning: Alpha feature> CPU Manager reconciliation period. Examples: '10s', or '1m'. If not supplied, defaults to `NodeStatusUpdateFrequency`")
|
||||
fs.StringVar(&c.ContainerRuntime, "container-runtime", c.ContainerRuntime, "The container runtime to use. Possible values: 'docker', 'rkt'.")
|
||||
fs.DurationVar(&c.RuntimeRequestTimeout.Duration, "runtime-request-timeout", c.RuntimeRequestTimeout.Duration, "Timeout of all runtime requests except long running request - pull, logs, exec and attach. When timeout exceeded, kubelet will cancel the request, throw out an error and retry later.")
|
||||
fs.StringVar(&c.LockFilePath, "lock-file", c.LockFilePath, "<Warning: Alpha feature> The path to file for kubelet to use as a lock file.")
|
||||
fs.BoolVar(&c.ExitOnLockContention, "exit-on-lock-contention", c.ExitOnLockContention, "Whether kubelet should exit upon lock-file contention.")
|
||||
fs.StringVar(&c.ExperimentalMounterPath, "experimental-mounter-path", c.ExperimentalMounterPath, "[Experimental] Path of mounter binary. Leave empty to use the default mount.")
|
||||
fs.StringVar(&c.HairpinMode, "hairpin-mode", c.HairpinMode, "How should the kubelet setup hairpin NAT. This allows endpoints of a Service to loadbalance back to themselves if they should try to access their own Service. Valid values are \"promiscuous-bridge\", \"hairpin-veth\" and \"none\".")
|
||||
fs.Int32Var(&c.MaxPods, "max-pods", c.MaxPods, "Number of Pods that can run on this Kubelet.")
|
||||
fs.StringVar(&c.NonMasqueradeCIDR, "non-masquerade-cidr", c.NonMasqueradeCIDR, "Traffic to IPs outside this range will use IP masquerade. Set to '0.0.0.0/0' to never masquerade.")
|
||||
fs.MarkDeprecated("non-masquerade-cidr", "will be removed in a future version")
|
||||
fs.StringVar(&c.PodCIDR, "pod-cidr", "", "The CIDR to use for pod IP addresses, only used in standalone mode. In cluster mode, this is obtained from the master.")
|
||||
fs.StringVar(&c.ResolverConfig, "resolv-conf", c.ResolverConfig, "Resolver configuration file used as the basis for the container DNS resolution configuration.")
|
||||
fs.BoolVar(&c.CPUCFSQuota, "cpu-cfs-quota", c.CPUCFSQuota, "Enable CPU CFS quota enforcement for containers that specify CPU limits")
|
||||
fs.BoolVar(&c.EnableControllerAttachDetach, "enable-controller-attach-detach", c.EnableControllerAttachDetach, "Enables the Attach/Detach controller to manage attachment/detachment of volumes scheduled to this node, and disables kubelet from executing any attach/detach operations")
|
||||
fs.BoolVar(&c.MakeIPTablesUtilChains, "make-iptables-util-chains", c.MakeIPTablesUtilChains, "If true, kubelet will ensure iptables utility rules are present on host.")
|
||||
fs.Int32Var(&c.IPTablesMasqueradeBit, "iptables-masquerade-bit", c.IPTablesMasqueradeBit, "The bit of the fwmark space to mark packets for SNAT. Must be within the range [0, 31]. Please match this parameter with corresponding parameter in kube-proxy.")
|
||||
fs.Int32Var(&c.IPTablesDropBit, "iptables-drop-bit", c.IPTablesDropBit, "The bit of the fwmark space to mark packets for dropping. Must be within the range [0, 31].")
|
||||
fs.StringSliceVar(&c.AllowedUnsafeSysctls, "experimental-allowed-unsafe-sysctls", c.AllowedUnsafeSysctls, "Comma-separated whitelist of unsafe sysctls or unsafe sysctl patterns (ending in *). Use these at your own risk.")
|
||||
|
||||
// Flags intended for testing, not recommended used in production environments.
|
||||
fs.BoolVar(&c.Containerized, "containerized", c.Containerized, "Experimental support for running kubelet in a container. Intended for testing.")
|
||||
fs.Int64Var(&c.MaxOpenFiles, "max-open-files", c.MaxOpenFiles, "Number of files that can be opened by Kubelet process.")
|
||||
fs.BoolVar(&c.RegisterSchedulable, "register-schedulable", c.RegisterSchedulable, "Register the node as schedulable. Won't have any effect if register-node is false.")
|
||||
fs.MarkDeprecated("register-schedulable", "will be removed in a future version")
|
||||
fs.Var(utiltaints.NewTaintsVar(&c.RegisterWithTaints), "register-with-taints", "Register the node with the given list of taints (comma separated \"<key>=<value>:<effect>\"). No-op if register-node is false.")
|
||||
fs.StringVar(&c.ContentType, "kube-api-content-type", c.ContentType, "Content type of requests sent to apiserver.")
|
||||
fs.Int32Var(&c.KubeAPIQPS, "kube-api-qps", c.KubeAPIQPS, "QPS to use while talking with kubernetes apiserver")
|
||||
fs.Int32Var(&c.KubeAPIBurst, "kube-api-burst", c.KubeAPIBurst, "Burst to use while talking with kubernetes apiserver")
|
||||
fs.BoolVar(&c.SerializeImagePulls, "serialize-image-pulls", c.SerializeImagePulls, "Pull images one at a time. We recommend *not* changing the default value on nodes that run docker daemon with version < 1.9 or an Aufs storage backend. Issue #10959 has more details.")
|
||||
|
||||
fs.BoolVar(&c.EnableCustomMetrics, "enable-custom-metrics", c.EnableCustomMetrics, "Support for gathering custom metrics.")
|
||||
fs.StringVar(&c.RuntimeCgroups, "runtime-cgroups", c.RuntimeCgroups, "Optional absolute name of cgroups to create and run the runtime in.")
|
||||
fs.StringVar(&c.EvictionHard, "eviction-hard", c.EvictionHard, "A set of eviction thresholds (e.g. memory.available<1Gi) that if met would trigger a pod eviction.")
|
||||
fs.StringVar(&c.EvictionSoft, "eviction-soft", c.EvictionSoft, "A set of eviction thresholds (e.g. memory.available<1.5Gi) that if met over a corresponding grace period would trigger a pod eviction.")
|
||||
fs.StringVar(&c.EvictionSoftGracePeriod, "eviction-soft-grace-period", c.EvictionSoftGracePeriod, "A set of eviction grace periods (e.g. memory.available=1m30s) that correspond to how long a soft eviction threshold must hold before triggering a pod eviction.")
|
||||
fs.DurationVar(&c.EvictionPressureTransitionPeriod.Duration, "eviction-pressure-transition-period", c.EvictionPressureTransitionPeriod.Duration, "Duration for which the kubelet has to wait before transitioning out of an eviction pressure condition.")
|
||||
fs.Int32Var(&c.EvictionMaxPodGracePeriod, "eviction-max-pod-grace-period", c.EvictionMaxPodGracePeriod, "Maximum allowed grace period (in seconds) to use when terminating pods in response to a soft eviction threshold being met. If negative, defer to pod specified value.")
|
||||
fs.StringVar(&c.EvictionMinimumReclaim, "eviction-minimum-reclaim", c.EvictionMinimumReclaim, "A set of minimum reclaims (e.g. imagefs.available=2Gi) that describes the minimum amount of resource the kubelet will reclaim when performing a pod eviction if that resource is under pressure.")
|
||||
fs.BoolVar(&c.ExperimentalKernelMemcgNotification, "experimental-kernel-memcg-notification", c.ExperimentalKernelMemcgNotification, "If enabled, the kubelet will integrate with the kernel memcg notification to determine if memory eviction thresholds are crossed rather than polling.")
|
||||
fs.Int32Var(&c.PodsPerCore, "pods-per-core", c.PodsPerCore, "Number of Pods per core that can run on this Kubelet. The total number of Pods on this Kubelet cannot exceed max-pods, so max-pods will be used if this calculation results in a larger number of Pods allowed on the Kubelet. A value of 0 disables this limit.")
|
||||
fs.BoolVar(&c.ProtectKernelDefaults, "protect-kernel-defaults", c.ProtectKernelDefaults, "Default kubelet behaviour for kernel tuning. If set, kubelet errors if any of kernel tunables is different than kubelet defaults.")
|
||||
fs.BoolVar(&c.KeepTerminatedPodVolumes, "keep-terminated-pod-volumes", c.KeepTerminatedPodVolumes, "Keep terminated pod volumes mounted to the node after the pod terminates. Can be useful for debugging volume related issues.")
|
||||
fs.MarkDeprecated("keep-terminated-pod-volumes", "will be removed in a future version")
|
||||
|
||||
// CRI flags.
|
||||
fs.StringVar(&c.RemoteRuntimeEndpoint, "container-runtime-endpoint", c.RemoteRuntimeEndpoint, "[Experimental] The endpoint of remote runtime service. Currently unix socket is supported on Linux, and tcp is supported on windows. Examples:'unix:///var/run/dockershim.sock', 'tcp://localhost:3735'")
|
||||
fs.StringVar(&c.RemoteImageEndpoint, "image-service-endpoint", c.RemoteImageEndpoint, "[Experimental] The endpoint of remote image service. If not specified, it will be the same with container-runtime-endpoint by default. Currently unix socket is supported on Linux, and tcp is supported on windows. Examples:'unix:///var/run/dockershim.sock', 'tcp://localhost:3735'")
|
||||
|
||||
fs.BoolVar(&c.ExperimentalCheckNodeCapabilitiesBeforeMount, "experimental-check-node-capabilities-before-mount", c.ExperimentalCheckNodeCapabilitiesBeforeMount, "[Experimental] if set true, the kubelet will check the underlying node for required componenets (binaries, etc.) before performing the mount")
|
||||
|
||||
// Node Allocatable Flags
|
||||
fs.Var(&c.SystemReserved, "system-reserved", "A set of ResourceName=ResourceQuantity (e.g. cpu=200m,memory=500Mi) pairs that describe resources reserved for non-kubernetes components. Currently only cpu and memory are supported. See http://kubernetes.io/docs/user-guide/compute-resources for more detail. [default=none]")
|
||||
fs.Var(&c.KubeReserved, "kube-reserved", "A set of ResourceName=ResourceQuantity (e.g. cpu=200m,memory=500Mi, storage=1Gi) pairs that describe resources reserved for kubernetes system components. Currently cpu, memory and local storage for root file system are supported. See http://kubernetes.io/docs/user-guide/compute-resources for more detail. [default=none]")
|
||||
fs.StringSliceVar(&c.EnforceNodeAllocatable, "enforce-node-allocatable", c.EnforceNodeAllocatable, "A comma separated list of levels of node allocatable enforcement to be enforced by kubelet. Acceptible options are 'pods', 'system-reserved' & 'kube-reserved'. If the latter two options are specified, '--system-reserved-cgroup' & '--kube-reserved-cgroup' must also be set respectively. See https://git.k8s.io/community/contributors/design-proposals/node-allocatable.md for more details.")
|
||||
fs.StringVar(&c.SystemReservedCgroup, "system-reserved-cgroup", c.SystemReservedCgroup, "Absolute name of the top level cgroup that is used to manage non-kubernetes components for which compute resources were reserved via '--system-reserved' flag. Ex. '/system-reserved'. [default='']")
|
||||
fs.StringVar(&c.KubeReservedCgroup, "kube-reserved-cgroup", c.KubeReservedCgroup, "Absolute name of the top level cgroup that is used to manage kubernetes components for which compute resources were reserved via '--kube-reserved' flag. Ex. '/kube-reserved'. [default='']")
|
||||
fs.BoolVar(&c.ExperimentalNodeAllocatableIgnoreEvictionThreshold, "experimental-allocatable-ignore-eviction", c.ExperimentalNodeAllocatableIgnoreEvictionThreshold, "When set to 'true', Hard Eviction Thresholds will be ignored while calculating Node Allocatable. See https://git.k8s.io/community/contributors/design-proposals/node-allocatable.md for more details. [default=false]")
|
||||
|
||||
fs.Var(&c.ExperimentalQOSReserved, "experimental-qos-reserved", "A set of ResourceName=Percentage (e.g. memory=50%) pairs that describe how pod resource requests are reserved at the QoS level. Currently only memory is supported. [default=none]")
|
||||
}
|
||||
127
vendor/k8s.io/kubernetes/cmd/kubelet/app/plugins.go
generated
vendored
Normal file
127
vendor/k8s.io/kubernetes/cmd/kubelet/app/plugins.go
generated
vendored
Normal file
|
|
@ -0,0 +1,127 @@
|
|||
/*
|
||||
Copyright 2014 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 app
|
||||
|
||||
// This file exists to force the desired plugin implementations to be linked.
|
||||
import (
|
||||
// Credential providers
|
||||
_ "k8s.io/kubernetes/pkg/credentialprovider/aws"
|
||||
_ "k8s.io/kubernetes/pkg/credentialprovider/azure"
|
||||
_ "k8s.io/kubernetes/pkg/credentialprovider/gcp"
|
||||
_ "k8s.io/kubernetes/pkg/credentialprovider/rancher"
|
||||
// Network plugins
|
||||
"k8s.io/kubernetes/pkg/kubelet/network"
|
||||
"k8s.io/kubernetes/pkg/kubelet/network/cni"
|
||||
"k8s.io/kubernetes/pkg/kubelet/network/kubenet"
|
||||
// Volume plugins
|
||||
"k8s.io/kubernetes/pkg/volume"
|
||||
"k8s.io/kubernetes/pkg/volume/aws_ebs"
|
||||
"k8s.io/kubernetes/pkg/volume/azure_dd"
|
||||
"k8s.io/kubernetes/pkg/volume/azure_file"
|
||||
"k8s.io/kubernetes/pkg/volume/cephfs"
|
||||
"k8s.io/kubernetes/pkg/volume/cinder"
|
||||
"k8s.io/kubernetes/pkg/volume/configmap"
|
||||
"k8s.io/kubernetes/pkg/volume/downwardapi"
|
||||
"k8s.io/kubernetes/pkg/volume/empty_dir"
|
||||
"k8s.io/kubernetes/pkg/volume/fc"
|
||||
"k8s.io/kubernetes/pkg/volume/flexvolume"
|
||||
"k8s.io/kubernetes/pkg/volume/flocker"
|
||||
"k8s.io/kubernetes/pkg/volume/gce_pd"
|
||||
"k8s.io/kubernetes/pkg/volume/git_repo"
|
||||
"k8s.io/kubernetes/pkg/volume/glusterfs"
|
||||
"k8s.io/kubernetes/pkg/volume/host_path"
|
||||
"k8s.io/kubernetes/pkg/volume/iscsi"
|
||||
"k8s.io/kubernetes/pkg/volume/local"
|
||||
"k8s.io/kubernetes/pkg/volume/nfs"
|
||||
"k8s.io/kubernetes/pkg/volume/photon_pd"
|
||||
"k8s.io/kubernetes/pkg/volume/portworx"
|
||||
"k8s.io/kubernetes/pkg/volume/projected"
|
||||
"k8s.io/kubernetes/pkg/volume/quobyte"
|
||||
"k8s.io/kubernetes/pkg/volume/rbd"
|
||||
"k8s.io/kubernetes/pkg/volume/scaleio"
|
||||
"k8s.io/kubernetes/pkg/volume/secret"
|
||||
"k8s.io/kubernetes/pkg/volume/storageos"
|
||||
"k8s.io/kubernetes/pkg/volume/vsphere_volume"
|
||||
// Cloud providers
|
||||
_ "k8s.io/kubernetes/pkg/cloudprovider/providers"
|
||||
)
|
||||
|
||||
// ProbeVolumePlugins collects all volume plugins into an easy to use list.
|
||||
func ProbeVolumePlugins() []volume.VolumePlugin {
|
||||
allPlugins := []volume.VolumePlugin{}
|
||||
|
||||
// The list of plugins to probe is decided by the kubelet binary, not
|
||||
// by dynamic linking or other "magic". Plugins will be analyzed and
|
||||
// initialized later.
|
||||
//
|
||||
// Kubelet does not currently need to configure volume plugins.
|
||||
// If/when it does, see kube-controller-manager/app/plugins.go for example of using volume.VolumeConfig
|
||||
allPlugins = append(allPlugins, aws_ebs.ProbeVolumePlugins()...)
|
||||
allPlugins = append(allPlugins, empty_dir.ProbeVolumePlugins()...)
|
||||
allPlugins = append(allPlugins, gce_pd.ProbeVolumePlugins()...)
|
||||
allPlugins = append(allPlugins, git_repo.ProbeVolumePlugins()...)
|
||||
allPlugins = append(allPlugins, host_path.ProbeVolumePlugins(volume.VolumeConfig{})...)
|
||||
allPlugins = append(allPlugins, nfs.ProbeVolumePlugins(volume.VolumeConfig{})...)
|
||||
allPlugins = append(allPlugins, secret.ProbeVolumePlugins()...)
|
||||
allPlugins = append(allPlugins, iscsi.ProbeVolumePlugins()...)
|
||||
allPlugins = append(allPlugins, glusterfs.ProbeVolumePlugins()...)
|
||||
allPlugins = append(allPlugins, rbd.ProbeVolumePlugins()...)
|
||||
allPlugins = append(allPlugins, cinder.ProbeVolumePlugins()...)
|
||||
allPlugins = append(allPlugins, quobyte.ProbeVolumePlugins()...)
|
||||
allPlugins = append(allPlugins, cephfs.ProbeVolumePlugins()...)
|
||||
allPlugins = append(allPlugins, downwardapi.ProbeVolumePlugins()...)
|
||||
allPlugins = append(allPlugins, fc.ProbeVolumePlugins()...)
|
||||
allPlugins = append(allPlugins, flocker.ProbeVolumePlugins()...)
|
||||
allPlugins = append(allPlugins, azure_file.ProbeVolumePlugins()...)
|
||||
allPlugins = append(allPlugins, configmap.ProbeVolumePlugins()...)
|
||||
allPlugins = append(allPlugins, vsphere_volume.ProbeVolumePlugins()...)
|
||||
allPlugins = append(allPlugins, azure_dd.ProbeVolumePlugins()...)
|
||||
allPlugins = append(allPlugins, photon_pd.ProbeVolumePlugins()...)
|
||||
allPlugins = append(allPlugins, projected.ProbeVolumePlugins()...)
|
||||
allPlugins = append(allPlugins, portworx.ProbeVolumePlugins()...)
|
||||
allPlugins = append(allPlugins, scaleio.ProbeVolumePlugins()...)
|
||||
allPlugins = append(allPlugins, local.ProbeVolumePlugins()...)
|
||||
allPlugins = append(allPlugins, storageos.ProbeVolumePlugins()...)
|
||||
return allPlugins
|
||||
}
|
||||
|
||||
// GetDynamicPluginProber gets the probers of dynamically discoverable plugins
|
||||
// for kubelet.
|
||||
// Currently only Flexvolume plugins are dynamically discoverable.
|
||||
func GetDynamicPluginProber(pluginDir string) volume.DynamicPluginProber {
|
||||
return flexvolume.GetDynamicPluginProber(pluginDir)
|
||||
}
|
||||
|
||||
// ProbeNetworkPlugins collects all compiled-in plugins
|
||||
func ProbeNetworkPlugins(pluginDir, cniConfDir, cniBinDir string) []network.NetworkPlugin {
|
||||
allPlugins := []network.NetworkPlugin{}
|
||||
|
||||
// for backwards-compat, allow pluginDir as a source of CNI config files
|
||||
if cniConfDir == "" {
|
||||
cniConfDir = pluginDir
|
||||
}
|
||||
|
||||
binDir := cniBinDir
|
||||
if binDir == "" {
|
||||
binDir = pluginDir
|
||||
}
|
||||
// for each existing plugin, add to the list
|
||||
allPlugins = append(allPlugins, cni.ProbeNetworkPlugins(cniConfDir, binDir)...)
|
||||
allPlugins = append(allPlugins, kubenet.NewPlugin(binDir))
|
||||
|
||||
return allPlugins
|
||||
}
|
||||
875
vendor/k8s.io/kubernetes/cmd/kubelet/app/server.go
generated
vendored
Normal file
875
vendor/k8s.io/kubernetes/cmd/kubelet/app/server.go
generated
vendored
Normal file
|
|
@ -0,0 +1,875 @@
|
|||
/*
|
||||
Copyright 2015 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 app makes it easy to create a kubelet server for various contexts.
|
||||
package app
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"net"
|
||||
"net/http"
|
||||
_ "net/http/pprof"
|
||||
"net/url"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/pflag"
|
||||
|
||||
"k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/api/resource"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
"k8s.io/apiserver/pkg/server/healthz"
|
||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||
"k8s.io/apiserver/pkg/util/flag"
|
||||
clientgoclientset "k8s.io/client-go/kubernetes"
|
||||
clientset "k8s.io/client-go/kubernetes"
|
||||
v1core "k8s.io/client-go/kubernetes/typed/core/v1"
|
||||
restclient "k8s.io/client-go/rest"
|
||||
"k8s.io/client-go/tools/clientcmd"
|
||||
"k8s.io/client-go/tools/record"
|
||||
certutil "k8s.io/client-go/util/cert"
|
||||
"k8s.io/kubernetes/cmd/kubelet/app/options"
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
"k8s.io/kubernetes/pkg/capabilities"
|
||||
"k8s.io/kubernetes/pkg/client/chaosclient"
|
||||
"k8s.io/kubernetes/pkg/cloudprovider"
|
||||
"k8s.io/kubernetes/pkg/credentialprovider"
|
||||
"k8s.io/kubernetes/pkg/features"
|
||||
"k8s.io/kubernetes/pkg/kubelet"
|
||||
kubeletconfiginternal "k8s.io/kubernetes/pkg/kubelet/apis/kubeletconfig"
|
||||
kubeletscheme "k8s.io/kubernetes/pkg/kubelet/apis/kubeletconfig/scheme"
|
||||
kubeletconfigv1alpha1 "k8s.io/kubernetes/pkg/kubelet/apis/kubeletconfig/v1alpha1"
|
||||
"k8s.io/kubernetes/pkg/kubelet/cadvisor"
|
||||
"k8s.io/kubernetes/pkg/kubelet/certificate"
|
||||
"k8s.io/kubernetes/pkg/kubelet/certificate/bootstrap"
|
||||
"k8s.io/kubernetes/pkg/kubelet/cm"
|
||||
"k8s.io/kubernetes/pkg/kubelet/config"
|
||||
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
|
||||
"k8s.io/kubernetes/pkg/kubelet/dockershim"
|
||||
"k8s.io/kubernetes/pkg/kubelet/dockershim/libdocker"
|
||||
dockerremote "k8s.io/kubernetes/pkg/kubelet/dockershim/remote"
|
||||
"k8s.io/kubernetes/pkg/kubelet/eviction"
|
||||
evictionapi "k8s.io/kubernetes/pkg/kubelet/eviction/api"
|
||||
"k8s.io/kubernetes/pkg/kubelet/kubeletconfig"
|
||||
"k8s.io/kubernetes/pkg/kubelet/server"
|
||||
"k8s.io/kubernetes/pkg/kubelet/server/streaming"
|
||||
kubetypes "k8s.io/kubernetes/pkg/kubelet/types"
|
||||
"k8s.io/kubernetes/pkg/util/configz"
|
||||
"k8s.io/kubernetes/pkg/util/flock"
|
||||
kubeio "k8s.io/kubernetes/pkg/util/io"
|
||||
"k8s.io/kubernetes/pkg/util/mount"
|
||||
nodeutil "k8s.io/kubernetes/pkg/util/node"
|
||||
"k8s.io/kubernetes/pkg/util/oom"
|
||||
"k8s.io/kubernetes/pkg/util/rlimit"
|
||||
"k8s.io/kubernetes/pkg/version"
|
||||
)
|
||||
|
||||
const (
|
||||
// Kubelet component name
|
||||
componentKubelet = "kubelet"
|
||||
)
|
||||
|
||||
// NewKubeletCommand creates a *cobra.Command object with default parameters
|
||||
func NewKubeletCommand() *cobra.Command {
|
||||
// ignore the error, as this is just for generating docs and the like
|
||||
s, _ := options.NewKubeletServer()
|
||||
s.AddFlags(pflag.CommandLine)
|
||||
cmd := &cobra.Command{
|
||||
Use: componentKubelet,
|
||||
Long: `The kubelet is the primary "node agent" that runs on each
|
||||
node. The kubelet works in terms of a PodSpec. A PodSpec is a YAML or JSON object
|
||||
that describes a pod. The kubelet takes a set of PodSpecs that are provided through
|
||||
various mechanisms (primarily through the apiserver) and ensures that the containers
|
||||
described in those PodSpecs are running and healthy. The kubelet doesn't manage
|
||||
containers which were not created by Kubernetes.
|
||||
|
||||
Other than from an PodSpec from the apiserver, there are three ways that a container
|
||||
manifest can be provided to the Kubelet.
|
||||
|
||||
File: Path passed as a flag on the command line. Files under this path will be monitored
|
||||
periodically for updates. The monitoring period is 20s by default and is configurable
|
||||
via a flag.
|
||||
|
||||
HTTP endpoint: HTTP endpoint passed as a parameter on the command line. This endpoint
|
||||
is checked every 20 seconds (also configurable with a flag).
|
||||
|
||||
HTTP server: The kubelet can also listen for HTTP and respond to a simple API
|
||||
(underspec'd currently) to submit a new manifest.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
},
|
||||
}
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
// UnsecuredDependencies returns a Dependencies suitable for being run, or an error if the server setup
|
||||
// is not valid. It will not start any background processes, and does not include authentication/authorization
|
||||
func UnsecuredDependencies(s *options.KubeletServer) (*kubelet.Dependencies, error) {
|
||||
// Initialize the TLS Options
|
||||
tlsOptions, err := InitializeTLS(&s.KubeletFlags, &s.KubeletConfiguration)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
mounter := mount.New(s.ExperimentalMounterPath)
|
||||
var writer kubeio.Writer = &kubeio.StdWriter{}
|
||||
if s.Containerized {
|
||||
glog.V(2).Info("Running kubelet in containerized mode (experimental)")
|
||||
mounter = mount.NewNsenterMounter()
|
||||
writer = &kubeio.NsenterWriter{}
|
||||
}
|
||||
|
||||
var dockerClient libdocker.Interface
|
||||
if s.ContainerRuntime == kubetypes.DockerContainerRuntime {
|
||||
dockerClient = libdocker.ConnectToDockerOrDie(s.DockerEndpoint, s.RuntimeRequestTimeout.Duration,
|
||||
s.ImagePullProgressDeadline.Duration)
|
||||
} else {
|
||||
dockerClient = nil
|
||||
}
|
||||
|
||||
return &kubelet.Dependencies{
|
||||
Auth: nil, // default does not enforce auth[nz]
|
||||
CAdvisorInterface: nil, // cadvisor.New launches background processes (bg http.ListenAndServe, and some bg cleaners), not set here
|
||||
Cloud: nil, // cloud provider might start background processes
|
||||
ContainerManager: nil,
|
||||
DockerClient: dockerClient,
|
||||
KubeClient: nil,
|
||||
HeartbeatClient: nil,
|
||||
ExternalKubeClient: nil,
|
||||
EventClient: nil,
|
||||
Mounter: mounter,
|
||||
NetworkPlugins: ProbeNetworkPlugins(s.NetworkPluginDir, s.CNIConfDir, s.CNIBinDir),
|
||||
OOMAdjuster: oom.NewOOMAdjuster(),
|
||||
OSInterface: kubecontainer.RealOS{},
|
||||
Writer: writer,
|
||||
VolumePlugins: ProbeVolumePlugins(),
|
||||
DynamicPluginProber: GetDynamicPluginProber(s.VolumePluginDir),
|
||||
TLSOptions: tlsOptions}, nil
|
||||
}
|
||||
|
||||
// Run runs the specified KubeletServer with the given Dependencies. This should never exit.
|
||||
// The kubeDeps argument may be nil - if so, it is initialized from the settings on KubeletServer.
|
||||
// Otherwise, the caller is assumed to have set up the Dependencies object and a default one will
|
||||
// not be generated.
|
||||
func Run(s *options.KubeletServer, kubeDeps *kubelet.Dependencies) error {
|
||||
if err := run(s, kubeDeps); err != nil {
|
||||
return fmt.Errorf("failed to run Kubelet: %v", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func checkPermissions() error {
|
||||
if uid := os.Getuid(); uid != 0 {
|
||||
return fmt.Errorf("Kubelet needs to run as uid `0`. It is being run as %d", uid)
|
||||
}
|
||||
// TODO: Check if kubelet is running in the `initial` user namespace.
|
||||
// http://man7.org/linux/man-pages/man7/user_namespaces.7.html
|
||||
return nil
|
||||
}
|
||||
|
||||
func setConfigz(cz *configz.Config, kc *kubeletconfiginternal.KubeletConfiguration) error {
|
||||
scheme, _, err := kubeletscheme.NewSchemeAndCodecs()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
versioned := kubeletconfigv1alpha1.KubeletConfiguration{}
|
||||
if err := scheme.Convert(kc, &versioned, nil); err != nil {
|
||||
return err
|
||||
}
|
||||
cz.Set(versioned)
|
||||
return nil
|
||||
}
|
||||
|
||||
func initConfigz(kc *kubeletconfiginternal.KubeletConfiguration) error {
|
||||
cz, err := configz.New("kubeletconfig")
|
||||
if err != nil {
|
||||
glog.Errorf("unable to register configz: %s", err)
|
||||
return err
|
||||
}
|
||||
if err := setConfigz(cz, kc); err != nil {
|
||||
glog.Errorf("unable to register config: %s", err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// makeEventRecorder sets up kubeDeps.Recorder if its nil. Its a no-op otherwise.
|
||||
func makeEventRecorder(kubeDeps *kubelet.Dependencies, nodeName types.NodeName) {
|
||||
if kubeDeps.Recorder != nil {
|
||||
return
|
||||
}
|
||||
eventBroadcaster := record.NewBroadcaster()
|
||||
kubeDeps.Recorder = eventBroadcaster.NewRecorder(api.Scheme, v1.EventSource{Component: componentKubelet, Host: string(nodeName)})
|
||||
eventBroadcaster.StartLogging(glog.V(3).Infof)
|
||||
if kubeDeps.EventClient != nil {
|
||||
glog.V(4).Infof("Sending events to api server.")
|
||||
eventBroadcaster.StartRecordingToSink(&v1core.EventSinkImpl{Interface: kubeDeps.EventClient.Events("")})
|
||||
} else {
|
||||
glog.Warning("No api server defined - no events will be sent to API server.")
|
||||
}
|
||||
}
|
||||
|
||||
func run(s *options.KubeletServer, kubeDeps *kubelet.Dependencies) (err error) {
|
||||
// Set global feature gates based on the value on the initial KubeletServer
|
||||
err = utilfeature.DefaultFeatureGate.Set(s.KubeletConfiguration.FeatureGates)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// validate the initial KubeletServer (we set feature gates first, because this validation depends on feature gates)
|
||||
if err := options.ValidateKubeletServer(s); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Obtain Kubelet Lock File
|
||||
if s.ExitOnLockContention && s.LockFilePath == "" {
|
||||
return errors.New("cannot exit on lock file contention: no lock file specified")
|
||||
}
|
||||
done := make(chan struct{})
|
||||
if s.LockFilePath != "" {
|
||||
glog.Infof("acquiring file lock on %q", s.LockFilePath)
|
||||
if err := flock.Acquire(s.LockFilePath); err != nil {
|
||||
return fmt.Errorf("unable to acquire file lock on %q: %v", s.LockFilePath, err)
|
||||
}
|
||||
if s.ExitOnLockContention {
|
||||
glog.Infof("watching for inotify events for: %v", s.LockFilePath)
|
||||
if err := watchForLockfileContention(s.LockFilePath, done); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Register current configuration with /configz endpoint
|
||||
err = initConfigz(&s.KubeletConfiguration)
|
||||
if err != nil {
|
||||
glog.Errorf("unable to register KubeletConfiguration with configz, error: %v", err)
|
||||
}
|
||||
|
||||
// About to get clients and such, detect standaloneMode
|
||||
standaloneMode := true
|
||||
switch {
|
||||
case s.RequireKubeConfig == true:
|
||||
standaloneMode = false
|
||||
glog.Warningf("--require-kubeconfig is deprecated. Set --kubeconfig without using --require-kubeconfig.")
|
||||
case s.KubeConfig.Provided():
|
||||
standaloneMode = false
|
||||
}
|
||||
|
||||
if kubeDeps == nil {
|
||||
kubeDeps, err = UnsecuredDependencies(s)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if s.CloudProvider == kubeletconfigv1alpha1.AutoDetectCloudProvider {
|
||||
glog.Warning("--cloud-provider=auto-detect is deprecated. The desired cloud provider should be set explicitly")
|
||||
}
|
||||
|
||||
if kubeDeps.Cloud == nil {
|
||||
if !cloudprovider.IsExternal(s.CloudProvider) && s.CloudProvider != kubeletconfigv1alpha1.AutoDetectCloudProvider {
|
||||
cloud, err := cloudprovider.InitCloudProvider(s.CloudProvider, s.CloudConfigFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if cloud == nil {
|
||||
glog.V(2).Infof("No cloud provider specified: %q from the config file: %q\n", s.CloudProvider, s.CloudConfigFile)
|
||||
} else {
|
||||
glog.V(2).Infof("Successfully initialized cloud provider: %q from the config file: %q\n", s.CloudProvider, s.CloudConfigFile)
|
||||
}
|
||||
kubeDeps.Cloud = cloud
|
||||
}
|
||||
}
|
||||
|
||||
nodeName, err := getNodeName(kubeDeps.Cloud, nodeutil.GetHostname(s.HostnameOverride))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if s.BootstrapKubeconfig != "" {
|
||||
if err := bootstrap.LoadClientCert(s.KubeConfig.Value(), s.BootstrapKubeconfig, s.CertDirectory, nodeName); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// if in standalone mode, indicate as much by setting all clients to nil
|
||||
if standaloneMode {
|
||||
kubeDeps.KubeClient = nil
|
||||
kubeDeps.ExternalKubeClient = nil
|
||||
kubeDeps.EventClient = nil
|
||||
kubeDeps.HeartbeatClient = nil
|
||||
glog.Warningf("standalone mode, no API client")
|
||||
} else if kubeDeps.KubeClient == nil || kubeDeps.ExternalKubeClient == nil || kubeDeps.EventClient == nil || kubeDeps.HeartbeatClient == nil {
|
||||
// initialize clients if not standalone mode and any of the clients are not provided
|
||||
var kubeClient clientset.Interface
|
||||
var eventClient v1core.EventsGetter
|
||||
var heartbeatClient v1core.CoreV1Interface
|
||||
var externalKubeClient clientgoclientset.Interface
|
||||
|
||||
clientConfig, err := CreateAPIServerClientConfig(s)
|
||||
|
||||
var clientCertificateManager certificate.Manager
|
||||
if err == nil {
|
||||
if s.RotateCertificates && utilfeature.DefaultFeatureGate.Enabled(features.RotateKubeletClientCertificate) {
|
||||
clientCertificateManager, err = certificate.NewKubeletClientCertificateManager(s.CertDirectory, nodeName, clientConfig.CertData, clientConfig.KeyData, clientConfig.CertFile, clientConfig.KeyFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := certificate.UpdateTransport(wait.NeverStop, clientConfig, clientCertificateManager); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
kubeClient, err = clientset.NewForConfig(clientConfig)
|
||||
if err != nil {
|
||||
glog.Warningf("New kubeClient from clientConfig error: %v", err)
|
||||
} else if kubeClient.Certificates() != nil && clientCertificateManager != nil {
|
||||
glog.V(2).Info("Starting client certificate rotation.")
|
||||
clientCertificateManager.SetCertificateSigningRequestClient(kubeClient.Certificates().CertificateSigningRequests())
|
||||
clientCertificateManager.Start()
|
||||
}
|
||||
externalKubeClient, err = clientgoclientset.NewForConfig(clientConfig)
|
||||
if err != nil {
|
||||
glog.Warningf("New kubeClient from clientConfig error: %v", err)
|
||||
}
|
||||
|
||||
// make a separate client for events
|
||||
eventClientConfig := *clientConfig
|
||||
eventClientConfig.QPS = float32(s.EventRecordQPS)
|
||||
eventClientConfig.Burst = int(s.EventBurst)
|
||||
eventClient, err = v1core.NewForConfig(&eventClientConfig)
|
||||
if err != nil {
|
||||
glog.Warningf("Failed to create API Server client for Events: %v", err)
|
||||
}
|
||||
|
||||
// make a separate client for heartbeat with throttling disabled and a timeout attached
|
||||
heartbeatClientConfig := *clientConfig
|
||||
heartbeatClientConfig.Timeout = s.KubeletConfiguration.NodeStatusUpdateFrequency.Duration
|
||||
heartbeatClientConfig.QPS = float32(-1)
|
||||
heartbeatClient, err = v1core.NewForConfig(&heartbeatClientConfig)
|
||||
if err != nil {
|
||||
glog.Warningf("Failed to create API Server client for heartbeat: %v", err)
|
||||
}
|
||||
} else {
|
||||
switch {
|
||||
case s.RequireKubeConfig:
|
||||
return fmt.Errorf("invalid kubeconfig: %v", err)
|
||||
case s.KubeConfig.Provided():
|
||||
glog.Warningf("invalid kubeconfig: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
kubeDeps.KubeClient = kubeClient
|
||||
kubeDeps.ExternalKubeClient = externalKubeClient
|
||||
if heartbeatClient != nil {
|
||||
kubeDeps.HeartbeatClient = heartbeatClient
|
||||
}
|
||||
if eventClient != nil {
|
||||
kubeDeps.EventClient = eventClient
|
||||
}
|
||||
}
|
||||
|
||||
// Alpha Dynamic Configuration Implementation;
|
||||
// if the kubelet config controller is available, inject the latest to start the config and status sync loops
|
||||
if utilfeature.DefaultFeatureGate.Enabled(features.DynamicKubeletConfig) && kubeDeps.KubeletConfigController != nil && !standaloneMode && !s.RunOnce {
|
||||
kubeDeps.KubeletConfigController.StartSync(kubeDeps.KubeClient, string(nodeName))
|
||||
}
|
||||
|
||||
if kubeDeps.Auth == nil {
|
||||
auth, err := BuildAuth(nodeName, kubeDeps.ExternalKubeClient, s.KubeletConfiguration)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
kubeDeps.Auth = auth
|
||||
}
|
||||
|
||||
if kubeDeps.CAdvisorInterface == nil {
|
||||
imageFsInfoProvider := cadvisor.NewImageFsInfoProvider(s.ContainerRuntime, s.RemoteRuntimeEndpoint)
|
||||
kubeDeps.CAdvisorInterface, err = cadvisor.New(s.Address, uint(s.CAdvisorPort), imageFsInfoProvider, s.RootDirectory)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// Setup event recorder if required.
|
||||
makeEventRecorder(kubeDeps, nodeName)
|
||||
|
||||
if kubeDeps.ContainerManager == nil {
|
||||
if s.CgroupsPerQOS && s.CgroupRoot == "" {
|
||||
glog.Infof("--cgroups-per-qos enabled, but --cgroup-root was not specified. defaulting to /")
|
||||
s.CgroupRoot = "/"
|
||||
}
|
||||
kubeReserved, err := parseResourceList(s.KubeReserved)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
systemReserved, err := parseResourceList(s.SystemReserved)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var hardEvictionThresholds []evictionapi.Threshold
|
||||
// If the user requested to ignore eviction thresholds, then do not set valid values for hardEvictionThresholds here.
|
||||
if !s.ExperimentalNodeAllocatableIgnoreEvictionThreshold {
|
||||
hardEvictionThresholds, err = eviction.ParseThresholdConfig([]string{}, s.EvictionHard, "", "", "")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
experimentalQOSReserved, err := cm.ParseQOSReserved(s.ExperimentalQOSReserved)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
devicePluginEnabled := utilfeature.DefaultFeatureGate.Enabled(features.DevicePlugins)
|
||||
|
||||
kubeDeps.ContainerManager, err = cm.NewContainerManager(
|
||||
kubeDeps.Mounter,
|
||||
kubeDeps.CAdvisorInterface,
|
||||
cm.NodeConfig{
|
||||
RuntimeCgroupsName: s.RuntimeCgroups,
|
||||
SystemCgroupsName: s.SystemCgroups,
|
||||
KubeletCgroupsName: s.KubeletCgroups,
|
||||
ContainerRuntime: s.ContainerRuntime,
|
||||
CgroupsPerQOS: s.CgroupsPerQOS,
|
||||
CgroupRoot: s.CgroupRoot,
|
||||
CgroupDriver: s.CgroupDriver,
|
||||
ProtectKernelDefaults: s.ProtectKernelDefaults,
|
||||
NodeAllocatableConfig: cm.NodeAllocatableConfig{
|
||||
KubeReservedCgroupName: s.KubeReservedCgroup,
|
||||
SystemReservedCgroupName: s.SystemReservedCgroup,
|
||||
EnforceNodeAllocatable: sets.NewString(s.EnforceNodeAllocatable...),
|
||||
KubeReserved: kubeReserved,
|
||||
SystemReserved: systemReserved,
|
||||
HardEvictionThresholds: hardEvictionThresholds,
|
||||
},
|
||||
ExperimentalQOSReserved: *experimentalQOSReserved,
|
||||
ExperimentalCPUManagerPolicy: s.CPUManagerPolicy,
|
||||
ExperimentalCPUManagerReconcilePeriod: s.CPUManagerReconcilePeriod.Duration,
|
||||
},
|
||||
s.FailSwapOn,
|
||||
devicePluginEnabled,
|
||||
kubeDeps.Recorder)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if err := checkPermissions(); err != nil {
|
||||
glog.Error(err)
|
||||
}
|
||||
|
||||
utilruntime.ReallyCrash = s.ReallyCrashForTesting
|
||||
|
||||
rand.Seed(time.Now().UTC().UnixNano())
|
||||
|
||||
// TODO(vmarmol): Do this through container config.
|
||||
oomAdjuster := kubeDeps.OOMAdjuster
|
||||
if err := oomAdjuster.ApplyOOMScoreAdj(0, int(s.OOMScoreAdj)); err != nil {
|
||||
glog.Warning(err)
|
||||
}
|
||||
|
||||
if err := RunKubelet(&s.KubeletFlags, &s.KubeletConfiguration, kubeDeps, s.RunOnce); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if s.HealthzPort > 0 {
|
||||
healthz.DefaultHealthz()
|
||||
go wait.Until(func() {
|
||||
err := http.ListenAndServe(net.JoinHostPort(s.HealthzBindAddress, strconv.Itoa(int(s.HealthzPort))), nil)
|
||||
if err != nil {
|
||||
glog.Errorf("Starting health server failed: %v", err)
|
||||
}
|
||||
}, 5*time.Second, wait.NeverStop)
|
||||
}
|
||||
|
||||
if s.RunOnce {
|
||||
return nil
|
||||
}
|
||||
|
||||
<-done
|
||||
return nil
|
||||
}
|
||||
|
||||
// getNodeName returns the node name according to the cloud provider
|
||||
// if cloud provider is specified. Otherwise, returns the hostname of the node.
|
||||
func getNodeName(cloud cloudprovider.Interface, hostname string) (types.NodeName, error) {
|
||||
if cloud == nil {
|
||||
return types.NodeName(hostname), nil
|
||||
}
|
||||
|
||||
instances, ok := cloud.Instances()
|
||||
if !ok {
|
||||
return "", fmt.Errorf("failed to get instances from cloud provider")
|
||||
}
|
||||
|
||||
nodeName, err := instances.CurrentNodeName(hostname)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("error fetching current node name from cloud provider: %v", err)
|
||||
}
|
||||
|
||||
glog.V(2).Infof("cloud provider determined current node name to be %s", nodeName)
|
||||
|
||||
return nodeName, nil
|
||||
}
|
||||
|
||||
// InitializeTLS checks for a configured TLSCertFile and TLSPrivateKeyFile: if unspecified a new self-signed
|
||||
// certificate and key file are generated. Returns a configured server.TLSOptions object.
|
||||
func InitializeTLS(kf *options.KubeletFlags, kc *kubeletconfiginternal.KubeletConfiguration) (*server.TLSOptions, error) {
|
||||
if !utilfeature.DefaultFeatureGate.Enabled(features.RotateKubeletServerCertificate) && kc.TLSCertFile == "" && kc.TLSPrivateKeyFile == "" {
|
||||
kc.TLSCertFile = path.Join(kf.CertDirectory, "kubelet.crt")
|
||||
kc.TLSPrivateKeyFile = path.Join(kf.CertDirectory, "kubelet.key")
|
||||
|
||||
canReadCertAndKey, err := certutil.CanReadCertAndKey(kc.TLSCertFile, kc.TLSPrivateKeyFile)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !canReadCertAndKey {
|
||||
cert, key, err := certutil.GenerateSelfSignedCertKey(nodeutil.GetHostname(kf.HostnameOverride), nil, nil)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to generate self signed cert: %v", err)
|
||||
}
|
||||
|
||||
if err := certutil.WriteCert(kc.TLSCertFile, cert); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := certutil.WriteKey(kc.TLSPrivateKeyFile, key); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
glog.V(4).Infof("Using self-signed cert (%s, %s)", kc.TLSCertFile, kc.TLSPrivateKeyFile)
|
||||
}
|
||||
}
|
||||
tlsOptions := &server.TLSOptions{
|
||||
Config: &tls.Config{
|
||||
// Can't use SSLv3 because of POODLE and BEAST
|
||||
// Can't use TLSv1.0 because of POODLE and BEAST using CBC cipher
|
||||
// Can't use TLSv1.1 because of RC4 cipher usage
|
||||
MinVersion: tls.VersionTLS12,
|
||||
},
|
||||
CertFile: kc.TLSCertFile,
|
||||
KeyFile: kc.TLSPrivateKeyFile,
|
||||
}
|
||||
|
||||
if len(kc.Authentication.X509.ClientCAFile) > 0 {
|
||||
clientCAs, err := certutil.NewPool(kc.Authentication.X509.ClientCAFile)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to load client CA file %s: %v", kc.Authentication.X509.ClientCAFile, err)
|
||||
}
|
||||
// Specify allowed CAs for client certificates
|
||||
tlsOptions.Config.ClientCAs = clientCAs
|
||||
// Populate PeerCertificates in requests, but don't reject connections without verified certificates
|
||||
tlsOptions.Config.ClientAuth = tls.RequestClientCert
|
||||
}
|
||||
|
||||
return tlsOptions, nil
|
||||
}
|
||||
|
||||
func kubeconfigClientConfig(s *options.KubeletServer) (*restclient.Config, error) {
|
||||
return clientcmd.NewNonInteractiveDeferredLoadingClientConfig(
|
||||
&clientcmd.ClientConfigLoadingRules{ExplicitPath: s.KubeConfig.Value()},
|
||||
&clientcmd.ConfigOverrides{},
|
||||
).ClientConfig()
|
||||
}
|
||||
|
||||
// createClientConfig creates a client configuration from the command line arguments.
|
||||
// If --kubeconfig is explicitly set, it will be used. If it is not set but
|
||||
// --require-kubeconfig=true, we attempt to load the default kubeconfig file.
|
||||
func createClientConfig(s *options.KubeletServer) (*restclient.Config, error) {
|
||||
// If --kubeconfig was not provided, it will have a default path set in cmd/kubelet/app/options/options.go.
|
||||
// We only use that default path when --require-kubeconfig=true. The default path is temporary until --require-kubeconfig is removed.
|
||||
// TODO(#41161:v1.10.0): Remove the default kubeconfig path and --require-kubeconfig.
|
||||
if s.BootstrapKubeconfig != "" || s.KubeConfig.Provided() || s.RequireKubeConfig == true {
|
||||
return kubeconfigClientConfig(s)
|
||||
} else {
|
||||
return nil, fmt.Errorf("createClientConfig called in standalone mode")
|
||||
}
|
||||
}
|
||||
|
||||
// CreateAPIServerClientConfig generates a client.Config from command line flags
|
||||
// via createClientConfig and then injects chaos into the configuration via addChaosToClientConfig.
|
||||
// This func is exported to support integration with third party kubelet extensions (e.g. kubernetes-mesos).
|
||||
func CreateAPIServerClientConfig(s *options.KubeletServer) (*restclient.Config, error) {
|
||||
clientConfig, err := createClientConfig(s)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
clientConfig.ContentType = s.ContentType
|
||||
// Override kubeconfig qps/burst settings from flags
|
||||
clientConfig.QPS = float32(s.KubeAPIQPS)
|
||||
clientConfig.Burst = int(s.KubeAPIBurst)
|
||||
|
||||
addChaosToClientConfig(s, clientConfig)
|
||||
return clientConfig, nil
|
||||
}
|
||||
|
||||
// addChaosToClientConfig injects random errors into client connections if configured.
|
||||
func addChaosToClientConfig(s *options.KubeletServer, config *restclient.Config) {
|
||||
if s.ChaosChance != 0.0 {
|
||||
config.WrapTransport = func(rt http.RoundTripper) http.RoundTripper {
|
||||
seed := chaosclient.NewSeed(1)
|
||||
// TODO: introduce a standard chaos package with more tunables - this is just a proof of concept
|
||||
// TODO: introduce random latency and stalls
|
||||
return chaosclient.NewChaosRoundTripper(rt, chaosclient.LogChaos, seed.P(s.ChaosChance, chaosclient.ErrSimulatedConnectionResetByPeer))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// RunKubelet is responsible for setting up and running a kubelet. It is used in three different applications:
|
||||
// 1 Integration tests
|
||||
// 2 Kubelet binary
|
||||
// 3 Standalone 'kubernetes' binary
|
||||
// Eventually, #2 will be replaced with instances of #3
|
||||
func RunKubelet(kubeFlags *options.KubeletFlags, kubeCfg *kubeletconfiginternal.KubeletConfiguration, kubeDeps *kubelet.Dependencies, runOnce bool) error {
|
||||
hostname := nodeutil.GetHostname(kubeFlags.HostnameOverride)
|
||||
// Query the cloud provider for our node name, default to hostname if kcfg.Cloud == nil
|
||||
nodeName, err := getNodeName(kubeDeps.Cloud, hostname)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// Setup event recorder if required.
|
||||
makeEventRecorder(kubeDeps, nodeName)
|
||||
|
||||
// TODO(mtaufen): I moved the validation of these fields here, from UnsecuredKubeletConfig,
|
||||
// so that I could remove the associated fields from KubeletConfiginternal. I would
|
||||
// prefer this to be done as part of an independent validation step on the
|
||||
// KubeletConfiguration. But as far as I can tell, we don't have an explicit
|
||||
// place for validation of the KubeletConfiguration yet.
|
||||
hostNetworkSources, err := kubetypes.GetValidatedSources(kubeCfg.HostNetworkSources)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
hostPIDSources, err := kubetypes.GetValidatedSources(kubeCfg.HostPIDSources)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
hostIPCSources, err := kubetypes.GetValidatedSources(kubeCfg.HostIPCSources)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
privilegedSources := capabilities.PrivilegedSources{
|
||||
HostNetworkSources: hostNetworkSources,
|
||||
HostPIDSources: hostPIDSources,
|
||||
HostIPCSources: hostIPCSources,
|
||||
}
|
||||
capabilities.Setup(kubeCfg.AllowPrivileged, privilegedSources, 0)
|
||||
|
||||
credentialprovider.SetPreferredDockercfgPath(kubeFlags.RootDirectory)
|
||||
glog.V(2).Infof("Using root directory: %v", kubeFlags.RootDirectory)
|
||||
|
||||
builder := kubeDeps.Builder
|
||||
if builder == nil {
|
||||
builder = CreateAndInitKubelet
|
||||
}
|
||||
if kubeDeps.OSInterface == nil {
|
||||
kubeDeps.OSInterface = kubecontainer.RealOS{}
|
||||
}
|
||||
|
||||
k, err := builder(kubeCfg, kubeDeps, &kubeFlags.ContainerRuntimeOptions, kubeFlags.HostnameOverride, kubeFlags.NodeIP, kubeFlags.ProviderID, kubeFlags.CloudProvider, kubeFlags.CertDirectory, kubeFlags.RootDirectory)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create kubelet: %v", err)
|
||||
}
|
||||
|
||||
// NewMainKubelet should have set up a pod source config if one didn't exist
|
||||
// when the builder was run. This is just a precaution.
|
||||
if kubeDeps.PodConfig == nil {
|
||||
return fmt.Errorf("failed to create kubelet, pod source config was nil")
|
||||
}
|
||||
podCfg := kubeDeps.PodConfig
|
||||
|
||||
rlimit.RlimitNumFiles(uint64(kubeCfg.MaxOpenFiles))
|
||||
|
||||
// process pods and exit.
|
||||
if runOnce {
|
||||
if _, err := k.RunOnce(podCfg.Updates()); err != nil {
|
||||
return fmt.Errorf("runonce failed: %v", err)
|
||||
}
|
||||
glog.Infof("Started kubelet %s as runonce", version.Get().String())
|
||||
} else {
|
||||
startKubelet(k, podCfg, kubeCfg, kubeDeps)
|
||||
glog.Infof("Started kubelet %s", version.Get().String())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func startKubelet(k kubelet.Bootstrap, podCfg *config.PodConfig, kubeCfg *kubeletconfiginternal.KubeletConfiguration, kubeDeps *kubelet.Dependencies) {
|
||||
// start the kubelet
|
||||
go wait.Until(func() { k.Run(podCfg.Updates()) }, 0, wait.NeverStop)
|
||||
|
||||
// start the kubelet server
|
||||
if kubeCfg.EnableServer {
|
||||
go wait.Until(func() {
|
||||
k.ListenAndServe(net.ParseIP(kubeCfg.Address), uint(kubeCfg.Port), kubeDeps.TLSOptions, kubeDeps.Auth, kubeCfg.EnableDebuggingHandlers, kubeCfg.EnableContentionProfiling)
|
||||
}, 0, wait.NeverStop)
|
||||
}
|
||||
if kubeCfg.ReadOnlyPort > 0 {
|
||||
go wait.Until(func() {
|
||||
k.ListenAndServeReadOnly(net.ParseIP(kubeCfg.Address), uint(kubeCfg.ReadOnlyPort))
|
||||
}, 0, wait.NeverStop)
|
||||
}
|
||||
}
|
||||
|
||||
func CreateAndInitKubelet(kubeCfg *kubeletconfiginternal.KubeletConfiguration,
|
||||
kubeDeps *kubelet.Dependencies,
|
||||
crOptions *options.ContainerRuntimeOptions,
|
||||
hostnameOverride,
|
||||
nodeIP,
|
||||
providerID,
|
||||
cloudProvider,
|
||||
certDirectory,
|
||||
rootDirectory string) (k kubelet.Bootstrap, err error) {
|
||||
// TODO: block until all sources have delivered at least one update to the channel, or break the sync loop
|
||||
// up into "per source" synchronizations
|
||||
|
||||
k, err = kubelet.NewMainKubelet(kubeCfg, kubeDeps, crOptions, hostnameOverride, nodeIP, providerID, cloudProvider, certDirectory, rootDirectory)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
k.BirthCry()
|
||||
|
||||
k.StartGarbageCollection()
|
||||
|
||||
return k, nil
|
||||
}
|
||||
|
||||
// parseResourceList parses the given configuration map into an API
|
||||
// ResourceList or returns an error.
|
||||
func parseResourceList(m kubeletconfiginternal.ConfigurationMap) (v1.ResourceList, error) {
|
||||
if len(m) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
rl := make(v1.ResourceList)
|
||||
for k, v := range m {
|
||||
switch v1.ResourceName(k) {
|
||||
// CPU, memory and local storage resources are supported.
|
||||
case v1.ResourceCPU, v1.ResourceMemory, v1.ResourceEphemeralStorage:
|
||||
q, err := resource.ParseQuantity(v)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if q.Sign() == -1 {
|
||||
return nil, fmt.Errorf("resource quantity for %q cannot be negative: %v", k, v)
|
||||
}
|
||||
rl[v1.ResourceName(k)] = q
|
||||
default:
|
||||
return nil, fmt.Errorf("cannot reserve %q resource", k)
|
||||
}
|
||||
}
|
||||
return rl, nil
|
||||
}
|
||||
|
||||
// BootstrapKubeletConfigController constructs and bootstrap a configuration controller
|
||||
func BootstrapKubeletConfigController(defaultConfig *kubeletconfiginternal.KubeletConfiguration,
|
||||
initConfigDirFlag flag.StringFlag,
|
||||
dynamicConfigDirFlag flag.StringFlag) (*kubeletconfiginternal.KubeletConfiguration, *kubeletconfig.Controller, error) {
|
||||
var err error
|
||||
// Alpha Dynamic Configuration Implementation; this section only loads config from disk, it does not contact the API server
|
||||
// compute absolute paths based on current working dir
|
||||
initConfigDir := ""
|
||||
if utilfeature.DefaultFeatureGate.Enabled(features.KubeletConfigFile) && initConfigDirFlag.Provided() {
|
||||
initConfigDir, err = filepath.Abs(initConfigDirFlag.Value())
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("failed to get absolute path for --init-config-dir")
|
||||
}
|
||||
}
|
||||
dynamicConfigDir := ""
|
||||
if utilfeature.DefaultFeatureGate.Enabled(features.DynamicKubeletConfig) && dynamicConfigDirFlag.Provided() {
|
||||
dynamicConfigDir, err = filepath.Abs(dynamicConfigDirFlag.Value())
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("failed to get absolute path for --dynamic-config-dir")
|
||||
}
|
||||
}
|
||||
|
||||
// get the latest KubeletConfiguration checkpoint from disk, or load the init or default config if no valid checkpoints exist
|
||||
kubeletConfigController, err := kubeletconfig.NewController(defaultConfig, initConfigDir, dynamicConfigDir)
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("failed to construct controller, error: %v", err)
|
||||
}
|
||||
kubeletConfig, err := kubeletConfigController.Bootstrap()
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("failed to determine a valid configuration, error: %v", err)
|
||||
}
|
||||
return kubeletConfig, kubeletConfigController, nil
|
||||
}
|
||||
|
||||
// RunDockershim only starts the dockershim in current process. This is only used for cri validate testing purpose
|
||||
// TODO(random-liu): Move this to a separate binary.
|
||||
func RunDockershim(c *kubeletconfiginternal.KubeletConfiguration, r *options.ContainerRuntimeOptions) error {
|
||||
// Create docker client.
|
||||
dockerClient := libdocker.ConnectToDockerOrDie(r.DockerEndpoint, c.RuntimeRequestTimeout.Duration,
|
||||
r.ImagePullProgressDeadline.Duration)
|
||||
|
||||
// Initialize network plugin settings.
|
||||
binDir := r.CNIBinDir
|
||||
if binDir == "" {
|
||||
binDir = r.NetworkPluginDir
|
||||
}
|
||||
nh := &kubelet.NoOpLegacyHost{}
|
||||
pluginSettings := dockershim.NetworkPluginSettings{
|
||||
HairpinMode: kubeletconfiginternal.HairpinMode(c.HairpinMode),
|
||||
NonMasqueradeCIDR: c.NonMasqueradeCIDR,
|
||||
PluginName: r.NetworkPluginName,
|
||||
PluginConfDir: r.CNIConfDir,
|
||||
PluginBinDir: binDir,
|
||||
MTU: int(r.NetworkPluginMTU),
|
||||
LegacyRuntimeHost: nh,
|
||||
}
|
||||
|
||||
// Initialize streaming configuration. (Not using TLS now)
|
||||
streamingConfig := &streaming.Config{
|
||||
// Use a relative redirect (no scheme or host).
|
||||
BaseURL: &url.URL{Path: "/cri/"},
|
||||
StreamIdleTimeout: c.StreamingConnectionIdleTimeout.Duration,
|
||||
StreamCreationTimeout: streaming.DefaultConfig.StreamCreationTimeout,
|
||||
SupportedRemoteCommandProtocols: streaming.DefaultConfig.SupportedRemoteCommandProtocols,
|
||||
SupportedPortForwardProtocols: streaming.DefaultConfig.SupportedPortForwardProtocols,
|
||||
}
|
||||
|
||||
ds, err := dockershim.NewDockerService(dockerClient, r.PodSandboxImage, streamingConfig, &pluginSettings,
|
||||
c.RuntimeCgroups, c.CgroupDriver, r.DockerExecHandlerName, r.DockershimRootDirectory, r.DockerDisableSharedPID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := ds.Start(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
glog.V(2).Infof("Starting the GRPC server for the docker CRI shim.")
|
||||
server := dockerremote.NewDockerServer(c.RemoteRuntimeEndpoint, ds)
|
||||
if err := server.Start(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Start the streaming server
|
||||
addr := net.JoinHostPort(c.Address, strconv.Itoa(int(c.Port)))
|
||||
return http.ListenAndServe(addr, ds)
|
||||
}
|
||||
44
vendor/k8s.io/kubernetes/cmd/kubelet/app/server_linux.go
generated
vendored
Normal file
44
vendor/k8s.io/kubernetes/cmd/kubelet/app/server_linux.go
generated
vendored
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
Copyright 2015 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 app
|
||||
|
||||
import (
|
||||
"github.com/golang/glog"
|
||||
"golang.org/x/exp/inotify"
|
||||
)
|
||||
|
||||
func watchForLockfileContention(path string, done chan struct{}) error {
|
||||
watcher, err := inotify.NewWatcher()
|
||||
if err != nil {
|
||||
glog.Errorf("unable to create watcher for lockfile: %v", err)
|
||||
return err
|
||||
}
|
||||
if err = watcher.AddWatch(path, inotify.IN_OPEN|inotify.IN_DELETE_SELF); err != nil {
|
||||
glog.Errorf("unable to watch lockfile: %v", err)
|
||||
return err
|
||||
}
|
||||
go func() {
|
||||
select {
|
||||
case ev := <-watcher.Event:
|
||||
glog.Infof("inotify event: %v", ev)
|
||||
case err = <-watcher.Error:
|
||||
glog.Errorf("inotify watcher error: %v", err)
|
||||
}
|
||||
close(done)
|
||||
}()
|
||||
return nil
|
||||
}
|
||||
71
vendor/k8s.io/kubernetes/cmd/kubelet/app/server_test.go
generated
vendored
Normal file
71
vendor/k8s.io/kubernetes/cmd/kubelet/app/server_test.go
generated
vendored
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
Copyright 2016 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 app
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"k8s.io/kubernetes/pkg/kubelet/apis/kubeletconfig"
|
||||
)
|
||||
|
||||
func TestValueOfAllocatableResources(t *testing.T) {
|
||||
testCases := []struct {
|
||||
kubeReserved string
|
||||
systemReserved string
|
||||
errorExpected bool
|
||||
name string
|
||||
}{
|
||||
{
|
||||
kubeReserved: "cpu=200m,memory=-150G",
|
||||
systemReserved: "cpu=200m,memory=15Ki",
|
||||
errorExpected: true,
|
||||
name: "negative quantity value",
|
||||
},
|
||||
{
|
||||
kubeReserved: "cpu=200m,memory=150Gi",
|
||||
systemReserved: "cpu=200m,memory=15Ky",
|
||||
errorExpected: true,
|
||||
name: "invalid quantity unit",
|
||||
},
|
||||
{
|
||||
kubeReserved: "cpu=200m,memory=15G",
|
||||
systemReserved: "cpu=200m,memory=15Ki",
|
||||
errorExpected: false,
|
||||
name: "Valid resource quantity",
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range testCases {
|
||||
kubeReservedCM := make(kubeletconfig.ConfigurationMap)
|
||||
systemReservedCM := make(kubeletconfig.ConfigurationMap)
|
||||
|
||||
kubeReservedCM.Set(test.kubeReserved)
|
||||
systemReservedCM.Set(test.systemReserved)
|
||||
|
||||
_, err1 := parseResourceList(kubeReservedCM)
|
||||
_, err2 := parseResourceList(systemReservedCM)
|
||||
if test.errorExpected {
|
||||
if err1 == nil && err2 == nil {
|
||||
t.Errorf("%s: error expected", test.name)
|
||||
}
|
||||
} else {
|
||||
if err1 != nil || err2 != nil {
|
||||
t.Errorf("%s: unexpected error: %v, %v", test.name, err1, err2)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
25
vendor/k8s.io/kubernetes/cmd/kubelet/app/server_unsupported.go
generated
vendored
Normal file
25
vendor/k8s.io/kubernetes/cmd/kubelet/app/server_unsupported.go
generated
vendored
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
// +build !linux
|
||||
|
||||
/*
|
||||
Copyright 2015 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 app
|
||||
|
||||
import "errors"
|
||||
|
||||
func watchForLockfileContention(path string, done chan struct{}) error {
|
||||
return errors.New("kubelet unsupported in this build")
|
||||
}
|
||||
109
vendor/k8s.io/kubernetes/cmd/kubelet/kubelet.go
generated
vendored
Normal file
109
vendor/k8s.io/kubernetes/cmd/kubelet/kubelet.go
generated
vendored
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
/*
|
||||
Copyright 2014 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.
|
||||
*/
|
||||
|
||||
// The kubelet binary is responsible for maintaining a set of containers on a particular host VM.
|
||||
// It syncs data from both configuration file(s) as well as from a quorum of etcd servers.
|
||||
// It then queries Docker to see what is currently running. It synchronizes the configuration data,
|
||||
// with the running set of containers by starting or stopping Docker containers.
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/spf13/pflag"
|
||||
|
||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||
"k8s.io/apiserver/pkg/util/flag"
|
||||
"k8s.io/apiserver/pkg/util/logs"
|
||||
"k8s.io/kubernetes/cmd/kubelet/app"
|
||||
"k8s.io/kubernetes/cmd/kubelet/app/options"
|
||||
_ "k8s.io/kubernetes/pkg/client/metrics/prometheus" // for client metric registration
|
||||
_ "k8s.io/kubernetes/pkg/version/prometheus" // for version metric registration
|
||||
"k8s.io/kubernetes/pkg/version/verflag"
|
||||
)
|
||||
|
||||
func die(err error) {
|
||||
fmt.Fprintf(os.Stderr, "error: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
func main() {
|
||||
// construct KubeletFlags object and register command line flags mapping
|
||||
kubeletFlags := options.NewKubeletFlags()
|
||||
kubeletFlags.AddFlags(pflag.CommandLine)
|
||||
|
||||
// construct KubeletConfiguration object and register command line flags mapping
|
||||
defaultConfig, err := options.NewKubeletConfiguration()
|
||||
if err != nil {
|
||||
die(err)
|
||||
}
|
||||
options.AddKubeletConfigFlags(pflag.CommandLine, defaultConfig)
|
||||
|
||||
// parse the command line flags into the respective objects
|
||||
flag.InitFlags()
|
||||
|
||||
// initialize logging and defer flush
|
||||
logs.InitLogs()
|
||||
defer logs.FlushLogs()
|
||||
|
||||
// short-circuit on verflag
|
||||
verflag.PrintAndExitIfRequested()
|
||||
|
||||
// TODO(mtaufen): won't need this this once dynamic config is GA
|
||||
// set feature gates so we can check if dynamic config is enabled
|
||||
if err := utilfeature.DefaultFeatureGate.Set(defaultConfig.FeatureGates); err != nil {
|
||||
die(err)
|
||||
}
|
||||
// validate the initial KubeletFlags, to make sure the dynamic-config-related flags aren't used unless the feature gate is on
|
||||
if err := options.ValidateKubeletFlags(kubeletFlags); err != nil {
|
||||
die(err)
|
||||
}
|
||||
// bootstrap the kubelet config controller, app.BootstrapKubeletConfigController will check
|
||||
// feature gates and only turn on relevant parts of the controller
|
||||
kubeletConfig, kubeletConfigController, err := app.BootstrapKubeletConfigController(
|
||||
defaultConfig, kubeletFlags.InitConfigDir, kubeletFlags.DynamicConfigDir)
|
||||
if err != nil {
|
||||
die(err)
|
||||
}
|
||||
|
||||
// construct a KubeletServer from kubeletFlags and kubeletConfig
|
||||
kubeletServer := &options.KubeletServer{
|
||||
KubeletFlags: *kubeletFlags,
|
||||
KubeletConfiguration: *kubeletConfig,
|
||||
}
|
||||
|
||||
// use kubeletServer to construct the default KubeletDeps
|
||||
kubeletDeps, err := app.UnsecuredDependencies(kubeletServer)
|
||||
if err != nil {
|
||||
die(err)
|
||||
}
|
||||
|
||||
// add the kubelet config controller to kubeletDeps
|
||||
kubeletDeps.KubeletConfigController = kubeletConfigController
|
||||
|
||||
// start the experimental docker shim, if enabled
|
||||
if kubeletFlags.ExperimentalDockershim {
|
||||
if err := app.RunDockershim(kubeletConfig, &kubeletFlags.ContainerRuntimeOptions); err != nil {
|
||||
die(err)
|
||||
}
|
||||
}
|
||||
|
||||
// run the kubelet
|
||||
if err := app.Run(kubeletServer, kubeletDeps); err != nil {
|
||||
die(err)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue