1
0
mirror of https://github.com/rancher/rke.git synced 2025-08-31 14:36:32 +00:00

Refactor kubectl

Export pki utlitity functions
This commit is contained in:
moelsayed
2017-11-08 19:45:51 +02:00
parent 7172f6ec46
commit d58fc84de9
5 changed files with 112 additions and 100 deletions

View File

@@ -4,8 +4,6 @@ import (
"fmt"
"github.com/Sirupsen/logrus"
"github.com/rancher/rke/k8s"
"github.com/rancher/rke/pki"
)
const (
@@ -20,17 +18,12 @@ func (c *Cluster) DeployK8sAddOns() error {
func (c *Cluster) deployKubeDNS() error {
logrus.Infof("[plugins] Setting up KubeDNS")
deployerHost := c.ControlPlaneHosts[0]
kubectlCmd := []string{"apply -f /addons/kubedns*.yaml"}
env := []string{
fmt.Sprintf("%s=%s", pki.KubeAdminConfigENVName, c.Certificates[pki.KubeAdminCommonName].Config),
fmt.Sprintf("%s=%s", ClusterDNSServerIPEnvName, c.ClusterDNSServer),
fmt.Sprintf("%s=%s", ClusterDomainEnvName, c.ClusterDomain),
kubectlCmd := &KubectlCommand{
Cmd: []string{"apply -f /addons/kubedns*.yaml"},
}
logrus.Infof("[plugins] Executing the deploy command..")
err := k8s.RunKubectlCmd(deployerHost.DClient, deployerHost.Hostname, kubectlCmd, env)
err := c.RunKubectlCmd(kubectlCmd)
if err != nil {
return fmt.Errorf("Failed to run kubectl command: %v", err)
}