aboutsummaryrefslogtreecommitdiff
path: root/vendor/k8s.io/kubernetes/pkg/kubelet/container
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/k8s.io/kubernetes/pkg/kubelet/container')
-rw-r--r--vendor/k8s.io/kubernetes/pkg/kubelet/container/container_gc.go5
-rw-r--r--vendor/k8s.io/kubernetes/pkg/kubelet/container/container_reference_manager.go4
-rw-r--r--vendor/k8s.io/kubernetes/pkg/kubelet/container/helpers.go24
-rw-r--r--vendor/k8s.io/kubernetes/pkg/kubelet/container/ref.go8
-rw-r--r--vendor/k8s.io/kubernetes/pkg/kubelet/container/runtime.go36
5 files changed, 44 insertions, 33 deletions
diff --git a/vendor/k8s.io/kubernetes/pkg/kubelet/container/container_gc.go b/vendor/k8s.io/kubernetes/pkg/kubelet/container/container_gc.go
index be2fac4b9..72fa4bd72 100644
--- a/vendor/k8s.io/kubernetes/pkg/kubelet/container/container_gc.go
+++ b/vendor/k8s.io/kubernetes/pkg/kubelet/container/container_gc.go
@@ -19,6 +19,8 @@ package container
import (
"fmt"
"time"
+
+ "github.com/golang/glog"
)
// Specified a policy for garbage collecting containers.
@@ -58,7 +60,7 @@ type realContainerGC struct {
// Policy for garbage collection.
policy ContainerGCPolicy
- // sourcesReadyProvider provides the readyness of kubelet configuration sources.
+ // sourcesReadyProvider provides the readiness of kubelet configuration sources.
sourcesReadyProvider SourcesReadyProvider
}
@@ -80,5 +82,6 @@ func (cgc *realContainerGC) GarbageCollect() error {
}
func (cgc *realContainerGC) DeleteAllUnusedContainers() error {
+ glog.Infof("attempting to delete unused containers")
return cgc.runtime.GarbageCollect(cgc.policy, cgc.sourcesReadyProvider.AllReady(), true)
}
diff --git a/vendor/k8s.io/kubernetes/pkg/kubelet/container/container_reference_manager.go b/vendor/k8s.io/kubernetes/pkg/kubelet/container/container_reference_manager.go
index 8383e77d9..d41d05a93 100644
--- a/vendor/k8s.io/kubernetes/pkg/kubelet/container/container_reference_manager.go
+++ b/vendor/k8s.io/kubernetes/pkg/kubelet/container/container_reference_manager.go
@@ -19,7 +19,7 @@ package container
import (
"sync"
- "k8s.io/kubernetes/pkg/api/v1"
+ "k8s.io/api/core/v1"
)
// RefManager manages the references for the containers.
@@ -38,7 +38,6 @@ func NewRefManager() *RefManager {
}
// SetRef stores a reference to a pod's container, associating it with the given container ID.
-// TODO: move this to client-go v1.ObjectReference
func (c *RefManager) SetRef(id ContainerID, ref *v1.ObjectReference) {
c.Lock()
defer c.Unlock()
@@ -53,7 +52,6 @@ func (c *RefManager) ClearRef(id ContainerID) {
}
// GetRef returns the container reference of the given ID, or (nil, false) if none is stored.
-// TODO: move this to client-go v1.ObjectReference
func (c *RefManager) GetRef(id ContainerID) (ref *v1.ObjectReference, ok bool) {
c.RLock()
defer c.RUnlock()
diff --git a/vendor/k8s.io/kubernetes/pkg/kubelet/container/helpers.go b/vendor/k8s.io/kubernetes/pkg/kubelet/container/helpers.go
index 7930fed55..2320a192b 100644
--- a/vendor/k8s.io/kubernetes/pkg/kubelet/container/helpers.go
+++ b/vendor/k8s.io/kubernetes/pkg/kubelet/container/helpers.go
@@ -26,14 +26,12 @@ import (
"github.com/golang/glog"
+ "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
- clientv1 "k8s.io/client-go/pkg/api/v1"
"k8s.io/client-go/tools/record"
- "k8s.io/kubernetes/pkg/api/v1"
- runtimeapi "k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1/runtime"
- "k8s.io/kubernetes/pkg/kubelet/events"
+ runtimeapi "k8s.io/kubernetes/pkg/kubelet/apis/cri/runtime/v1alpha2"
"k8s.io/kubernetes/pkg/kubelet/util/format"
"k8s.io/kubernetes/pkg/kubelet/util/ioutils"
hashutil "k8s.io/kubernetes/pkg/util/hash"
@@ -48,9 +46,9 @@ type HandlerRunner interface {
// RuntimeHelper wraps kubelet to make container runtime
// able to get necessary informations like the RunContainerOptions, DNS settings, Host IP.
type RuntimeHelper interface {
- GenerateRunContainerOptions(pod *v1.Pod, container *v1.Container, podIP string) (contOpts *RunContainerOptions, useClusterFirstPolicy bool, err error)
- GetClusterDNS(pod *v1.Pod) (dnsServers []string, dnsSearches []string, useClusterFirstPolicy bool, err error)
- // GetPodCgroupParent returns the the CgroupName identifer, and its literal cgroupfs form on the host
+ GenerateRunContainerOptions(pod *v1.Pod, container *v1.Container, podIP string) (contOpts *RunContainerOptions, err error)
+ GetPodDNS(pod *v1.Pod) (dnsConfig *runtimeapi.DNSConfig, err error)
+ // GetPodCgroupParent returns the CgroupName identifier, and its literal cgroupfs form on the host
// of a pod.
GetPodCgroupParent(pod *v1.Pod) string
GetPodDir(podUID types.UID) string
@@ -176,19 +174,13 @@ type innerEventRecorder struct {
recorder record.EventRecorder
}
-func (irecorder *innerEventRecorder) shouldRecordEvent(object runtime.Object) (*clientv1.ObjectReference, bool) {
+func (irecorder *innerEventRecorder) shouldRecordEvent(object runtime.Object) (*v1.ObjectReference, bool) {
if object == nil {
return nil, false
}
- if ref, ok := object.(*clientv1.ObjectReference); ok {
- if !strings.HasPrefix(ref.FieldPath, ImplicitContainerPrefix) {
- return ref, true
- }
- }
- // just in case we miss a spot, be sure that we still log something
if ref, ok := object.(*v1.ObjectReference); ok {
if !strings.HasPrefix(ref.FieldPath, ImplicitContainerPrefix) {
- return events.ToObjectReference(ref), true
+ return ref, true
}
}
return nil, false
@@ -310,7 +302,7 @@ func GetContainerSpec(pod *v1.Pod, containerName string) *v1.Container {
// HasPrivilegedContainer returns true if any of the containers in the pod are privileged.
func HasPrivilegedContainer(pod *v1.Pod) bool {
- for _, c := range pod.Spec.Containers {
+ for _, c := range append(pod.Spec.Containers, pod.Spec.InitContainers...) {
if c.SecurityContext != nil &&
c.SecurityContext.Privileged != nil &&
*c.SecurityContext.Privileged {
diff --git a/vendor/k8s.io/kubernetes/pkg/kubelet/container/ref.go b/vendor/k8s.io/kubernetes/pkg/kubelet/container/ref.go
index 0251b8134..f61c0fc4a 100644
--- a/vendor/k8s.io/kubernetes/pkg/kubelet/container/ref.go
+++ b/vendor/k8s.io/kubernetes/pkg/kubelet/container/ref.go
@@ -19,9 +19,9 @@ package container
import (
"fmt"
- "k8s.io/kubernetes/pkg/api"
- "k8s.io/kubernetes/pkg/api/v1"
- "k8s.io/kubernetes/pkg/api/v1/ref"
+ "k8s.io/api/core/v1"
+ ref "k8s.io/client-go/tools/reference"
+ "k8s.io/kubernetes/pkg/api/legacyscheme"
)
var ImplicitContainerPrefix string = "implicitly required container "
@@ -39,7 +39,7 @@ func GenerateContainerRef(pod *v1.Pod, container *v1.Container) (*v1.ObjectRefer
// start (like the pod infra container). This is not a good way, ugh.
fieldPath = ImplicitContainerPrefix + container.Name
}
- ref, err := ref.GetPartialReference(api.Scheme, pod, fieldPath)
+ ref, err := ref.GetPartialReference(legacyscheme.Scheme, pod, fieldPath)
if err != nil {
return nil, err
}
diff --git a/vendor/k8s.io/kubernetes/pkg/kubelet/container/runtime.go b/vendor/k8s.io/kubernetes/pkg/kubelet/container/runtime.go
index c3403ad57..56aeaf813 100644
--- a/vendor/k8s.io/kubernetes/pkg/kubelet/container/runtime.go
+++ b/vendor/k8s.io/kubernetes/pkg/kubelet/container/runtime.go
@@ -25,11 +25,11 @@ import (
"time"
"github.com/golang/glog"
+ "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/tools/remotecommand"
"k8s.io/client-go/util/flowcontrol"
- "k8s.io/kubernetes/pkg/api/v1"
- runtimeapi "k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1/runtime"
+ runtimeapi "k8s.io/kubernetes/pkg/kubelet/apis/cri/runtime/v1alpha2"
"k8s.io/kubernetes/pkg/volume"
)
@@ -127,9 +127,8 @@ type Runtime interface {
// DirectStreamingRuntime is the interface implemented by runtimes for which the streaming calls
// (exec/attach/port-forward) should be served directly by the Kubelet.
type DirectStreamingRuntime interface {
- // Runs the command in the container of the specified pod using nsenter.
- // Attaches the processes stdin, stdout, and stderr. Optionally uses a
- // tty.
+ // Runs the command in the container of the specified pod. Attaches
+ // the processes stdin, stdout, and stderr. Optionally uses a tty.
ExecInContainer(containerID ContainerID, cmd []string, stdin io.Reader, stdout, stderr io.WriteCloser, tty bool, resize <-chan remotecommand.TerminalSize, timeout time.Duration) error
// Forward the specified port from the specified pod to the stream.
PortForward(pod *Pod, port int32, stream io.ReadWriteCloser) error
@@ -266,6 +265,13 @@ const (
ContainerStateUnknown ContainerState = "unknown"
)
+type ContainerType string
+
+const (
+ ContainerTypeInit ContainerType = "INIT"
+ ContainerTypeRegular ContainerType = "REGULAR"
+)
+
// Container provides the runtime information for a container, such as ID, hash,
// state of the container.
type Container struct {
@@ -376,6 +382,11 @@ type EnvVar struct {
Value string
}
+type Annotation struct {
+ Name string
+ Value string
+}
+
type Mount struct {
// Name of the volume mount.
// TODO(yifan): Remove this field, as this is not representing the unique name of the mount,
@@ -389,6 +400,8 @@ type Mount struct {
ReadOnly bool
// Whether the mount needs SELinux relabeling
SELinuxRelabel bool
+ // Requested propagation mode
+ Propagation runtimeapi.MountPropagation
}
type PortMapping struct {
@@ -423,14 +436,14 @@ type RunContainerOptions struct {
Devices []DeviceInfo
// The port mappings for the containers.
PortMappings []PortMapping
+ // The annotations for the container
+ // These annotations are generated by other components (i.e.,
+ // not users). Currently, only device plugins populate the annotations.
+ Annotations []Annotation
// If the container has specified the TerminationMessagePath, then
// this directory will be used to create and mount the log file to
// container.TerminationMessagePath
PodContainerDir string
- // The list of DNS servers for the container to use.
- DNS []string
- // The list of DNS search domains.
- DNSSearch []string
// The parent cgroup to pass to Docker
CgroupParent string
// The type of container rootfs
@@ -449,9 +462,14 @@ type RunContainerOptions struct {
type VolumeInfo struct {
// Mounter is the volume's mounter
Mounter volume.Mounter
+ // BlockVolumeMapper is the Block volume's mapper
+ BlockVolumeMapper volume.BlockVolumeMapper
// SELinuxLabeled indicates whether this volume has had the
// pod's SELinux label applied to it or not
SELinuxLabeled bool
+ // Whether the volume permission is set to read-only or not
+ // This value is passed from volume.spec
+ ReadOnly bool
}
type VolumeMap map[string]VolumeInfo