tree: 815ab4d8783b53f71241f571750d28583d71ba7f [path history] [tgz]
  1. artifacts/
  2. docs/
  3. hack/
  4. pkg/
  5. test/
  6. go.mod
  7. go.sum
  8. main.go
  9. Makefile
  10. README.md
submarine-cloud-v2/README.md

submarine-cloud-v2 (submarine operator)

submarine-cloud-v2, i.e. submarine-operator, implements the operator for Submarine application. The operator provides a new option for users to deploy the Submarine service to their Kubernetes clusters. The submarine-operator can fix some errors automatically. However, if the Submarine service is deployed with Helm, the errors need to be fixed by human operators.

Getting Started

  • In this section, we provide two methods, including out-of-cluter method and in-cluster method, for you to deploy your submarine-operator. In addition, the out-of-cluster method is convenient for operator developers. On the other hand, the in-cluster method is suitable for production.

Golang version: 1.16.2

Initialization

# Install dependencies
go mod vendor
# Run the cluster
minikube start --vm-driver=docker --cpus 8 --memory 4096 --kubernetes-version v1.21.2
# Or if you want to support Pod Security Policy (https://minikube.sigs.k8s.io/docs/tutorials/using_psp), you can use the following command to start cluster
minikube start --extra-config=apiserver.enable-admission-plugins=PodSecurityPolicy --addons=pod-security-policy --vm-driver=docker --cpus 8 --memory 4096 --kubernetes-version v1.21.2

Set up storage class fields

One can set up storage class fields in values.yaml or using helm with --set. We‘ve set up minikube’s provisioner for storage class as default.

For example, if you are using kind in local, please add --set storageClass.provisioner=rancher.io/local-path --set storageClass.volumeBindingMode=WaitForFirstConsumer to helm install command.

Documentation for storage class: https://kubernetes.io/docs/concepts/storage/storage-classes/

Run operator out-of-cluster

# Step1: Install helm chart dependencies
helm install --set dev=true submarine ../helm-charts/submarine/

# Step2: Build & Run "submarine-operator"
make
./submarine-operator

# Step3: Deploy a Submarine
kubectl create ns submarine-user-test
kubectl apply -n submarine-user-test -f artifacts/examples/example-submarine.yaml

# Step4: Exposing Service
# Method1 -- use minikube ip
minikube ip  # you'll get the IP address of minikube, ex: 192.168.49.2

# Method2 -- use port-forwarding
kubectl port-forward --address 0.0.0.0 service/submarine-traefik 32080:80

# Step5: View Workbench
# http://{minikube ip}:32080 (from Method 1), ex: http://192.168.49.2:32080
# or http://127.0.0.1:32080 (from Method 2).

# Step6: Delete Submarine
# By deleting the submarine custom resource, the operator will do the following things:
#   (1) Remove all relevant Helm chart releases
#   (2) Remove all resources in the namespace "submariner-user-test"
#   (3) Remove all non-namespaced resources (Ex: PersistentVolume) created by client-go API
#   (4) **Note:** The namespace "submarine-user-test" will not be deleted
kubectl delete submarine example-submarine -n submarine-user-test

# Step6: Stop the operator
# Press ctrl+c to stop the operator

# Step7: Uninstall helm chart dependencies
helm delete submarine

Run operator in-cluster

# Step1: Install submarine-operator
helm install submarine ../helm-charts/submarine/

# Step2: Deploy a submarine
kubectl create ns submarine-user-test
kubectl apply -n submarine-user-test -f artifacts/examples/example-submarine.yaml

# Step3: Inspect the logs of submarine-operator
kubectl logs -f $(kubectl get pods --output=name | grep submarine-operator)

# Step4: Exposing Service
# Method1 -- use minikube ip
minikube ip  # you'll get the IP address of minikube, ex: 192.168.49.2

# Method2 -- use port-forwarding
kubectl port-forward --address 0.0.0.0 service/submarine-traefik 32080:80

# Step5: View Workbench
# http://{minikube ip}:32080 (from Method 1), ex: http://192.168.49.2:32080
# or http://127.0.0.1:32080 (from Method 2).

# Step6: Delete Submarine
# By deleting the submarine custom resource, the operator will do the following things:
#   (1) Remove all relevant Helm chart releases
#   (2) Remove all resources in the namespace "submariner-user-test"
#   (3) Remove all non-namespaced resources (Ex: PersistentVolume) created by client-go API
#   (4) **Note:** The namespace "submarine-user-test" will not be deleted
kubectl delete submarine example-submarine -n submarine-user-test

# Step7: Delete the submarine-operator
helm delete submarine

Development

Please check out the Developer Guide.