1
0
mirror of https://github.com/rancher/rke.git synced 2025-06-05 13:32:50 +00:00
rke/services/kubeproxy.go

45 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-10-29 09:45:21 +00:00
)
type Kubeproxy struct {
Version string `yaml:"version"`
Image string `yaml:"image"`
}
func runKubeproxy(host hosts.Host, kubeproxyService Kubeproxy) error {
imageCfg, hostCfg := buildKubeproxyConfig(host, kubeproxyService)
err := docker.DoRunContainer(imageCfg, hostCfg, KubeproxyContainerName, &host, WorkerRole)
2017-10-29 09:45:21 +00:00
if err != nil {
return err
}
return nil
}
func buildKubeproxyConfig(host hosts.Host, kubeproxyService Kubeproxy) (*container.Config, *container.HostConfig) {
2017-10-29 09:45:21 +00:00
imageCfg := &container.Config{
Image: kubeproxyService.Image + ":" + kubeproxyService.Version,
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,
}
return imageCfg, hostCfg
2017-10-29 09:45:21 +00:00
}