1
0
mirror of https://github.com/rancher/rke.git synced 2025-09-16 23:20:56 +00:00

Add dind mode to rke

This commit is contained in:
galal-hussein
2018-07-10 21:21:27 +02:00
committed by Alena Prokharchyk
parent d155cc8e76
commit 247f4c9450
6 changed files with 301 additions and 3 deletions

View File

@@ -8,6 +8,7 @@ import (
"strings"
"github.com/rancher/rke/cluster"
"github.com/rancher/rke/dind"
"github.com/rancher/rke/hosts"
"github.com/rancher/rke/k8s"
"github.com/rancher/rke/log"
@@ -31,7 +32,11 @@ func RemoveCommand() cli.Command {
},
cli.BoolFlag{
Name: "local",
Usage: "Deploy Kubernetes cluster locally",
Usage: "Remove Kubernetes cluster locally",
},
cli.BoolFlag{
Name: "dind",
Usage: "Remove Kubernetes cluster deployed in dind mode",
},
}
@@ -94,6 +99,9 @@ func clusterRemoveFromCli(ctx *cli.Context) error {
if ctx.Bool("local") {
return clusterRemoveLocal(ctx)
}
if ctx.Bool("dind") {
return clusterRemoveDind(ctx)
}
clusterFilePath = filePath
rkeConfig, err := cluster.ParseConfig(clusterFile)
if err != nil {
@@ -130,3 +138,30 @@ func clusterRemoveLocal(ctx *cli.Context) error {
return ClusterRemove(context.Background(), rkeConfig, nil, nil, true, "")
}
func clusterRemoveDind(ctx *cli.Context) error {
clusterFile, filePath, err := resolveClusterFile(ctx)
if err != nil {
return fmt.Errorf("Failed to resolve cluster file: %v", err)
}
rkeConfig, err := cluster.ParseConfig(clusterFile)
if err != nil {
return fmt.Errorf("Failed to parse cluster file: %v", err)
}
rkeConfig, err = setOptionsFromCLI(ctx, rkeConfig)
if err != nil {
return err
}
for _, node := range rkeConfig.Nodes {
if err = dind.RmoveDindContainer(context.Background(), node.Address); err != nil {
return err
}
}
localKubeConfigPath := pki.GetLocalKubeConfig(filePath, "")
// remove the kube config file
pki.RemoveAdminConfig(context.Background(), localKubeConfigPath)
return err
}