1
0
mirror of https://github.com/rancher/rke.git synced 2025-09-08 10:29:44 +00:00

Update rancher types

This commit is contained in:
galal-hussein
2017-11-14 20:11:21 +02:00
parent 75448eb572
commit 37b6c8a65e
20 changed files with 134 additions and 75 deletions

View File

@@ -42,10 +42,10 @@ func (c *Cluster) buildClusterConfigEnv() []string {
func (c *Cluster) RunKubectlCmd(kubectlCmd *KubectlCommand) error {
h := c.ControlPlaneHosts[0]
logrus.Debugf("[kubectl] Using host [%s] for deployment", h.Hostname)
logrus.Debugf("[kubectl] Using host [%s] for deployment", h.AdvertisedHostname)
logrus.Debugf("[kubectl] Pulling kubectl image..")
if err := docker.PullImage(h.DClient, h.Hostname, KubectlImage); err != nil {
if err := docker.PullImage(h.DClient, h.AdvertisedHostname, KubectlImage); err != nil {
return err
}
@@ -62,26 +62,26 @@ func (c *Cluster) RunKubectlCmd(kubectlCmd *KubectlCommand) error {
logrus.Debugf("[kubectl] Creating kubectl container..")
resp, err := h.DClient.ContainerCreate(context.Background(), imageCfg, nil, nil, KubctlContainer)
if err != nil {
return fmt.Errorf("Failed to create kubectl container on host [%s]: %v", h.Hostname, err)
return fmt.Errorf("Failed to create kubectl container on host [%s]: %v", h.AdvertisedHostname, err)
}
logrus.Debugf("[kubectl] Container %s created..", resp.ID)
if err := h.DClient.ContainerStart(context.Background(), resp.ID, types.ContainerStartOptions{}); err != nil {
return fmt.Errorf("Failed to start kubectl container on host [%s]: %v", h.Hostname, err)
return fmt.Errorf("Failed to start kubectl container on host [%s]: %v", h.AdvertisedHostname, err)
}
logrus.Debugf("[kubectl] running command: %s", kubectlCmd.Cmd)
statusCh, errCh := h.DClient.ContainerWait(context.Background(), resp.ID, container.WaitConditionNotRunning)
select {
case err := <-errCh:
if err != nil {
return fmt.Errorf("Failed to execute kubectl container on host [%s]: %v", h.Hostname, err)
return fmt.Errorf("Failed to execute kubectl container on host [%s]: %v", h.AdvertisedHostname, err)
}
case status := <-statusCh:
if status.StatusCode != 0 {
return fmt.Errorf("kubectl command failed on host [%s]: exit status %v", h.Hostname, status.StatusCode)
return fmt.Errorf("kubectl command failed on host [%s]: exit status %v", h.AdvertisedHostname, status.StatusCode)
}
}
if err := h.DClient.ContainerRemove(context.Background(), resp.ID, types.ContainerRemoveOptions{}); err != nil {
return fmt.Errorf("Failed to remove kubectl container on host[%s]: %v", h.Hostname, err)
return fmt.Errorf("Failed to remove kubectl container on host[%s]: %v", h.AdvertisedHostname, err)
}
return nil
}