1
0
mirror of https://github.com/rancher/rke.git synced 2025-08-10 11:13:44 +00:00
rke/services/kubeproxy.go

37 lines
1.1 KiB
Go
Raw Normal View History

2017-10-29 09:45:21 +00:00
package services
import (
"github.com/docker/docker/api/types/container"
"github.com/rancher/rke/docker"
2017-10-29 09:45:21 +00:00
"github.com/rancher/rke/hosts"
"github.com/rancher/rke/pki"
2017-11-13 21:28:38 +00:00
"github.com/rancher/types/io.cattle.cluster/v1"
2017-10-29 09:45:21 +00:00
)
2017-11-09 19:50:49 +00:00
func runKubeproxy(host hosts.Host, kubeproxyService v1.KubeproxyService) error {
imageCfg, hostCfg := buildKubeproxyConfig(host, kubeproxyService)
return docker.DoRunContainer(host.DClient, imageCfg, hostCfg, KubeproxyContainerName, host.Hostname, WorkerRole)
2017-10-29 09:45:21 +00:00
}
2017-11-09 19:50:49 +00:00
func buildKubeproxyConfig(host hosts.Host, kubeproxyService v1.KubeproxyService) (*container.Config, *container.HostConfig) {
2017-10-29 09:45:21 +00:00
imageCfg := &container.Config{
Image: kubeproxyService.Image,
2017-10-29 09:45:21 +00:00
Cmd: []string{"/hyperkube",
"proxy",
"--v=2",
"--healthz-bind-address=0.0.0.0",
"--kubeconfig=" + pki.KubeProxyConfigPath,
},
2017-10-29 09:45:21 +00:00
}
hostCfg := &container.HostConfig{
Binds: []string{
"/etc/kubernetes:/etc/kubernetes",
},
2017-10-29 09:45:21 +00:00
NetworkMode: "host",
RestartPolicy: container.RestartPolicy{Name: "always"},
Privileged: true,
}
2017-11-10 19:53:48 +00:00
imageCfg.Cmd = append(imageCfg.Cmd, kubeproxyService.ExtraArgs...)
return imageCfg, hostCfg
2017-10-29 09:45:21 +00:00
}