diff --git a/cmd/ceph-destroy.go b/cmd/ceph-destroy.go index 7ce163c..11d6f68 100644 --- a/cmd/ceph-destroy.go +++ b/cmd/ceph-destroy.go @@ -31,18 +31,18 @@ func cephDestroy() { co.Commands = append(co.Commands, "https://raw.githubusercontent.com/redhat-iot/iot-dev/master/yamls/ceph/setup/route.yaml") co.Commands = append(co.Commands, "https://raw.githubusercontent.com/redhat-iot/iot-dev/master/yamls/ceph/setup/object-user.yaml") - co.Commands = append(co.Commands, "https://raw.githubusercontent.com/redhat-iot/iot-dev/master/yamls/ceph/setup/object.yaml") + co.Commands = append(co.Commands, "https://raw.githubusercontent.com/redhat-iot/iot-dev/master/yamls/ceph/setup/object-openshift.yaml") co.Commands = append(co.Commands, "https://raw.githubusercontent.com/redhat-iot/iot-dev/master/yamls/ceph/setup/toolbox.yaml") - co.Commands = append(co.Commands, "https://raw.githubusercontent.com/redhat-iot/iot-dev/master/yamls/ceph/setup/cluster.yaml") - co.Commands = append(co.Commands, "https://raw.githubusercontent.com/redhat-iot/iot-dev/master/yamls/ceph/setup/operator.yaml") - co.Commands = append(co.Commands, "https://raw.githubusercontent.com/redhat-iot/iot-dev/master/yamls/ceph/setup/scc.yaml") + co.Commands = append(co.Commands, "https://raw.githubusercontent.com/redhat-iot/iot-dev/master/yamls/ceph/setup/cluster-on-pvc.yaml") + co.Commands = append(co.Commands, "https://raw.githubusercontent.com/redhat-iot/iot-dev/master/yamls/ceph/setup/operator-openshift.yaml") + co.Commands = append(co.Commands, "https://raw.githubusercontent.com/redhat-iot/iot-dev/master/yamls/ceph/setup/common.yaml") IOStreams, _, out, _ := genericclioptions.NewTestIOStreams() //Switch Context and Reload Config Flags co.SwitchContext("rook-ceph-system") - log.Println("Provision Knative Source") + log.Println("Removing Ceph Via Rook v1.3.2") for _, command := range co.Commands { cmd := delete.NewCmdDelete(co.CurrentFactory, IOStreams) //Kubectl signals missing field, set validate to false to ignore this @@ -56,7 +56,10 @@ func cephDestroy() { out.Reset() } - + log.Println("For removal to be complete the user must manually remove rook related files from the worker nodes in the following directorys:") + log.Println("1./var/lib/rook") + log.Println("2./var/lib/kubelet/plugins") + log.Println("3./var/lib/kubelet/plugins-registry") } // destroyCmd represents the destroy command diff --git a/cmd/ceph-secrets.go b/cmd/ceph-secrets.go index 31f00c4..f97caf7 100644 --- a/cmd/ceph-secrets.go +++ b/cmd/ceph-secrets.go @@ -21,6 +21,7 @@ import ( "github.com/spf13/cobra" "k8s.io/cli-runtime/pkg/genericclioptions" "k8s.io/kubectl/pkg/cmd/get" + "strconv" ) func getCredentials(user string) { @@ -33,14 +34,14 @@ func getCredentials(user string) { //Switch Context and Reload Config Flags co.SwitchContext("rook-ceph") - log.Info("Get S3 secrets, save for possible later use:") + log.Print("Get S3 secrets, save for possible later use:") cmd := get.NewCmdGet("kubectl", co.CurrentFactory, IOStreams) - cmd.Flags().Set("output", "jsonpath=.data") + cmd.Flags().Set("output", "jsonpath={.data}") cmd.Run(cmd, []string{co.Commands[0], "rook-ceph-object-user-my-store-" + user}) log.Info(out.String()) out.Reset() - log.Info("Ceph Endpoint URL: ") + log.Print("Ceph Endpoint URL: ") cmd = get.NewCmdGet("kubectl", co.CurrentFactory, IOStreams) cmd.Flags().Set("output", "jsonpath={.spec.host}") cmd.Run(cmd, []string{"route", "ceph-route"}) @@ -60,7 +61,12 @@ This application is a tool to generate the needed files to quickly create a Cobra application.`, Run: func(cmd *cobra.Command, args []string) { log.Info("Ceph Secrets called") - getCredentials(args[0]) + cobra.ExactArgs(1) + if len(args) != 1 { + log.Fatal("Wrong number of Input arguments expected 1 ceph user got " + strconv.Itoa(len(args))) + } else { + getCredentials(args[0]) + } }, } diff --git a/cmd/ceph-setup.go b/cmd/ceph-setup.go index 15075b7..19a4ac4 100644 --- a/cmd/ceph-setup.go +++ b/cmd/ceph-setup.go @@ -45,7 +45,7 @@ func cephSetup() { //Switch Context and Reload Config Flags co.SwitchContext("rook-ceph") - log.Println("Setup Ceph Object Storage with Rook Operator") + log.Println("Setup Ceph Object Storage with Rook Operator v1.3.2") for commandNumber, command := range co.Commands { if commandNumber == 4 { @@ -58,7 +58,7 @@ func cephSetup() { cmd.Run(cmd, []string{command}) podStatus.CountPods(out.Bytes()) log.Debug(podStatus) - log.Info("Waiting...") + log.Info("Waiting on Ceph Deployment...") out.Reset() time.Sleep(5 * time.Second) } diff --git a/cmd/kafka-bridge.go b/cmd/kafka-bridge.go index de1802e..cd01900 100644 --- a/cmd/kafka-bridge.go +++ b/cmd/kafka-bridge.go @@ -22,6 +22,7 @@ import ( "k8s.io/cli-runtime/pkg/genericclioptions" "k8s.io/kubectl/pkg/cmd/apply" "k8s.io/kubectl/pkg/cmd/get" + "time" ) var ( @@ -55,6 +56,21 @@ func kafkaBridgeRoute() { out.Reset() } + //After pods for Kafka bridge is provisioned wait for them to become ready before moving on + log.Print("Waiting for Kafka Bridge to be ready") + podStatus := utils.NewpodStatus() + for podStatus.Running >= 5 { + cmd := get.NewCmdGet("kubectl", co.CurrentFactory, IOStreams) + cmd.Flags().Set("output", "yaml") + cmd.Run(cmd, []string{"pods"}) + podStatus.CountPods(out.Bytes()) + log.Debug(podStatus) + log.Info("Waiting for Kafka Bridge...") + out.Reset() + time.Sleep(5 * time.Second) + } + log.Print("Kafka Deployment is ready") + cmd := get.NewCmdGet("kubectl", co.CurrentFactory, IOStreams) cmd.Flags().Set("output", "jsonpath={.spec.host}") cmd.Run(cmd, []string{"route", "my-bridge-route"}) @@ -94,6 +110,21 @@ func kafkaBridge() { out.Reset() } + //After pods for Kafka bridge is provisioned wait for them to become ready before moving on + log.Print("Waiting for Kafka Bridge to be ready") + podStatus := utils.NewpodStatus() + for podStatus.Running != 5 { + cmd := get.NewCmdGet("kubectl", co.CurrentFactory, IOStreams) + cmd.Flags().Set("output", "yaml") + cmd.Run(cmd, []string{"pods"}) + podStatus.CountPods(out.Bytes()) + log.Debug(podStatus) + log.Info("Waiting for Kafka Bridge...") + out.Reset() + time.Sleep(5 * time.Second) + } + log.Print("Kafka Deployment is ready") + cmd := get.NewCmdGet("kubectl", co.CurrentFactory, IOStreams) cmd.Flags().Set("output", "jsonpath={.spec.host}") cmd.Run(cmd, []string{"pods"}) @@ -139,6 +170,6 @@ func init() { // is called directly, e.g.: // bridgeCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") kafkaBridgeCmd.Flags().StringVarP(&kafkaBridgeNamespaceFlag, "namespace", "n", "kafka", "Option to specify namespace for kafka deletion, defaults to 'kafka'") - - kafkaBridgeCmd.Flags().BoolP("route", "r", false, "Setup kafka bridge using route, defaults to using ingress") + //Default to using Route + kafkaBridgeCmd.Flags().BoolP("route", "r", true, "Setup kafka bridge using route, defaults to using ingress") } diff --git a/cmd/kafka-setup.go b/cmd/kafka-setup.go index 53018e6..f9fbd30 100644 --- a/cmd/kafka-setup.go +++ b/cmd/kafka-setup.go @@ -94,7 +94,7 @@ func kafkaSetup() { cmd.Run(cmd, []string{"pods"}) podStatus.CountPods(out.Bytes()) log.Debug(podStatus) - log.Info("Waiting...") + log.Info("Waiting for Kafka deployment...") out.Reset() time.Sleep(5 * time.Second) } diff --git a/cmd/knative-service.go b/cmd/knative-service.go index d7b4281..cf4f7e8 100644 --- a/cmd/knative-service.go +++ b/cmd/knative-service.go @@ -27,6 +27,7 @@ import ( "k8s.io/cli-runtime/pkg/genericclioptions" "k8s.io/kubectl/pkg/cmd/apply" "k8s.io/kubectl/pkg/cmd/get" + "strconv" ) var ( @@ -207,13 +208,17 @@ This application is a tool to generate the needed files to quickly create a Cobra application.`, Run: func(cmd *cobra.Command, args []string) { log.Println("Knative Service called") - - if status { - serviceStatus() - } else if logView { - //logs(args[0]) + cobra.ExactArgs(1) + if len(args) != 1 { + log.Fatal("Wrong number of Input arguments expected 1 ceph user got " + strconv.Itoa(len(args))) } else { - service(args[0]) + if status { + serviceStatus() + } else if logView { + //logs(args[0]) + } else { + service(args[0]) + } } }, } @@ -231,7 +236,7 @@ func init() { // is called directly, e.g.: // serviceCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") knativeServiceCmd.Flags().BoolVarP(&status, "status", "S", false, "Show Status of the Service") - knativeServiceCmd.Flags().BoolVarP(&logView, "logView", "l", false, "Show logs of the Service") + //knativeServiceCmd.Flags().BoolVarP(&logView, "logView", "l", false, "Show logs of the Service") knativeServiceCmd.Flags().StringVarP(&knativeServiceNamespaceFlag, "namespace", "n", "knative-eventing", "Option to specify namespace for knative service deployment, defaults to 'knative-eventing'") knativeServiceCmd.Flags().StringVarP(&cephEndpoint, "cephEndpoint", "c", "", "Option to specify ceph object storage endpoint to service") knativeServiceCmd.Flags().StringVarP(&cephAccessKey, "cephAccessKey", "a", "", "Option to specify ceph object storage access key to service")