mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 13:37:30 +00:00
IP: Shared IPC.
This commit is contained in:
parent
6410f37a32
commit
b6a0ff1003
@ -50,7 +50,7 @@ var (
|
|||||||
address = util.IP(net.ParseIP("127.0.0.1"))
|
address = util.IP(net.ParseIP("127.0.0.1"))
|
||||||
port = flag.Uint("port", ports.KubeletPort, "The port for the info server to serve on")
|
port = flag.Uint("port", ports.KubeletPort, "The port for the info server to serve on")
|
||||||
hostnameOverride = flag.String("hostname_override", "", "If non-empty, will use this string as identification instead of the actual hostname.")
|
hostnameOverride = flag.String("hostname_override", "", "If non-empty, will use this string as identification instead of the actual hostname.")
|
||||||
networkContainerImage = flag.String("network_container_image", kubelet.NetworkContainerImage, "The image that network containers in each pod will use.")
|
podInfraContainerImage = flag.String("pod_infra_container_image", kubelet.PodInfraContainerImage, "The image whose network/ipc namespaces containers in each pod will use.")
|
||||||
dockerEndpoint = flag.String("docker_endpoint", "", "If non-empty, use this for the docker endpoint to communicate with")
|
dockerEndpoint = flag.String("docker_endpoint", "", "If non-empty, use this for the docker endpoint to communicate with")
|
||||||
etcdServerList util.StringList
|
etcdServerList util.StringList
|
||||||
etcdConfigFile = flag.String("etcd_config", "", "The config file for the etcd client. Mutually exclusive with -etcd_servers")
|
etcdConfigFile = flag.String("etcd_config", "", "The config file for the etcd client. Mutually exclusive with -etcd_servers")
|
||||||
@ -136,7 +136,7 @@ func main() {
|
|||||||
ManifestURL: *manifestURL,
|
ManifestURL: *manifestURL,
|
||||||
FileCheckFrequency: *fileCheckFrequency,
|
FileCheckFrequency: *fileCheckFrequency,
|
||||||
HttpCheckFrequency: *httpCheckFrequency,
|
HttpCheckFrequency: *httpCheckFrequency,
|
||||||
NetworkContainerImage: *networkContainerImage,
|
PodInfraContainerImage: *podInfraContainerImage,
|
||||||
SyncFrequency: *syncFrequency,
|
SyncFrequency: *syncFrequency,
|
||||||
RegistryPullQPS: *registryPullQPS,
|
RegistryPullQPS: *registryPullQPS,
|
||||||
RegistryBurst: *registryBurst,
|
RegistryBurst: *registryBurst,
|
||||||
|
@ -37,6 +37,10 @@ import (
|
|||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
PodInfraContainerName = "POD" // This should match the constant defined in kubelet
|
||||||
|
)
|
||||||
|
|
||||||
// DockerInterface is an abstract interface for testability. It abstracts the interface of docker.Client.
|
// DockerInterface is an abstract interface for testability. It abstracts the interface of docker.Client.
|
||||||
type DockerInterface interface {
|
type DockerInterface interface {
|
||||||
ListContainers(options docker.ListContainersOptions) ([]docker.APIContainers, error)
|
ListContainers(options docker.ListContainersOptions) ([]docker.APIContainers, error)
|
||||||
@ -372,8 +376,8 @@ var (
|
|||||||
// ErrNoContainersInPod is returned when there are no containers for a given pod
|
// ErrNoContainersInPod is returned when there are no containers for a given pod
|
||||||
ErrNoContainersInPod = errors.New("no containers exist for this pod")
|
ErrNoContainersInPod = errors.New("no containers exist for this pod")
|
||||||
|
|
||||||
// ErrNoNetworkContainerInPod is returned when there is no network container for a given pod
|
// ErrNoPodInfraContainerInPod is returned when there is no pod infra container for a given pod
|
||||||
ErrNoNetworkContainerInPod = errors.New("No network container exists for this pod")
|
ErrNoPodInfraContainerInPod = errors.New("No pod infra container exists for this pod")
|
||||||
|
|
||||||
// ErrContainerCannotRun is returned when a container is created, but cannot run properly
|
// ErrContainerCannotRun is returned when a container is created, but cannot run properly
|
||||||
ErrContainerCannotRun = errors.New("Container cannot run")
|
ErrContainerCannotRun = errors.New("Container cannot run")
|
||||||
@ -401,7 +405,7 @@ func inspectContainer(client DockerInterface, dockerID, containerName, tPath str
|
|||||||
containerStatus.State.Running = &api.ContainerStateRunning{
|
containerStatus.State.Running = &api.ContainerStateRunning{
|
||||||
StartedAt: util.NewTime(inspectResult.State.StartedAt),
|
StartedAt: util.NewTime(inspectResult.State.StartedAt),
|
||||||
}
|
}
|
||||||
if containerName == "net" && inspectResult.NetworkSettings != nil {
|
if containerName == PodInfraContainerName && inspectResult.NetworkSettings != nil {
|
||||||
containerStatus.PodIP = inspectResult.NetworkSettings.IPAddress
|
containerStatus.PodIP = inspectResult.NetworkSettings.IPAddress
|
||||||
}
|
}
|
||||||
waiting = false
|
waiting = false
|
||||||
@ -454,7 +458,7 @@ func GetDockerPodInfo(client DockerInterface, manifest api.PodSpec, podFullName
|
|||||||
for _, container := range manifest.Containers {
|
for _, container := range manifest.Containers {
|
||||||
expectedContainers[container.Name] = container
|
expectedContainers[container.Name] = container
|
||||||
}
|
}
|
||||||
expectedContainers["net"] = api.Container{}
|
expectedContainers[PodInfraContainerName] = api.Container{}
|
||||||
|
|
||||||
containers, err := client.ListContainers(docker.ListContainersOptions{All: true})
|
containers, err := client.ListContainers(docker.ListContainersOptions{All: true})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -498,9 +502,9 @@ func GetDockerPodInfo(client DockerInterface, manifest api.PodSpec, podFullName
|
|||||||
return nil, ErrNoContainersInPod
|
return nil, ErrNoContainersInPod
|
||||||
}
|
}
|
||||||
|
|
||||||
// First make sure we are not missing network container
|
// First make sure we are not missing pod infra container
|
||||||
if _, found := info["net"]; !found {
|
if _, found := info[PodInfraContainerName]; !found {
|
||||||
return nil, ErrNoNetworkContainerInPod
|
return nil, ErrNoPodInfraContainerInPod
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(info) < (len(manifest.Containers) + 1) {
|
if len(info) < (len(manifest.Containers) + 1) {
|
||||||
|
@ -24,6 +24,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/dockertools"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
@ -77,7 +78,7 @@ func (h *httpActionHandler) Run(podFullName string, uid types.UID, container *ap
|
|||||||
glog.Errorf("unable to get pod info, event handlers may be invalid.")
|
glog.Errorf("unable to get pod info, event handlers may be invalid.")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
netInfo, found := status.Info[networkContainerName]
|
netInfo, found := status.Info[dockertools.PodInfraContainerName]
|
||||||
if found {
|
if found {
|
||||||
host = netInfo.PodIP
|
host = netInfo.PodIP
|
||||||
} else {
|
} else {
|
||||||
|
@ -72,7 +72,7 @@ func NewMainKubelet(
|
|||||||
etcdClient tools.EtcdClient,
|
etcdClient tools.EtcdClient,
|
||||||
kubeClient *client.Client,
|
kubeClient *client.Client,
|
||||||
rootDirectory string,
|
rootDirectory string,
|
||||||
networkContainerImage string,
|
podInfraContainerImage string,
|
||||||
resyncInterval time.Duration,
|
resyncInterval time.Duration,
|
||||||
pullQPS float32,
|
pullQPS float32,
|
||||||
pullBurst int,
|
pullBurst int,
|
||||||
@ -106,7 +106,7 @@ func NewMainKubelet(
|
|||||||
kubeClient: kubeClient,
|
kubeClient: kubeClient,
|
||||||
rootDirectory: rootDirectory,
|
rootDirectory: rootDirectory,
|
||||||
resyncInterval: resyncInterval,
|
resyncInterval: resyncInterval,
|
||||||
networkContainerImage: networkContainerImage,
|
podInfraContainerImage: podInfraContainerImage,
|
||||||
podWorkers: newPodWorkers(),
|
podWorkers: newPodWorkers(),
|
||||||
dockerIDToRef: map[dockertools.DockerID]*api.ObjectReference{},
|
dockerIDToRef: map[dockertools.DockerID]*api.ObjectReference{},
|
||||||
runner: dockertools.NewDockerContainerCommandRunner(dockerClient),
|
runner: dockertools.NewDockerContainerCommandRunner(dockerClient),
|
||||||
@ -142,15 +142,15 @@ type serviceLister interface {
|
|||||||
|
|
||||||
// Kubelet is the main kubelet implementation.
|
// Kubelet is the main kubelet implementation.
|
||||||
type Kubelet struct {
|
type Kubelet struct {
|
||||||
hostname string
|
hostname string
|
||||||
dockerClient dockertools.DockerInterface
|
dockerClient dockertools.DockerInterface
|
||||||
kubeClient *client.Client
|
kubeClient *client.Client
|
||||||
rootDirectory string
|
rootDirectory string
|
||||||
networkContainerImage string
|
podInfraContainerImage string
|
||||||
podWorkers *podWorkers
|
podWorkers *podWorkers
|
||||||
resyncInterval time.Duration
|
resyncInterval time.Duration
|
||||||
pods []api.BoundPod
|
pods []api.BoundPod
|
||||||
sourceReady SourceReadyFn
|
sourceReady SourceReadyFn
|
||||||
|
|
||||||
// Needed to report events for containers belonging to deleted/modified pods.
|
// Needed to report events for containers belonging to deleted/modified pods.
|
||||||
// Tracks references for reporting events
|
// Tracks references for reporting events
|
||||||
@ -583,7 +583,7 @@ func containerRef(pod *api.BoundPod, container *api.Container) (*api.ObjectRefer
|
|||||||
fieldPath, err := fieldPath(pod, container)
|
fieldPath, err := fieldPath(pod, container)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// TODO: figure out intelligent way to refer to containers that we implicitly
|
// TODO: figure out intelligent way to refer to containers that we implicitly
|
||||||
// start (like the network container). This is not a good way, ugh.
|
// start (like the pod infra container). This is not a good way, ugh.
|
||||||
fieldPath = "implicitly required container " + container.Name
|
fieldPath = "implicitly required container " + container.Name
|
||||||
}
|
}
|
||||||
ref, err := api.GetPartialReference(pod, fieldPath)
|
ref, err := api.GetPartialReference(pod, fieldPath)
|
||||||
@ -619,7 +619,7 @@ func (kl *Kubelet) getRef(id dockertools.DockerID) (ref *api.ObjectReference, ok
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Run a single container from a pod. Returns the docker container ID
|
// Run a single container from a pod. Returns the docker container ID
|
||||||
func (kl *Kubelet) runContainer(pod *api.BoundPod, container *api.Container, podVolumes volumeMap, netMode string) (id dockertools.DockerID, err error) {
|
func (kl *Kubelet) runContainer(pod *api.BoundPod, container *api.Container, podVolumes volumeMap, netMode, ipcMode string) (id dockertools.DockerID, err error) {
|
||||||
ref, err := containerRef(pod, container)
|
ref, err := containerRef(pod, container)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("Couldn't make a ref to pod %v, container %v: '%v'", pod.Name, container.Name, err)
|
glog.Errorf("Couldn't make a ref to pod %v, container %v: '%v'", pod.Name, container.Name, err)
|
||||||
@ -684,6 +684,7 @@ func (kl *Kubelet) runContainer(pod *api.BoundPod, container *api.Container, pod
|
|||||||
PortBindings: portBindings,
|
PortBindings: portBindings,
|
||||||
Binds: binds,
|
Binds: binds,
|
||||||
NetworkMode: netMode,
|
NetworkMode: netMode,
|
||||||
|
IpcMode: ipcMode,
|
||||||
Privileged: privileged,
|
Privileged: privileged,
|
||||||
}
|
}
|
||||||
if pod.Spec.DNSPolicy == api.DNSClusterFirst {
|
if pod.Spec.DNSPolicy == api.DNSClusterFirst {
|
||||||
@ -878,21 +879,20 @@ func (kl *Kubelet) killContainerByID(ID, name string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
networkContainerName = "net"
|
PodInfraContainerImage = "kubernetes/pause:latest"
|
||||||
NetworkContainerImage = "kubernetes/pause:latest"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// createNetworkContainer starts the network container for a pod. Returns the docker container ID of the newly created container.
|
// createPodInfraContainer starts the pod infra container for a pod. Returns the docker container ID of the newly created container.
|
||||||
func (kl *Kubelet) createNetworkContainer(pod *api.BoundPod) (dockertools.DockerID, error) {
|
func (kl *Kubelet) createPodInfraContainer(pod *api.BoundPod) (dockertools.DockerID, error) {
|
||||||
var ports []api.Port
|
var ports []api.Port
|
||||||
// Docker only exports ports from the network container. Let's
|
// Docker only exports ports from the pod infra container. Let's
|
||||||
// collect all of the relevant ports and export them.
|
// collect all of the relevant ports and export them.
|
||||||
for _, container := range pod.Spec.Containers {
|
for _, container := range pod.Spec.Containers {
|
||||||
ports = append(ports, container.Ports...)
|
ports = append(ports, container.Ports...)
|
||||||
}
|
}
|
||||||
container := &api.Container{
|
container := &api.Container{
|
||||||
Name: networkContainerName,
|
Name: dockertools.PodInfraContainerName,
|
||||||
Image: kl.networkContainerImage,
|
Image: kl.podInfraContainerImage,
|
||||||
Ports: ports,
|
Ports: ports,
|
||||||
}
|
}
|
||||||
ref, err := containerRef(pod, container)
|
ref, err := containerRef(pod, container)
|
||||||
@ -915,7 +915,7 @@ func (kl *Kubelet) createNetworkContainer(pod *api.BoundPod) (dockertools.Docker
|
|||||||
if ref != nil {
|
if ref != nil {
|
||||||
record.Eventf(ref, "pulled", "Successfully pulled image %q", container.Image)
|
record.Eventf(ref, "pulled", "Successfully pulled image %q", container.Image)
|
||||||
}
|
}
|
||||||
return kl.runContainer(pod, container, nil, "")
|
return kl.runContainer(pod, container, nil, "", "")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (kl *Kubelet) pullImage(img string, ref *api.ObjectReference) error {
|
func (kl *Kubelet) pullImage(img string, ref *api.ObjectReference) error {
|
||||||
@ -987,19 +987,19 @@ func (kl *Kubelet) syncPod(pod *api.BoundPod, dockerContainers dockertools.Docke
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure we have a network container
|
// Make sure we have a pod infra container
|
||||||
var netID dockertools.DockerID
|
var podInfraContainerID dockertools.DockerID
|
||||||
if netDockerContainer, found, _ := dockerContainers.FindPodContainer(podFullName, uid, networkContainerName); found {
|
if podInfraDockerContainer, found, _ := dockerContainers.FindPodContainer(podFullName, uid, dockertools.PodInfraContainerName); found {
|
||||||
netID = dockertools.DockerID(netDockerContainer.ID)
|
podInfraContainerID = dockertools.DockerID(podInfraDockerContainer.ID)
|
||||||
} else {
|
} else {
|
||||||
glog.V(2).Infof("Network container doesn't exist for pod %q, killing and re-creating the pod", podFullName)
|
glog.V(2).Infof("Network container doesn't exist for pod %q, killing and re-creating the pod", podFullName)
|
||||||
count, err := kl.killContainersInPod(pod, dockerContainers)
|
count, err := kl.killContainersInPod(pod, dockerContainers)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
netID, err = kl.createNetworkContainer(pod)
|
podInfraContainerID, err = kl.createPodInfraContainer(pod)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("Failed to introspect network container: %v; Skipping pod %q", err, podFullName)
|
glog.Errorf("Failed to introspect pod infra container: %v; Skipping pod %q", err, podFullName)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if count > 0 {
|
if count > 0 {
|
||||||
@ -1011,7 +1011,7 @@ func (kl *Kubelet) syncPod(pod *api.BoundPod, dockerContainers dockertools.Docke
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
containersToKeep[netID] = empty{}
|
containersToKeep[podInfraContainerID] = empty{}
|
||||||
|
|
||||||
podVolumes, err := kl.mountExternalVolumes(pod)
|
podVolumes, err := kl.mountExternalVolumes(pod)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -1023,7 +1023,7 @@ func (kl *Kubelet) syncPod(pod *api.BoundPod, dockerContainers dockertools.Docke
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("Unable to get pod with name %q and uid %q info, health checks may be invalid", podFullName, uid)
|
glog.Errorf("Unable to get pod with name %q and uid %q info, health checks may be invalid", podFullName, uid)
|
||||||
}
|
}
|
||||||
netInfo, found := podStatus.Info[networkContainerName]
|
netInfo, found := podStatus.Info[dockertools.PodInfraContainerName]
|
||||||
if found {
|
if found {
|
||||||
podStatus.PodIP = netInfo.PodIP
|
podStatus.PodIP = netInfo.PodIP
|
||||||
}
|
}
|
||||||
@ -1058,10 +1058,10 @@ func (kl *Kubelet) syncPod(pod *api.BoundPod, dockerContainers dockertools.Docke
|
|||||||
}
|
}
|
||||||
killedContainers[containerID] = empty{}
|
killedContainers[containerID] = empty{}
|
||||||
|
|
||||||
// Also kill associated network container
|
// Also kill associated pod infra container
|
||||||
if netContainer, found, _ := dockerContainers.FindPodContainer(podFullName, uid, networkContainerName); found {
|
if podInfraContainer, found, _ := dockerContainers.FindPodContainer(podFullName, uid, dockertools.PodInfraContainerName); found {
|
||||||
if err := kl.killContainer(netContainer); err != nil {
|
if err := kl.killContainer(podInfraContainer); err != nil {
|
||||||
glog.V(1).Infof("Failed to kill network container %q: %v", netContainer.ID, err)
|
glog.V(1).Infof("Failed to kill pod infra container %q: %v", podInfraContainer.ID, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1112,7 +1112,8 @@ func (kl *Kubelet) syncPod(pod *api.BoundPod, dockerContainers dockertools.Docke
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO(dawnchen): Check RestartPolicy.DelaySeconds before restart a container
|
// TODO(dawnchen): Check RestartPolicy.DelaySeconds before restart a container
|
||||||
containerID, err := kl.runContainer(pod, &container, podVolumes, "container:"+string(netID))
|
namespaceMode := fmt.Sprintf("container:%v", podInfraContainerID)
|
||||||
|
containerID, err := kl.runContainer(pod, &container, podVolumes, namespaceMode, namespaceMode)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// TODO(bburns) : Perhaps blacklist a container after N failures?
|
// TODO(bburns) : Perhaps blacklist a container after N failures?
|
||||||
glog.Errorf("Error running pod %q container %q: %v", podFullName, container.Name, err)
|
glog.Errorf("Error running pod %q container %q: %v", podFullName, container.Name, err)
|
||||||
@ -1222,7 +1223,7 @@ func (kl *Kubelet) SyncPods(pods []api.BoundPod) error {
|
|||||||
desiredPods[uid] = empty{}
|
desiredPods[uid] = empty{}
|
||||||
|
|
||||||
// Add all containers (including net) to the map.
|
// Add all containers (including net) to the map.
|
||||||
desiredContainers[podContainer{podFullName, uid, networkContainerName}] = empty{}
|
desiredContainers[podContainer{podFullName, uid, dockertools.PodInfraContainerName}] = empty{}
|
||||||
for _, cont := range pod.Spec.Containers {
|
for _, cont := range pod.Spec.Containers {
|
||||||
desiredContainers[podContainer{podFullName, uid, cont.Name}] = empty{}
|
desiredContainers[podContainer{podFullName, uid, cont.Name}] = empty{}
|
||||||
}
|
}
|
||||||
|
@ -336,8 +336,8 @@ func TestSyncPodsDoesNothing(t *testing.T) {
|
|||||||
ID: "1234",
|
ID: "1234",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// network container
|
// pod infra container
|
||||||
Names: []string{"/k8s_net_foo.new.test_12345678_0"},
|
Names: []string{"/k8s_POD_foo.new.test_12345678_0"},
|
||||||
ID: "9876",
|
ID: "9876",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -426,7 +426,7 @@ func matchString(t *testing.T, pattern, str string) bool {
|
|||||||
|
|
||||||
func TestSyncPodsCreatesNetAndContainer(t *testing.T) {
|
func TestSyncPodsCreatesNetAndContainer(t *testing.T) {
|
||||||
kubelet, fakeDocker := newTestKubelet(t)
|
kubelet, fakeDocker := newTestKubelet(t)
|
||||||
kubelet.networkContainerImage = "custom_image_name"
|
kubelet.podInfraContainerImage = "custom_image_name"
|
||||||
fakeDocker.ContainerList = []docker.APIContainers{}
|
fakeDocker.ContainerList = []docker.APIContainers{}
|
||||||
err := kubelet.SyncPods([]api.BoundPod{
|
err := kubelet.SyncPods([]api.BoundPod{
|
||||||
{
|
{
|
||||||
@ -455,7 +455,7 @@ func TestSyncPodsCreatesNetAndContainer(t *testing.T) {
|
|||||||
|
|
||||||
found := false
|
found := false
|
||||||
for _, c := range fakeDocker.ContainerList {
|
for _, c := range fakeDocker.ContainerList {
|
||||||
if c.Image == "custom_image_name" && strings.HasPrefix(c.Names[0], "/k8s_net") {
|
if c.Image == "custom_image_name" && strings.HasPrefix(c.Names[0], "/k8s_POD") {
|
||||||
found = true
|
found = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -464,7 +464,7 @@ func TestSyncPodsCreatesNetAndContainer(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(fakeDocker.Created) != 2 ||
|
if len(fakeDocker.Created) != 2 ||
|
||||||
!matchString(t, "k8s_net\\.[a-f0-9]+_foo.new.test_", fakeDocker.Created[0]) ||
|
!matchString(t, "k8s_POD\\.[a-f0-9]+_foo.new.test_", fakeDocker.Created[0]) ||
|
||||||
!matchString(t, "k8s_bar\\.[a-f0-9]+_foo.new.test_", fakeDocker.Created[1]) {
|
!matchString(t, "k8s_bar\\.[a-f0-9]+_foo.new.test_", fakeDocker.Created[1]) {
|
||||||
t.Errorf("Unexpected containers created %v", fakeDocker.Created)
|
t.Errorf("Unexpected containers created %v", fakeDocker.Created)
|
||||||
}
|
}
|
||||||
@ -475,7 +475,7 @@ func TestSyncPodsCreatesNetAndContainerPullsImage(t *testing.T) {
|
|||||||
kubelet, fakeDocker := newTestKubelet(t)
|
kubelet, fakeDocker := newTestKubelet(t)
|
||||||
puller := kubelet.dockerPuller.(*dockertools.FakeDockerPuller)
|
puller := kubelet.dockerPuller.(*dockertools.FakeDockerPuller)
|
||||||
puller.HasImages = []string{}
|
puller.HasImages = []string{}
|
||||||
kubelet.networkContainerImage = "custom_image_name"
|
kubelet.podInfraContainerImage = "custom_image_name"
|
||||||
fakeDocker.ContainerList = []docker.APIContainers{}
|
fakeDocker.ContainerList = []docker.APIContainers{}
|
||||||
err := kubelet.SyncPods([]api.BoundPod{
|
err := kubelet.SyncPods([]api.BoundPod{
|
||||||
{
|
{
|
||||||
@ -507,7 +507,7 @@ func TestSyncPodsCreatesNetAndContainerPullsImage(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(fakeDocker.Created) != 2 ||
|
if len(fakeDocker.Created) != 2 ||
|
||||||
!matchString(t, "k8s_net\\.[a-f0-9]+_foo.new.test_", fakeDocker.Created[0]) ||
|
!matchString(t, "k8s_POD\\.[a-f0-9]+_foo.new.test_", fakeDocker.Created[0]) ||
|
||||||
!matchString(t, "k8s_bar\\.[a-f0-9]+_foo.new.test_", fakeDocker.Created[1]) {
|
!matchString(t, "k8s_bar\\.[a-f0-9]+_foo.new.test_", fakeDocker.Created[1]) {
|
||||||
t.Errorf("Unexpected containers created %v", fakeDocker.Created)
|
t.Errorf("Unexpected containers created %v", fakeDocker.Created)
|
||||||
}
|
}
|
||||||
@ -518,8 +518,8 @@ func TestSyncPodsWithNetCreatesContainer(t *testing.T) {
|
|||||||
kubelet, fakeDocker := newTestKubelet(t)
|
kubelet, fakeDocker := newTestKubelet(t)
|
||||||
fakeDocker.ContainerList = []docker.APIContainers{
|
fakeDocker.ContainerList = []docker.APIContainers{
|
||||||
{
|
{
|
||||||
// network container
|
// pod infra container
|
||||||
Names: []string{"/k8s_net_foo.new.test_12345678_0"},
|
Names: []string{"/k8s_POD_foo.new.test_12345678_0"},
|
||||||
ID: "9876",
|
ID: "9876",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -560,8 +560,8 @@ func TestSyncPodsWithNetCreatesContainerCallsHandler(t *testing.T) {
|
|||||||
kubelet.httpClient = &fakeHttp
|
kubelet.httpClient = &fakeHttp
|
||||||
fakeDocker.ContainerList = []docker.APIContainers{
|
fakeDocker.ContainerList = []docker.APIContainers{
|
||||||
{
|
{
|
||||||
// network container
|
// pod infra container
|
||||||
Names: []string{"/k8s_net_foo.new.test_12345678_0"},
|
Names: []string{"/k8s_POD_foo.new.test_12345678_0"},
|
||||||
ID: "9876",
|
ID: "9876",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -666,8 +666,8 @@ func TestSyncPodsDeletesWhenSourcesAreReady(t *testing.T) {
|
|||||||
ID: "1234",
|
ID: "1234",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// network container
|
// pod infra container
|
||||||
Names: []string{"/k8s_net_foo.new.test_12345678_42"},
|
Names: []string{"/k8s_POD_foo.new.test_12345678_42"},
|
||||||
ID: "9876",
|
ID: "9876",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -714,8 +714,8 @@ func TestSyncPodsDeletesWhenContainerSourceReady(t *testing.T) {
|
|||||||
ID: "7492",
|
ID: "7492",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// network container
|
// pod infra container
|
||||||
Names: []string{"/k8s_net_boo.default.testSource_12345678_42"},
|
Names: []string{"/k8s_POD_boo.default.testSource_12345678_42"},
|
||||||
ID: "3542",
|
ID: "3542",
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -725,8 +725,8 @@ func TestSyncPodsDeletesWhenContainerSourceReady(t *testing.T) {
|
|||||||
ID: "1234",
|
ID: "1234",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// network container
|
// pod infra container
|
||||||
Names: []string{"/k8s_net_foo.new.otherSource_12345678_42"},
|
Names: []string{"/k8s_POD_foo.new.otherSource_12345678_42"},
|
||||||
ID: "9876",
|
ID: "9876",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -767,8 +767,8 @@ func TestSyncPodsDeletes(t *testing.T) {
|
|||||||
ID: "1234",
|
ID: "1234",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// network container
|
// pod infra container
|
||||||
Names: []string{"/k8s_net_foo.new.test_12345678_42"},
|
Names: []string{"/k8s_POD_foo.new.test_12345678_42"},
|
||||||
ID: "9876",
|
ID: "9876",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -805,8 +805,8 @@ func TestSyncPodDeletesDuplicate(t *testing.T) {
|
|||||||
ID: "1234",
|
ID: "1234",
|
||||||
},
|
},
|
||||||
"9876": &docker.APIContainers{
|
"9876": &docker.APIContainers{
|
||||||
// network container
|
// pod infra container
|
||||||
Names: []string{"/k8s_net_bar.new.test_12345678_2222"},
|
Names: []string{"/k8s_POD_bar.new.test_12345678_2222"},
|
||||||
ID: "9876",
|
ID: "9876",
|
||||||
},
|
},
|
||||||
"4567": &docker.APIContainers{
|
"4567": &docker.APIContainers{
|
||||||
@ -865,8 +865,8 @@ func TestSyncPodBadHash(t *testing.T) {
|
|||||||
ID: "1234",
|
ID: "1234",
|
||||||
},
|
},
|
||||||
"9876": &docker.APIContainers{
|
"9876": &docker.APIContainers{
|
||||||
// network container
|
// pod infra container
|
||||||
Names: []string{"/k8s_net_foo.new.test_12345678_42"},
|
Names: []string{"/k8s_POD_foo.new.test_12345678_42"},
|
||||||
ID: "9876",
|
ID: "9876",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -912,8 +912,8 @@ func TestSyncPodUnhealthy(t *testing.T) {
|
|||||||
ID: "1234",
|
ID: "1234",
|
||||||
},
|
},
|
||||||
"9876": &docker.APIContainers{
|
"9876": &docker.APIContainers{
|
||||||
// network container
|
// pod infra container
|
||||||
Names: []string{"/k8s_net_foo.new.test_12345678_42"},
|
Names: []string{"/k8s_POD_foo.new.test_12345678_42"},
|
||||||
ID: "9876",
|
ID: "9876",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -1559,8 +1559,8 @@ func TestSyncPodEventHandlerFails(t *testing.T) {
|
|||||||
}
|
}
|
||||||
dockerContainers := dockertools.DockerContainers{
|
dockerContainers := dockertools.DockerContainers{
|
||||||
"9876": &docker.APIContainers{
|
"9876": &docker.APIContainers{
|
||||||
// network container
|
// pod infra container
|
||||||
Names: []string{"/k8s_net_foo.new.test_12345678_42"},
|
Names: []string{"/k8s_POD_foo.new.test_12345678_42"},
|
||||||
ID: "9876",
|
ID: "9876",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -1607,33 +1607,33 @@ func TestKubeletGarbageCollection(t *testing.T) {
|
|||||||
{
|
{
|
||||||
containers: []docker.APIContainers{
|
containers: []docker.APIContainers{
|
||||||
{
|
{
|
||||||
// network container
|
// pod infra container
|
||||||
Names: []string{"/k8s_net_foo.new.test_.deadbeef_42"},
|
Names: []string{"/k8s_POD_foo.new.test_.deadbeef_42"},
|
||||||
ID: "1876",
|
ID: "1876",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// network container
|
// pod infra container
|
||||||
Names: []string{"/k8s_net_foo.new.test_.deadbeef_42"},
|
Names: []string{"/k8s_POD_foo.new.test_.deadbeef_42"},
|
||||||
ID: "2876",
|
ID: "2876",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// network container
|
// pod infra container
|
||||||
Names: []string{"/k8s_net_foo.new.test_.deadbeef_42"},
|
Names: []string{"/k8s_POD_foo.new.test_.deadbeef_42"},
|
||||||
ID: "3876",
|
ID: "3876",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// network container
|
// pod infra container
|
||||||
Names: []string{"/k8s_net_foo.new.test_.deadbeef_42"},
|
Names: []string{"/k8s_POD_foo.new.test_.deadbeef_42"},
|
||||||
ID: "4876",
|
ID: "4876",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// network container
|
// pod infra container
|
||||||
Names: []string{"/k8s_net_foo.new.test_.deadbeef_42"},
|
Names: []string{"/k8s_POD_foo.new.test_.deadbeef_42"},
|
||||||
ID: "5876",
|
ID: "5876",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// network container
|
// pod infra container
|
||||||
Names: []string{"/k8s_net_foo.new.test_.deadbeef_42"},
|
Names: []string{"/k8s_POD_foo.new.test_.deadbeef_42"},
|
||||||
ID: "6876",
|
ID: "6876",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -1651,38 +1651,38 @@ func TestKubeletGarbageCollection(t *testing.T) {
|
|||||||
{
|
{
|
||||||
containers: []docker.APIContainers{
|
containers: []docker.APIContainers{
|
||||||
{
|
{
|
||||||
// network container
|
// pod infra container
|
||||||
Names: []string{"/k8s_net_foo.new.test_.deadbeef_42"},
|
Names: []string{"/k8s_POD_foo.new.test_.deadbeef_42"},
|
||||||
ID: "1876",
|
ID: "1876",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// network container
|
// pod infra container
|
||||||
Names: []string{"/k8s_net_foo.new.test_.deadbeef_42"},
|
Names: []string{"/k8s_POD_foo.new.test_.deadbeef_42"},
|
||||||
ID: "2876",
|
ID: "2876",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// network container
|
// pod infra container
|
||||||
Names: []string{"/k8s_net_foo.new.test_.deadbeef_42"},
|
Names: []string{"/k8s_POD_foo.new.test_.deadbeef_42"},
|
||||||
ID: "3876",
|
ID: "3876",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// network container
|
// pod infra container
|
||||||
Names: []string{"/k8s_net_foo.new.test_.deadbeef_42"},
|
Names: []string{"/k8s_POD_foo.new.test_.deadbeef_42"},
|
||||||
ID: "4876",
|
ID: "4876",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// network container
|
// pod infra container
|
||||||
Names: []string{"/k8s_net_foo.new.test_.deadbeef_42"},
|
Names: []string{"/k8s_POD_foo.new.test_.deadbeef_42"},
|
||||||
ID: "5876",
|
ID: "5876",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// network container
|
// pod infra container
|
||||||
Names: []string{"/k8s_net_foo.new.test_.deadbeef_42"},
|
Names: []string{"/k8s_POD_foo.new.test_.deadbeef_42"},
|
||||||
ID: "6876",
|
ID: "6876",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// network container
|
// pod infra container
|
||||||
Names: []string{"/k8s_net_foo.new.test_.deadbeef_42"},
|
Names: []string{"/k8s_POD_foo.new.test_.deadbeef_42"},
|
||||||
ID: "7876",
|
ID: "7876",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -1707,8 +1707,8 @@ func TestKubeletGarbageCollection(t *testing.T) {
|
|||||||
{
|
{
|
||||||
containers: []docker.APIContainers{
|
containers: []docker.APIContainers{
|
||||||
{
|
{
|
||||||
// network container
|
// pod infra container
|
||||||
Names: []string{"/k8s_net_foo.new.test_.deadbeef_42"},
|
Names: []string{"/k8s_POD_foo.new.test_.deadbeef_42"},
|
||||||
ID: "1876",
|
ID: "1876",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -1896,7 +1896,7 @@ func TestSyncPodsWithPullPolicy(t *testing.T) {
|
|||||||
kubelet, fakeDocker := newTestKubelet(t)
|
kubelet, fakeDocker := newTestKubelet(t)
|
||||||
puller := kubelet.dockerPuller.(*dockertools.FakeDockerPuller)
|
puller := kubelet.dockerPuller.(*dockertools.FakeDockerPuller)
|
||||||
puller.HasImages = []string{"existing_one", "want:latest"}
|
puller.HasImages = []string{"existing_one", "want:latest"}
|
||||||
kubelet.networkContainerImage = "custom_image_name"
|
kubelet.podInfraContainerImage = "custom_image_name"
|
||||||
fakeDocker.ContainerList = []docker.APIContainers{}
|
fakeDocker.ContainerList = []docker.APIContainers{}
|
||||||
err := kubelet.SyncPods([]api.BoundPod{
|
err := kubelet.SyncPods([]api.BoundPod{
|
||||||
{
|
{
|
||||||
|
@ -153,13 +153,13 @@ func SimpleRunKubelet(client *client.Client,
|
|||||||
masterServiceNamespace string,
|
masterServiceNamespace string,
|
||||||
volumePlugins []volume.Plugin) {
|
volumePlugins []volume.Plugin) {
|
||||||
kcfg := KubeletConfig{
|
kcfg := KubeletConfig{
|
||||||
KubeClient: client,
|
KubeClient: client,
|
||||||
EtcdClient: etcdClient,
|
EtcdClient: etcdClient,
|
||||||
DockerClient: dockerClient,
|
DockerClient: dockerClient,
|
||||||
HostnameOverride: hostname,
|
HostnameOverride: hostname,
|
||||||
RootDirectory: rootDir,
|
RootDirectory: rootDir,
|
||||||
ManifestURL: manifestURL,
|
ManifestURL: manifestURL,
|
||||||
NetworkContainerImage: kubelet.NetworkContainerImage,
|
PodInfraContainerImage: kubelet.PodInfraContainerImage,
|
||||||
Port: port,
|
Port: port,
|
||||||
Address: util.IP(net.ParseIP(address)),
|
Address: util.IP(net.ParseIP(address)),
|
||||||
EnableServer: true,
|
EnableServer: true,
|
||||||
@ -256,7 +256,7 @@ type KubeletConfig struct {
|
|||||||
FileCheckFrequency time.Duration
|
FileCheckFrequency time.Duration
|
||||||
HttpCheckFrequency time.Duration
|
HttpCheckFrequency time.Duration
|
||||||
Hostname string
|
Hostname string
|
||||||
NetworkContainerImage string
|
PodInfraContainerImage string
|
||||||
SyncFrequency time.Duration
|
SyncFrequency time.Duration
|
||||||
RegistryPullQPS float64
|
RegistryPullQPS float64
|
||||||
RegistryBurst int
|
RegistryBurst int
|
||||||
@ -282,7 +282,7 @@ func createAndInitKubelet(kc *KubeletConfig, pc *config.PodConfig) (*kubelet.Kub
|
|||||||
kc.EtcdClient,
|
kc.EtcdClient,
|
||||||
kc.KubeClient,
|
kc.KubeClient,
|
||||||
kc.RootDirectory,
|
kc.RootDirectory,
|
||||||
kc.NetworkContainerImage,
|
kc.PodInfraContainerImage,
|
||||||
kc.SyncFrequency,
|
kc.SyncFrequency,
|
||||||
float32(kc.RegistryPullQPS),
|
float32(kc.RegistryPullQPS),
|
||||||
kc.RegistryBurst,
|
kc.RegistryBurst,
|
||||||
|
Loading…
Reference in New Issue
Block a user