Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Initial-cut of cri-dockerd #74051

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions build/BUILD
Expand Up @@ -134,6 +134,7 @@ release_filegroup(
release_filegroup(
name = "node-targets",
conditioned_srcs = for_platforms(for_node = [
"//cmd/cri-dockerd",
"//cmd/kube-proxy",
"//cmd/kubeadm",
"//cmd/kubelet",
Expand Down
18 changes: 18 additions & 0 deletions build/debs/BUILD
Expand Up @@ -110,6 +110,24 @@ genrule(
tags = ["manual"],
) for arch in NODE_PLATFORMS["linux"]]

[deb_data(
name = "cri-dockerd",
data = [
{
"files": ["//cmd/cri-dockerd"],
"mode": "0755",
"dir": "/usr/bin",
},
{
"files": ["cri-dockerd.service"],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see this file in the PR. Perhaps it's missing or uncommitted?
Anyway, I presume it's going to be roughly equivalent to kubelet's systemd service file.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, i missed this, will add one

"mode": "644",
"dir": "/lib/systemd/system",
},
],
goarch = arch,
tags = ["manual"],
) for arch in NODE_PLATFORMS["linux"]]

[deb_data(
name = "kubeadm",
data = [
Expand Down
12 changes: 12 additions & 0 deletions build/debs/cri-dockerd.service
@@ -0,0 +1,12 @@
[Unit]
Description=kubelet: The Kubernetes Node Agent
Documentation=http://kubernetes.io/docs/

[Service]
ExecStart=/usr/bin/cri-dockerd
Restart=always
StartLimitInterval=0
RestartSec=10

[Install]
WantedBy=multi-user.target
13 changes: 13 additions & 0 deletions build/rpms/BUILD
Expand Up @@ -50,6 +50,19 @@ genrule(
"kubernetes-cni",
]]

[pkg_rpm_for_goarch(
name = "cri-dockerd",
changelog = "//:CHANGELOG.md",
data = [
"cri-dockerd.service",
"//cmd/cri-dockerd",
],
goarch = arch,
spec_file = "kubelet.spec",
tags = ["manual"],
version_file = "//build:os_package_version",
) for arch in NODE_PLATFORMS["linux"]]

[pkg_rpm_for_goarch(
name = "kubectl",
changelog = "//:CHANGELOG.md",
Expand Down
12 changes: 12 additions & 0 deletions build/rpms/cri-dockerd.service
@@ -0,0 +1,12 @@
[Unit]
Description=kubelet: The Kubernetes Node Agent
Documentation=http://kubernetes.io/docs/

[Service]
ExecStart=/usr/bin/cri-dockerd
Restart=always
StartLimitInterval=0
RestartSec=10

[Install]
WantedBy=multi-user.target
1 change: 1 addition & 0 deletions cmd/BUILD
Expand Up @@ -14,6 +14,7 @@ filegroup(
"//cmd/clicheck:all-srcs",
"//cmd/cloud-controller-manager:all-srcs",
"//cmd/controller-manager/app:all-srcs",
"//cmd/cri-dockerd:all-srcs",
"//cmd/gendocs:all-srcs",
"//cmd/genkubedocs:all-srcs",
"//cmd/genman:all-srcs",
Expand Down
41 changes: 41 additions & 0 deletions cmd/cri-dockerd/BUILD
@@ -0,0 +1,41 @@
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 = "cri-dockerd",
embed = [":go_default_library"],
x_defs = version_x_defs(),
)

go_library(
name = "go_default_library",
srcs = ["cri-dockerd.go"],
importpath = "k8s.io/kubernetes/cmd/cri-dockerd",
deps = [
"//cmd/cri-dockerd/app:go_default_library",
"//staging/src/k8s.io/apiserver/pkg/server:go_default_library",
"//staging/src/k8s.io/component-base/logs:go_default_library",
],
)

filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)

filegroup(
name = "all-srcs",
srcs = [
":package-srcs",
"//cmd/cri-dockerd/app:all-srcs",
],
tags = ["automanaged"],
)
14 changes: 14 additions & 0 deletions cmd/cri-dockerd/OWNERS
@@ -0,0 +1,14 @@
# See the OWNERS docs at https://go.k8s.io/owners

approvers:
- dchen1107
- derekwaynecarr
- Random-Liu
- vishh
- yujuhong
- dims
reviewers:
- sig-node-reviewers
labels:
- area/kubelet
- sig/node
38 changes: 38 additions & 0 deletions cmd/cri-dockerd/app/BUILD
@@ -0,0 +1,38 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")

go_library(
name = "go_default_library",
srcs = ["server.go"],
importpath = "k8s.io/kubernetes/cmd/cri-dockerd/app",
visibility = ["//visibility:public"],
deps = [
"//cmd/cri-dockerd/app/options:go_default_library",
"//pkg/kubelet/dockershim:go_default_library",
"//pkg/kubelet/dockershim/remote:go_default_library",
"//pkg/kubelet/server/streaming:go_default_library",
"//pkg/util/flag:go_default_library",
"//pkg/version/verflag:go_default_library",
"//staging/src/k8s.io/component-base/cli/flag:go_default_library",
"//vendor/github.com/spf13/cobra:go_default_library",
"//vendor/github.com/spf13/pflag:go_default_library",
"//vendor/k8s.io/klog:go_default_library",
],
)

filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)

filegroup(
name = "all-srcs",
srcs = [
":package-srcs",
"//cmd/cri-dockerd/app/config:all-srcs",
"//cmd/cri-dockerd/app/options:all-srcs",
],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)
26 changes: 26 additions & 0 deletions cmd/cri-dockerd/app/config/BUILD
@@ -0,0 +1,26 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")

go_library(
name = "go_default_library",
srcs = ["types.go"],
importpath = "k8s.io/kubernetes/cmd/cri-dockerd/app/config",
visibility = ["//visibility:public"],
deps = [
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/github.com/spf13/pflag:go_default_library",
],
)

filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)

filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)
68 changes: 68 additions & 0 deletions cmd/cri-dockerd/app/config/types.go
@@ -0,0 +1,68 @@
/*
Copyright 2019 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package config

import (
"fmt"

"github.com/spf13/pflag"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// ContainerRuntimeOptions contains runtime options
type ContainerRuntimeOptions struct {
// General options.

//// driver that the kubelet uses to manipulate cgroups on the host (cgroupfs or systemd)
CgroupDriver string
// RuntimeCgroups that container runtime is expected to be isolated in.
RuntimeCgroups string

// 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
// 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
// If no pulling progress is made before the deadline imagePullProgressDeadline,
// the image pulling will be cancelled. Defaults to 1m0s.
// +optional
ImagePullProgressDeadline metav1.Duration
// runtimeRequestTimeout is the timeout for all runtime requests except long running
// requests - pull, logs, exec and attach.
RuntimeRequestTimeout metav1.Duration
// streamingConnectionIdleTimeout is the maximum time a streaming connection
// can be idle before the connection is automatically closed.
StreamingConnectionIdleTimeout metav1.Duration
}

// AddFlags has the set of flags needed by cri-dockerd
func (s *ContainerRuntimeOptions) AddFlags(fs *pflag.FlagSet) {
// General settings.
fs.StringVar(&s.RuntimeCgroups, "runtime-cgroups", s.RuntimeCgroups, "Optional absolute name of cgroups to create and run the runtime in.")

// Docker-specific settings.
fs.StringVar(&s.DockershimRootDirectory, "dockershim-root-directory", s.DockershimRootDirectory, "Path to the dockershim root directory.")
fs.StringVar(&s.PodSandboxImage, "pod-infra-container-image", s.PodSandboxImage, fmt.Sprintf("The image whose network/ipc namespaces containers in each pod will use"))
fs.StringVar(&s.DockerEndpoint, "docker-endpoint", s.DockerEndpoint, fmt.Sprintf("Use this for the docker endpoint to communicate with."))
fs.DurationVar(&s.ImagePullProgressDeadline.Duration, "image-pull-progress-deadline", s.ImagePullProgressDeadline.Duration, fmt.Sprintf("If no pulling progress is made before this deadline, the image pulling will be cancelled."))
}
33 changes: 33 additions & 0 deletions cmd/cri-dockerd/app/options/BUILD
@@ -0,0 +1,33 @@
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",
"globalflags.go",
"options.go",
],
importpath = "k8s.io/kubernetes/cmd/cri-dockerd/app/options",
deps = [
"//cmd/cri-dockerd/app/config:go_default_library",
"//pkg/version/verflag:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//staging/src/k8s.io/component-base/logs:go_default_library",
"//vendor/github.com/spf13/pflag:go_default_library",
],
)

filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)

filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
)
53 changes: 53 additions & 0 deletions cmd/cri-dockerd/app/options/container_runtime.go
@@ -0,0 +1,53 @@
/*
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"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/kubernetes/cmd/cri-dockerd/app/config"
)

const (
// When these values are updated, also update test/e2e/framework/util.go
defaultPodSandboxImageName = "k8s.gcr.io/pause"
defaultPodSandboxImageVersion = "3.1"
)

var (
dockerContainerRuntime = "docker"
defaultPodSandboxImage = defaultPodSandboxImageName +
":" + defaultPodSandboxImageVersion
)

// NewContainerRuntimeOptions will create a new ContainerRuntimeOptions with
// default values.
func NewContainerRuntimeOptions() *config.ContainerRuntimeOptions {
dockerEndpoint := ""
if runtime.GOOS != "windows" {
dockerEndpoint = "unix:///var/run/docker.sock"
}

return &config.ContainerRuntimeOptions{
DockerEndpoint: dockerEndpoint,
DockershimRootDirectory: "/var/lib/dockershim",
PodSandboxImage: defaultPodSandboxImage,
ImagePullProgressDeadline: metav1.Duration{Duration: 1 * time.Minute},
}
}