Skip to content

Commit

Permalink
cluster-api-dev-helper: Make compatible with CRDs (openshift#262)
Browse files Browse the repository at this point in the history
  • Loading branch information
randomvariable authored and k8s-ci-robot committed Oct 16, 2018
1 parent 944779a commit b6b58af
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 58 deletions.
2 changes: 1 addition & 1 deletion hack/cluster-api-dev-helper/cmd/minikube.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func defineMinikubeSetup(parent *cobra.Command) {
Long: `Set up minikube for use with Cluster API`,
Run: func(cmd *cobra.Command, args []string) {
runCommandWithWait("minikube", "config", "set", "bootstrapper", "kubeadm")
runCommandWithWait("minikube", "config", "set", "kubernetes-version", "v1.9.4")
runCommandWithWait("minikube", "config", "set", "kubernetes-version", "v1.12.1")
},
}
parent.AddCommand(newCmd)
Expand Down
70 changes: 13 additions & 57 deletions hack/cluster-api-dev-helper/cmd/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ func defineTestingCmd(parent *cobra.Command) {
defineTestingDestroyClustersCmd(newCmd)
defineTestingDeleteMachinesCmd(newCmd)
defineTestingDestroyMachinesCmd(newCmd)
defineTestingClusterLogs(newCmd)
defineTestingMachineLogs(newCmd)
defineTestingRestartControllerCmd(newCmd)
defineTestingApplyControllerManifestsCmd(newCmd)

Expand All @@ -53,15 +51,14 @@ func defineTestingStartCmd(parent *cobra.Command) {
Long: `Start tests with an existing kubeconfig context. Expects to be run in the repository using Go 1.11`,
Run: func(cmd *cobra.Command, args []string) {
var wg sync.WaitGroup
a := runShell(`go run ./clusterctl create cluster -v2 \
a := runShell(`go run ./clusterctl create cluster -v4 \
-m ./clusterctl/examples/aws/out/machines.yaml \
-c ./clusterctl/examples/aws/out/cluster.yaml \
-p ./clusterctl/examples/aws/out/provider-components.yaml \
--provider aws \
--existing-bootstrap-cluster-kubeconfig ~/.kube/config`)
wg.Add(2)
go clusterLogs(&wg)
go machineLogs(&wg)
--existing-bootstrap-cluster-kubeconfig /home/naadir/.kube/config`)
wg.Add(1)
go controllerLogs(&wg)
a.Wait()
},
}
Expand All @@ -76,9 +73,8 @@ func defineTestingLogsCmd(parent *cobra.Command) {
Long: `Start tailing controller logs`,
Run: func(cmd *cobra.Command, args []string) {
var wg sync.WaitGroup
wg.Add(2)
go clusterLogs(&wg)
go machineLogs(&wg)
wg.Add(1)
go controllerLogs(&wg)
wg.Wait()
},
}
Expand Down Expand Up @@ -107,7 +103,7 @@ func defineTestingDeleteClustersCmd(parent *cobra.Command) {
Run: func(cmd *cobra.Command, args []string) {
var wg sync.WaitGroup
wg.Add(1)
go clusterLogs(&wg)
go controllerLogs(&wg)
runShell("kubectl delete clusters --all --wait=true")
wg.Wait()
},
Expand Down Expand Up @@ -135,7 +131,7 @@ func defineTestingDeleteMachinesCmd(parent *cobra.Command) {
Run: func(cmd *cobra.Command, args []string) {
var wg sync.WaitGroup
wg.Add(1)
go machineLogs(&wg)
go controllerLogs(&wg)
runShell("kubectl delete machines --all --wait=true")
wg.Wait()
},
Expand All @@ -155,36 +151,6 @@ func defineTestingDestroyMachinesCmd(parent *cobra.Command) {
parent.AddCommand(newCmd)
}

func defineTestingClusterLogs(parent *cobra.Command) {
newCmd := &cobra.Command{
Use: "cluster-controller-logs",
Short: "Tail cluster controller logs",
Long: `Tail cluster controller logs`,
Run: func(cmd *cobra.Command, args []string) {
var wg sync.WaitGroup
wg.Add(1)
go clusterLogs(&wg)
wg.Wait()
},
}
parent.AddCommand(newCmd)
}

func defineTestingMachineLogs(parent *cobra.Command) {
newCmd := &cobra.Command{
Use: "machine-controller-logs",
Short: "Tail cluster controller logs",
Long: `Tail cluster controller logs`,
Run: func(cmd *cobra.Command, args []string) {
var wg sync.WaitGroup
wg.Add(1)
go machineLogs(&wg)
wg.Wait()
},
}
parent.AddCommand(newCmd)
}

func defineTestingRestartControllerCmd(parent *cobra.Command) {
newCmd := &cobra.Command{
Use: "restart-controllers",
Expand All @@ -210,25 +176,24 @@ func defineTestingApplyControllerManifestsCmd(parent *cobra.Command) {
}

func destroyMachines() {
runShellWithWait("kubectl get machine -o name | xargs kubectl patch -p '{\"metadata\":{\"finalizers\":null}}'")
runShellWithWait("kubectl get machine -o name | xargs kubectl patch -p '{\"metadata\":{\"finalizers\":null}}' --type=merge")
runShellWithWait("kubectl delete machines --force=true --grace-period 0 --all --wait=true")
}

func destroyClusters() {
runShellWithWait("kubectl patch cluster test1 -p '{\"metadata\":{\"finalizers\":null}}'")
runShellWithWait("kubectl patch cluster test1 -p '{\"metadata\":{\"finalizers\":null}}' --type=merge")
runShellWithWait("kubectl delete clusters --force=true --grace-period 0 --all --wait=true")
}

func destroyControlPlane() {
runShellWithWait("kubectl delete deployment clusterapi-apiserver --force=true --grace-period 0 --wait=true")
runShellWithWait("kubectl delete deployment clusterapi-controllers --force=true --grace-period 0 --wait=true")
runShellWithWait("kubectl delete statefulsets etcd-clusterapi --force=true --grace-period 0 --wait=true")
runShellWithWait("kubectl delete crds --all --force=true --grace-period 0 --wait=true")
}

func clusterLogs(wg *sync.WaitGroup) {
func controllerLogs(wg *sync.WaitGroup) {
defer wg.Done()
for {
b := runShell("kubectl get po -o name | grep clusterapi-controllers | xargs kubectl logs -c aws-cluster-controller -f")
b := runShell("kubectl get po -o name | grep clusterapi-controllers | xargs kubectl logs -c cluster-api-aws-controller -f")
b.Wait()
time.Sleep(5 * 1000 * 1000 * 1000)
}
Expand All @@ -237,12 +202,3 @@ func clusterLogs(wg *sync.WaitGroup) {
func restartControllers() {
runShellWithWait("kubectl get po -o name | grep clusterapi-controllers | xargs kubectl delete")
}

func machineLogs(wg *sync.WaitGroup) {
defer wg.Done()
for {
c := runShell("kubectl get po -o name | grep clusterapi-controllers | xargs kubectl logs -c aws-machine-controller -f")
c.Wait()
time.Sleep(5 * 1000 * 1000 * 1000)
}
}

0 comments on commit b6b58af

Please sign in to comment.