Skip to content

Commit

Permalink
Merge pull request #9 from redhat-iot/ceph-update
Browse files Browse the repository at this point in the history
Ceph update to rook 1.3.2
  • Loading branch information
Andrew Stoycos committed May 13, 2020
2 parents b5001dd + 4f7c123 commit 362f357
Show file tree
Hide file tree
Showing 35 changed files with 2,398 additions and 931 deletions.
32 changes: 17 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
# Setting up Clound Native Edge systems with the IoTCLI
# OpenShift Clients

The user can choose which tools they want to use in order to either digest, display or process the IoT data. Eventually the user will be allowed to create custom data pipelines to connect the tools. Currently the following tools/commands are supported
The OpenShift client `oc` simplifies working with Kubernetes and OpenShift
clusters, offering a number of advantages over `kubectl` such as easy login,
kube config file management, and access to developer tools. The `kubectl`
binary is included alongside for when strict Kubernetes compliance is necessary.

## Getting Started
To learn more about OpenShift, visit [docs.openshift.com](https://docs.openshift.com)
and select the version of OpenShift you are using.

Download the latest Release from the [release page](https://github.com/redhat-iot/iot-dev/releases)
## Installing the tools

Move the Binary `IoTCLI` into your `$PATH`
After extracting this archive, move the `oc` and `kubectl` binaries
to a location on your PATH such as `/usr/local/bin`. Then run:

Run `IoTCLI login` to authenticate with your Openshift cluster
oc login [API_URL]

# Main Components Overview
to start a session against an OpenShift cluster. After login, run `oc` and
`oc help` to learn more about how to get started with OpenShift.

## Messaging Core
## License

In any Edge system that incorporates IoT devices, having a scalable cloud native edge system is very important. With the `IoTCLI` you can easily deploy these messaging services to your Openshift 4.X cluster

### Enmasse

[Enmasse](enmasse.io) is an open source project for managed, self-service messaging on Kubernetes.

The IoTCLI makes it easy to deploy the system along with its [IoT services](https://enmasse.io/documentation/0.31.0/openshift/#iot-guide-messaging-iot) onto an openshift Cluster
OpenShift is licensed under the Apache Public License 2.0. The source code for this
program is [located on github](https://github.com/openshift/origin).
he system along with its [IoT services](https://enmasse.io/documentation/0.31.0/openshift/#iot-guide-messaging-iot) onto an openshift Cluster

### Kafka

Expand Down
7 changes: 3 additions & 4 deletions cmd/ceph-destroy.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ package cmd

import (
"github.com/IoTCLI/cmd/utils"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/kubectl/pkg/cmd/delete"
"log"
//"time"
)

//Made from Instructions @https://opendatahub.io/docs/administration/advanced-installation/object-storage.html for installing
Expand Down Expand Up @@ -53,7 +52,7 @@ func cephDestroy() {
log.Fatal(err)
}
cmd.Run(cmd, []string{})
log.Print(out.String())
log.Info(out.String())
out.Reset()

}
Expand All @@ -71,7 +70,7 @@ Cobra is a CLI library for Go that empowers applications.
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("destroy called")
log.Info("destroy called")
cephDestroy()
},
}
Expand Down
8 changes: 4 additions & 4 deletions cmd/ceph-secrets.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ package cmd

import (
"github.com/IoTCLI/cmd/utils"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/kubectl/pkg/cmd/get"
"log"
)

func getCredentials(user string) {
Expand All @@ -33,11 +33,11 @@ func getCredentials(user string) {
//Switch Context and Reload Config Flags
co.SwitchContext("rook-ceph")

log.Print("Get S3 secrets, save for possible later use:")
log.Info("Get S3 secrets, save for possible later use:")
cmd := get.NewCmdGet("kubectl", co.CurrentFactory, IOStreams)
cmd.Flags().Set("output", "json")
cmd.Run(cmd, []string{co.Commands[0], "rook-ceph-object-user-my-store-" + user})
log.Print(out.String())
log.Info(out.String())
out.Reset()
}

Expand All @@ -52,7 +52,7 @@ Cobra is a CLI library for Go that empowers applications.
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("Ceph Secrets called")
log.Info("Ceph Secrets called")
getCredentials(args[0])
},
}
Expand Down
36 changes: 11 additions & 25 deletions cmd/ceph-setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ package cmd

import (
"github.com/IoTCLI/cmd/utils"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/kubectl/pkg/cmd/apply"
"k8s.io/kubectl/pkg/cmd/get"
"log"
"time"
)

Expand All @@ -31,47 +31,33 @@ func cephSetup() {
//Make command options for Knative Setup
co := utils.NewCommandOptions()

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/operator.yaml")
co.Commands = append(co.Commands, "pods")
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/common.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/cluster-on-pvc.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/object.yaml")
co.Commands = append(co.Commands, "pods")
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/route.yaml")

IOStreams, _, out, _ := genericclioptions.NewTestIOStreams()

//Switch Context and Reload Config Flags
co.SwitchContext("rook-ceph-system")
co.SwitchContext("rook-ceph")

log.Println("Setup Ceph Object Storage with Rook Operator")
for commandNumber, command := range co.Commands {
//After the system pods are provisioned wait for them to become ready before moving on
if commandNumber == 2 {
log.Print("Waiting for Pods to be ready in rook-ceph-system namespace:")
podStatus := utils.NewpodStatus()
for podStatus.Running != 7 {
cmd := get.NewCmdGet("kubectl", co.CurrentFactory, IOStreams)
cmd.Flags().Set("output", "yaml")
cmd.Run(cmd, []string{command})
podStatus.CountPods(out.Bytes())
log.Print("Waiting...")
out.Reset()
time.Sleep(5 * time.Second)
}
co.SwitchContext("rook-ceph")

} else if commandNumber == 6 {
if commandNumber == 4 {
//After the pods in rook-ceph are provisioned wait for them to become ready before moving on
log.Print("Waiting for pods to be ready in rook-ceph")
podStatus := utils.NewpodStatus()
for podStatus.Running != 9 && podStatus.Succeeded != 3 {
for podStatus.Running != 22 && podStatus.Succeeded != 3 {
cmd := get.NewCmdGet("kubectl", co.CurrentFactory, IOStreams)
cmd.Flags().Set("output", "yaml")
cmd.Run(cmd, []string{command})
podStatus.CountPods(out.Bytes())
log.Print("Waiting...")
log.Debug(podStatus)
log.Info("Waiting...")
out.Reset()
time.Sleep(5 * time.Second)
}
Expand All @@ -85,7 +71,7 @@ func cephSetup() {
log.Fatal(err)
}
cmd.Run(cmd, []string{})
log.Print(out.String())
log.Info(out.String())
out.Reset()
}
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/enmasse-IoT-addDevice.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package cmd

import (
//"io/ioutil"
"log"
log "github.com/sirupsen/logrus"
//"os"
"bytes"
"crypto/tls"
Expand Down
2 changes: 1 addition & 1 deletion cmd/enmasse-IoT-project.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ limitations under the License.
package cmd

import (
log "github.com/sirupsen/logrus"
"io/ioutil"
"log"
"os"
"strconv"
"strings"
Expand Down
12 changes: 7 additions & 5 deletions cmd/enmasse-destroy.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,18 @@ limitations under the License.
package cmd

import (
"log"
//"os"

log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"

"github.com/IoTCLI/cmd/utils"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/kubectl/pkg/cmd/delete"
)

var (
enmasseDestroyNamespaceFlag string
)

func enmasseDestroy() {

//Make command options for Kafka Setup
Expand All @@ -37,7 +39,7 @@ func enmasseDestroy() {
//
IOStreams, _, out, _ := genericclioptions.NewTestIOStreams()

co.SwitchContext(enmasseSetupNamespaceFlag)
co.SwitchContext(enmasseDestroyNamespaceFlag)

//Reload config flags after switching context
log.Println("Destroy Enmasse Messaging Service")
Expand Down Expand Up @@ -82,5 +84,5 @@ func init() {
// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
// destroyCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")

enmasseDestroyCmd.Flags().StringVarP(&enmasseDestroyNamespaceFlag, "namespace", "n", "enmasse-infra", "Option to specify namespace for enmasse deployment, defaults to 'enmasse-infra'")
}
2 changes: 1 addition & 1 deletion cmd/enmasse-setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ limitations under the License.
package cmd

import (
"log"
log "github.com/sirupsen/logrus"
"os"
"os/exec"

Expand Down
2 changes: 1 addition & 1 deletion cmd/gstreamer-destroy.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ limitations under the License.
package cmd

import (
"log"
log "github.com/sirupsen/logrus"

"github.com/IoTCLI/cmd/utils"
"github.com/spf13/cobra"
Expand Down
2 changes: 1 addition & 1 deletion cmd/gstreamer-setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package cmd

import (
"fmt"
"log"
log "github.com/sirupsen/logrus"

"github.com/IoTCLI/cmd/utils"
"github.com/spf13/cobra"
Expand Down
2 changes: 0 additions & 2 deletions cmd/gstreamer.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ package cmd

import (
"fmt"
//"k8s.io/cli-runtime/pkg/genericclioptions"
//"k8s.io/kubectl/pkg/cmd/apply"
"github.com/spf13/cobra"
)

Expand Down
33 changes: 31 additions & 2 deletions cmd/kafka-bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,45 @@ package cmd

import (
"github.com/IoTCLI/cmd/utils"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/kubectl/pkg/cmd/apply"
"log"
)

var (
kafkaBridgeNamespaceFlag string
)

func kafkaBridgeRoute() {
co := utils.NewCommandOptions()

//Setup kafka bridge
co.Commands = append(co.Commands, "https://raw.githubusercontent.com/redhat-iot/iot-dev/master/yamls/kafka/bridge/route.yaml")
co.Commands = append(co.Commands, "https://raw.githubusercontent.com/redhat-iot/iot-dev/master/yamls/kafka/bridge/kafka-bridge.yaml")

IOStreams, _, out, _ := genericclioptions.NewTestIOStreams()

co.SwitchContext(kafkaBridgeNamespaceFlag)

//Reload config flags after switching context

log.Println("Provision Kafka Http Bridge using route")
for _, command := range co.Commands {
cmd := apply.NewCmdApply("kubectl", co.CurrentFactory, IOStreams)
//Kubectl signals missing field, set validate to false to ignore this
cmd.Flags().Set("validate", "false")
err := cmd.Flags().Set("filename", command)
if err != nil {
log.Fatal(err)
}
cmd.Run(cmd, []string{})
log.Print(out.String())
out.Reset()
}
log.Println("To check status of Kafka HTTP bridge run 'curl -v GET http://my-bridge.io/healthy'")
}

func kafkaBridge() {

co := utils.NewCommandOptions()
Expand Down Expand Up @@ -73,7 +102,7 @@ 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("Kafka Http Bridge called")
kafkaBridge()
kafkaBridgeRoute()
},
}

Expand Down
4 changes: 2 additions & 2 deletions cmd/kafka-destroy.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ package cmd

import (
"github.com/IoTCLI/cmd/utils"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/kubectl/pkg/cmd/delete"
"log"
)

var (
Expand All @@ -40,7 +40,7 @@ func kafkaDestroy() {
co.Commands = append(co.Commands, "https://github.com/strimzi/strimzi-kafka-operator/releases/download/0.17.0/strimzi-cluster-operator-0.17.0.yaml")
co.Commands = append(co.Commands, "https://raw.githubusercontent.com/redhat-iot/iot-dev/master/yamls/kafka/setup/kafka-namespace.yaml")
co.Commands = append(co.Commands, "https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-0.30.0/deploy/static/mandatory.yaml")
co.Commands = append(co.Commands, "https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-0.30.0/deploy/static/provider/cloud-generic.yaml")
//co.Commands = append(co.Commands, "https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-0.30.0/deploy/static/provider/cloud-generic.yaml")
//
IOStreams, _, out, _ := genericclioptions.NewTestIOStreams()

Expand Down
8 changes: 4 additions & 4 deletions cmd/kafka-setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ limitations under the License.
package cmd

import (
log "github.com/sirupsen/logrus"
"io/ioutil"
"log"
"os"

"github.com/spf13/cobra"
Expand Down Expand Up @@ -66,15 +66,15 @@ func kafkaSetup() {

co.SwitchContext(kafkaSetupNamespaceFlag)

log.Println("Provision Kafka")
log.Info("Provision Kafka")
for _, command := range co.Commands {
cmd := apply.NewCmdApply("kubectl", co.CurrentFactory, IOStreams)
err := cmd.Flags().Set("filename", command)
if err != nil {
log.Fatal(err)
}
cmd.Run(cmd, []string{})
log.Print(out.String())
log.Info(out.String())
out.Reset()
}
//Remove tempfile when done
Expand All @@ -93,7 +93,7 @@ Cobra is a CLI library for Go that empowers applications.
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("Kafka setup called")
log.Info("Kafka setup called")
kafkaSetup()

},
Expand Down
Loading

0 comments on commit 362f357

Please sign in to comment.