2017-10-29 09:45:21 +00:00
|
|
|
package services
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/docker/docker/api/types/container"
|
2017-10-31 13:55:35 +00:00
|
|
|
"github.com/rancher/rke/docker"
|
2017-10-29 09:45:21 +00:00
|
|
|
"github.com/rancher/rke/hosts"
|
2017-10-31 13:55:35 +00:00
|
|
|
"github.com/rancher/rke/pki"
|
2017-10-29 09:45:21 +00:00
|
|
|
)
|
|
|
|
|
2017-10-31 13:55:35 +00:00
|
|
|
func runKubeproxy(host hosts.Host, kubeproxyService Kubeproxy) error {
|
|
|
|
imageCfg, hostCfg := buildKubeproxyConfig(host, kubeproxyService)
|
2017-11-02 10:07:10 +00:00
|
|
|
return docker.DoRunContainer(host.DClient, imageCfg, hostCfg, KubeproxyContainerName, host.Hostname, WorkerRole)
|
2017-10-29 09:45:21 +00:00
|
|
|
}
|
|
|
|
|
2017-10-31 13:55:35 +00:00
|
|
|
func buildKubeproxyConfig(host hosts.Host, kubeproxyService Kubeproxy) (*container.Config, *container.HostConfig) {
|
2017-10-29 09:45:21 +00:00
|
|
|
imageCfg := &container.Config{
|
2017-11-02 10:07:10 +00:00
|
|
|
Image: kubeproxyService.Image,
|
2017-10-29 09:45:21 +00:00
|
|
|
Cmd: []string{"/hyperkube",
|
|
|
|
"proxy",
|
|
|
|
"--v=2",
|
|
|
|
"--healthz-bind-address=0.0.0.0",
|
2017-10-31 13:55:35 +00:00
|
|
|
"--kubeconfig=" + pki.KubeProxyConfigPath,
|
|
|
|
},
|
2017-10-29 09:45:21 +00:00
|
|
|
}
|
|
|
|
hostCfg := &container.HostConfig{
|
2017-10-31 13:55:35 +00:00
|
|
|
Binds: []string{
|
|
|
|
"/etc/kubernetes:/etc/kubernetes",
|
|
|
|
},
|
2017-10-29 09:45:21 +00:00
|
|
|
NetworkMode: "host",
|
|
|
|
RestartPolicy: container.RestartPolicy{Name: "always"},
|
|
|
|
Privileged: true,
|
|
|
|
}
|
2017-10-31 13:55:35 +00:00
|
|
|
|
|
|
|
return imageCfg, hostCfg
|
2017-10-29 09:45:21 +00:00
|
|
|
}
|