Unverified Commit 24415254 authored by Alexander Brand's avatar Alexander Brand Committed by Paulo Pires

Changes to kubelet to support win containers

parent 09285864
...@@ -196,7 +196,7 @@ func SetDefaults_KubeletConfiguration(obj *KubeletConfiguration) { ...@@ -196,7 +196,7 @@ func SetDefaults_KubeletConfiguration(obj *KubeletConfiguration) {
if obj.DockerExecHandlerName == "" { if obj.DockerExecHandlerName == "" {
obj.DockerExecHandlerName = "native" obj.DockerExecHandlerName = "native"
} }
if obj.DockerEndpoint == "" { if obj.DockerEndpoint == "" && runtime.GOOS != "windows" {
obj.DockerEndpoint = "unix:///var/run/docker.sock" obj.DockerEndpoint = "unix:///var/run/docker.sock"
} }
if obj.EventBurst == 0 { if obj.EventBurst == 0 {
......
// +build !linux
/* /*
Copyright 2015 The Kubernetes Authors. Copyright 2015 The Kubernetes Authors.
...@@ -25,6 +23,8 @@ import ( ...@@ -25,6 +23,8 @@ import (
type containerManagerStub struct{} type containerManagerStub struct{}
var _ ContainerManager = &containerManagerStub{}
func (cm *containerManagerStub) Start(_ *api.Node) error { func (cm *containerManagerStub) Start(_ *api.Node) error {
glog.V(2).Infof("Starting stub container manager") glog.V(2).Infof("Starting stub container manager")
return nil return nil
......
/*
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 cm
import (
"k8s.io/kubernetes/pkg/kubelet/cadvisor"
"k8s.io/kubernetes/pkg/util/mount"
)
func NewContainerManager(mountUtil mount.Interface, cadvisorInterface cadvisor.Interface, nodeConfig NodeConfig) (ContainerManager, error) {
return NewStubContainerManager(), nil
}
package dockertools
import dockertypes "github.com/docker/engine-api/types"
func getContainerIP(container *dockertypes.ContainerJSON) string {
result := ""
if container.NetworkSettings != nil {
result = container.NetworkSettings.IPAddress
// Fall back to IPv6 address if no IPv4 address is present
if result == "" {
result = container.NetworkSettings.GlobalIPv6Address
}
}
return result
}
// We don't want to override the networking mode on Linux.
func getNetworkingMode() string { return "" }
// Returns true if the container name matches the infrastructure's container name
func containerProvidesPodIP(name *KubeletContainerName) bool {
return name.ContainerName == PodInfraContainerName
}
package dockertools
import (
"os"
dockertypes "github.com/docker/engine-api/types"
)
func getContainerIP(container *dockertypes.ContainerJSON) string {
if container.NetworkSettings != nil {
for _, network := range container.NetworkSettings.Networks {
if network.IPAddress != "" {
return network.IPAddress
}
}
}
return ""
}
func getNetworkingMode() string {
// Allow override via env variable. Otherwise, use a default "kubenet" network
netMode := os.Getenv("CONTAINER_NETWORK")
if netMode == "" {
netMode = "kubenet"
}
return netMode
}
// Infrastructure containers are not supported on Windows. For this reason, we
// make sure to not grab the infra container's IP for the pod.
func containerProvidesPodIP(name *KubeletContainerName) bool {
return name.ContainerName != PodInfraContainerName
}
...@@ -25,6 +25,7 @@ import ( ...@@ -25,6 +25,7 @@ import (
"os" "os"
"path" "path"
"path/filepath" "path/filepath"
"runtime"
"sort" "sort"
"strings" "strings"
...@@ -261,16 +262,18 @@ func (kl *Kubelet) GenerateRunContainerOptions(pod *api.Pod, container *api.Cont ...@@ -261,16 +262,18 @@ func (kl *Kubelet) GenerateRunContainerOptions(pod *api.Pod, container *api.Cont
} }
} }
opts.Mounts, err = makeMounts(pod, kl.getPodDir(pod.UID), container, hostname, hostDomainName, podIP, volumes) if runtime.GOOS != "windows" {
if err != nil { opts.Mounts, err = makeMounts(pod, kl.getPodDir(pod.UID), container, hostname, hostDomainName, podIP, volumes)
return nil, err if err != nil {
return nil, err
}
} }
opts.Envs, err = kl.makeEnvironmentVariables(pod, container, podIP) opts.Envs, err = kl.makeEnvironmentVariables(pod, container, podIP)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if len(container.TerminationMessagePath) != 0 { if len(container.TerminationMessagePath) != 0 && runtime.GOOS != "windows" {
p := kl.getPodContainerDir(pod.UID, container.Name) p := kl.getPodContainerDir(pod.UID, container.Name)
if err := os.MkdirAll(p, 0750); err != nil { if err := os.MkdirAll(p, 0750); err != nil {
glog.Errorf("Error on creating %q: %v", p, err) glog.Errorf("Error on creating %q: %v", p, err)
......
...@@ -21,6 +21,7 @@ import ( ...@@ -21,6 +21,7 @@ import (
"io/ioutil" "io/ioutil"
"os" "os"
"path" "path"
"runtime"
"time" "time"
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
...@@ -214,15 +215,22 @@ func RenameDirectory(oldPath, newName string) (string, error) { ...@@ -214,15 +215,22 @@ func RenameDirectory(oldPath, newName string) (string, error) {
if err != nil { if err != nil {
return "", err return "", err
} }
// os.Rename call fails on windows (https://github.com/golang/go/issues/14527) // os.Rename call fails on windows (https://github.com/golang/go/issues/14527)
// Replacing with copyFolder to the newPath and deleting the oldPath directory // Replacing with copyFolder to the newPath and deleting the oldPath directory
// err = os.Rename(oldPath, newPath) if runtime.GOOS == "windows" {
err = copyFolder(oldPath, newPath) err = copyFolder(oldPath, newPath)
if err != nil {
return "", err
}
os.RemoveAll(oldPath)
return newPath, nil
}
err = os.Rename(oldPath, newPath)
if err != nil { if err != nil {
return "", err return "", err
} }
os.RemoveAll(oldPath)
return newPath, nil return newPath, nil
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment