mirror of
https://github.com/rancher/rke.git
synced 2025-09-18 08:06:20 +00:00
Use separate cluster package Save cluster state and certs to kubernetes Handle Remove and sync cluster state/crts Reuse kubernetes client and combine image and version Separate building functions and small fixes
42 lines
1.4 KiB
Go
42 lines
1.4 KiB
Go
package services
|
|
|
|
import (
|
|
"github.com/docker/docker/api/types/container"
|
|
"github.com/rancher/rke/docker"
|
|
"github.com/rancher/rke/hosts"
|
|
"github.com/rancher/rke/pki"
|
|
)
|
|
|
|
func runKubeController(host hosts.Host, kubeControllerService KubeController) error {
|
|
imageCfg, hostCfg := buildKubeControllerConfig(kubeControllerService)
|
|
return docker.DoRunContainer(host.DClient, imageCfg, hostCfg, KubeControllerContainerName, host.Hostname, ControlRole)
|
|
}
|
|
|
|
func buildKubeControllerConfig(kubeControllerService KubeController) (*container.Config, *container.HostConfig) {
|
|
imageCfg := &container.Config{
|
|
Image: kubeControllerService.Image,
|
|
Cmd: []string{"/hyperkube",
|
|
"controller-manager",
|
|
"--address=0.0.0.0",
|
|
"--cloud-provider=",
|
|
"--kubeconfig=" + pki.KubeControllerConfigPath,
|
|
"--enable-hostpath-provisioner=false",
|
|
"--node-monitor-grace-period=40s",
|
|
"--pod-eviction-timeout=5m0s",
|
|
"--v=2",
|
|
"--allocate-node-cidrs=true",
|
|
"--cluster-cidr=" + kubeControllerService.ClusterCIDR,
|
|
"--service-cluster-ip-range=" + kubeControllerService.ServiceClusterIPRange,
|
|
"--service-account-private-key-file=" + pki.KubeAPIKeyPath,
|
|
"--root-ca-file=" + pki.CACertPath,
|
|
},
|
|
}
|
|
hostCfg := &container.HostConfig{
|
|
Binds: []string{
|
|
"/etc/kubernetes:/etc/kubernetes",
|
|
},
|
|
RestartPolicy: container.RestartPolicy{Name: "always"},
|
|
}
|
|
return imageCfg, hostCfg
|
|
}
|