Project: CloudARK KubePlus (App Definition and Development / Application Definition & Image Build)
File: saas-and-managed-app-testing.md

SaaS and Managed Application delivery example ============================================== KubePlus Operator can be set up in two ways - multi-namespace and single namespace. The multi-namespace configuration is ideal when a separate instance of an application needs to be created in a separate namespace. The single namespace configuration is ideal for managed application scenario where an application provider is delivering their application on someone else's cluster using KubePlus. The difference between the two configurations is that, for multi-namespace configuration, the KubePlus Operator needs to be installed in the default Namespace whereas for single namespace configuration, the KubePlus Operator needs to be installed in any other namespace. When installed in the default Namespace, KubePlus gets permissions to create new namespaces and deploy applications inside them. Use Helm version 3+. With minikube, you can create a cluster with a specific version like so: ``` $ minikube start --kubernetes-version=v1.24.3 ``` Setup KubePlus kubectl plugins ``` $ wget https://github.com/cloud-ark/kubeplus/raw/master/kubeplus-kubectl-plugins.tar.gz $ gunzip kubeplus-kubectl-plugins.tar.gz $ tar -xvf kubeplus-kubectl-plugins.tar $ export KUBEPLUS_HOME=`pwd` $ export PATH=$KUBEPLUS_HOME/plugins/:$PATH $ kubectl kubeplus commands ``` Multi-namespace setup ``` KUBEPLUS_NS=default helm install kubeplus "https://github.com/cloud-ark/operatorcharts/blob/master/kubeplus-chart-3.0.0.tgz?raw=true" -n $KUBEPLUS_NS kubectl create ns testns --as=system:serviceaccount:$KUBEPLUS_NS:kubeplus request should be allowed kubectl create ns testns1 --as=system:serviceaccount:$KUBEPLUS_NS:kubeplus-saas-provider request should be denied kubectl create ns testns2 --as=system:serviceaccount:$KUBEPLUS_NS:kubeplus-saas-consumer request should be denied until kubectl get pods -n $KUBEPLUS_NS | grep Running; do echo "Waiting for KubePlus Operator to become ready"; sleep 1; done kubectl get configmaps kubeplus-saas-consumer-kubeconfig -n $KUBEPLUS_NS -o jsonpath="{.data.kubeplus-saas-consumer\.json}" > consumer.conf more consumer.conf | grep namespace namespace should be set to 'default' kubectl create -f hello-world-service-composition.yaml --kubeconfig=consumer.conf request should be denied kubectl get configmaps kubeplus-saas-provider-kubeconfig -n $KUBEPLUS_NS -o jsonpath="{.data.kubeplus-saas-provider\.json}" > provider.conf more provider.conf | grep namespace namespace should be set to 'default' kubectl create -f hello-world-service-composition.yaml --kubeconfig=provider.conf until kubectl get crds --kubeconfig=provider.conf | grep hello ; do echo "Waiting for HelloworldService CRD to be registered.."; sleep 1; done kubectl man HelloWorldService -k consumer.conf kubectl create -f hs1.yaml --kubeconfig=consumer.conf kubectl get helloworldservices hs1 -o json kubectl get pods -A Hello World Pod in hs1 namespace kubectl get ns hs1 namespace has been created kubectl appurl HelloWorldService hs1 default -k consumer.conf curl the IP address received. Should see "Hello hello hello" kubectl applogs HelloWorldService hs1 default -k

Should see app logs kubectl connections HelloWorldService hs1 default -i Namespace:$KUBEPLUS_NS -k consumer.conf Should see created resources' listing kubectl metrics HelloWorldService hs1 default -o prometheus -k consumer.conf Should see the metrics kubectl delete -f hs1.yaml --kubeconfig=consumer.conf kubectl get pods -A Hello World Pod is deleted kubectl get ns hs1 namespace has been deleted kubectl delete ns testns --as=system:serviceaccount:$KUBEPLUS_NS:kubeplus should be allowed helm delete kubeplus -n $KUBEPLUS_NS ``` Single namespace setup -- ``` kubectl create ns kubeplus KUBEPLUS_NS=kubeplus helm install kubeplus "https://github.com/cloud-ark/operatorcharts/blob/master/kubeplus-chart-3.0.0.tgz?raw=true" -n $KUBEPLUS_NS kubectl create ns testns --as=system:serviceaccount:$KUBEPLUS_NS:kubeplus request should be denied kubectl create ns testns1 --as=system:serviceaccount:$KUBEPLUS_NS:kubeplus-saas-provider request should be denied kubectl create ns testns2 --as=system:serviceaccount:$KUBEPLUS_NS:kubeplus-saas-consumer request should be denied until kubectl get pods -n $KUBEPLUS_NS | grep Running; do echo "Waiting for KubePlus Operator to become ready"; sleep 1; done kubectl get configmaps kubeplus-saas-consumer-kubeconfig -n $KUBEPLUS_NS -o jsonpath="{.data.kubeplus-saas-consumer\.json}" > consumer.conf more consumer.conf | grep namespace namespace should be set to 'kubeplus' kubectl create -f hello-world-service-composition.yaml --kubeconfig=consumer.conf request should be denied kubectl get configmaps kubeplus-saas-provider-kubeconfig -n $KUBEPLUS_NS -o jsonpath="{.data.kubeplus-saas-provider\.json}" > provider.conf more provider.conf | grep namespace namespace should be set to 'kubeplus' kubectl create -f hello-world-service-composition.yaml --kubeconfig=provider.conf until kubectl get crds --kubeconfig=provider.conf | grep hello ; do echo "Waiting for HelloworldService CRD to be registered.."; sleep 1; done kubectl man HelloWorldService -k provider.conf kubectl create -f hs1.yaml --kubeconfig=provider.conf kubectl get pods -A Hello World Pod in kubeplus namespace kubectl appurl HelloWorldService hs1 kubeplus -k provider.conf curl the IP address received. Should see "Hello hello hello" kubectl applogs HelloWorldService hs1 kubeplus -k provider.conf Should see app logs kubectl connections HelloWorldService hs1 kubeplus -i Namespace:$KUBEPLUS_NS -k provider.conf Should see created resources' listing kubectl metrics HelloWorldService hs1 kubeplus -o prometheus -k provider.conf Should see the metrics kubectl delete -f hs1.yaml --kubeconfig=provider.conf kubectl get pods -A Hello World Pod is deleted kubectl get ns kubeplus namespace remains intact helm delete kubeplus -n $KUBEPLUS_NS kubectl delete ns kubeplus ``` KubePlus Operator troubleshooting: -- If any of the above steps fail (don't give expected output), collect the logs and share them with us in a Github issue. ``` kubectl logs <kubeplus-pod> $KUBEPLUS_NS -c crd-hook kubectl logs <kubeplus-pod> $KUBEPLUS_NS -c helmer kubectl logs <kubeplus-pod> $KUBEPLUS_NS -c platform-operator kubectl logs <kubeplus-pod> $KUBEPLUS_NS -c webhook-cert-setup kubectl logs <kubeplus-pod> $KUBEPLUS_NS -c consumerui ```