Skip to content

Commit e991f2f

Browse files
committed
Refactoring provider-kubeconfig.py
* Use python kube-client * Modularize delete functionality * Add check to verify if API server is reachable * Error handling Signed-off-by: Chirayu Kapoor <[email protected]>
1 parent dcc6424 commit e991f2f

File tree

5 files changed

+755
-806
lines changed

5 files changed

+755
-806
lines changed

.github/workflows/pr.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
pip3 install -r requirements.txt
5454
apiserver=`kubectl config view --minify -o jsonpath='{.clusters[0].cluster.server}'`
5555
echo "API_SERVER_URL:$apiserver"
56-
python3 provider-kubeconfig.py -s $apiserver create $KUBEPLUS_NS
56+
python3 provider-kubeconfig.py create $KUBEPLUS_NS -s $apiserver
5757
deactivate
5858
5959
echo "Building mutating-webhook..."

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
*~
22
venv
33
provider-kubeconfig.log
4+
kubeplus-saas-provider.json
45
bak
56
vendor
67
operator-deployer/artifacts/deployment/operator-deployer

README.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,13 @@ Let’s look at an example of creating a multi-instance WordPress Service using
6060
```
6161
wget https://github.com/cloud-ark/kubeplus/raw/master/kubeplus-kubectl-plugins.tar.gz
6262
tar -zxvf kubeplus-kubectl-plugins.tar.gz
63-
export KUBEPLUS_HOME=`pwd`
64-
export PATH=$KUBEPLUS_HOME/plugins:$PATH
63+
export PATH=$(pwd)/plugins:$PATH
6564
kubectl kubeplus commands
6665
```
6766

6867
3. Set the Namespace in which to deploy KubePlus
6968

70-
`export KUBEPLUS_NS=default`
69+
`export KUBEPLUS_NS=kubeplus-example`
7170

7271
4. Create provider kubeconfig using provider-kubeconfig.py
7372

@@ -78,7 +77,7 @@ Let’s look at an example of creating a multi-instance WordPress Service using
7877
source venv/bin/activate
7978
pip3 install -r requirements.txt
8079
apiserver=`kubectl config view --minify -o jsonpath='{.clusters[0].cluster.server}'`
81-
python3 provider-kubeconfig.py -s $apiserver create $KUBEPLUS_NS
80+
python3 provider-kubeconfig.py create $KUBEPLUS_NS -s $apiserver
8281
deactivate
8382
```
8483

@@ -95,8 +94,8 @@ Let’s look at an example of creating a multi-instance WordPress Service using
9594

9695
```
9796
kubectl create -f https://raw.githubusercontent.com/cloud-ark/kubeplus/master/examples/multitenancy/application-hosting/wordpress/wordpress-service-composition.yaml --kubeconfig=kubeplus-saas-provider.json
98-
kubectl get resourcecompositions
99-
kubectl describe resourcecomposition wordpress-service-composition
97+
kubectl get resourcecompositions -n $KUBEPLUS_NS
98+
kubectl describe resourcecomposition wordpress-service-composition -n $KUBEPLUS_NS
10099
```
101100

102101
If the status of the `wordpress-service-composition` indicates that the new CRD has been created successfully, verify it:
@@ -122,7 +121,7 @@ Let’s look at an example of creating a multi-instance WordPress Service using
122121
9. Check created WordpressService instances
123122

124123
```
125-
kubectl get wordpressservices
124+
kubectl get wordpressservices -n $KUBEPLUS_NS
126125
127126
NAME AGE
128127
wp-tenant1 86s
@@ -132,13 +131,13 @@ Let’s look at an example of creating a multi-instance WordPress Service using
132131
10. Check the details of created instance:
133132

134133
```
135-
kubectl describe wordpressservices wp-tenant1
134+
kubectl describe wordpressservices wp-tenant1 -n $KUBEPLUS_NS
136135
```
137136

138137
11. Check created application resources. Notice that the `WordpressService` instance resources are deployed in a Namespace `wp-tenant1`, which was created by KubePlus.
139138

140139
```
141-
kubectl appresources WordpressService wp-tenant1 –k kubeplus-saas-provider.json
140+
kubectl appresources WordpressService wp-tenant1 –k kubeplus-saas-provider.json -n $KUBEPLUS_NS
142141
143142
NAMESPACE KIND NAME
144143
default WordpressService wp-tenant1
@@ -183,7 +182,7 @@ Let’s look at an example of creating a multi-instance WordPress Service using
183182
kubectl delete wordpressservice wp-tenant2 --kubeconfig=kubeplus-saas-provider.json
184183
kubectl delete resourcecomposition wordpress-service-composition --kubeconfig=kubeplus-saas-provider.json
185184
helm delete kubeplus -n $KUBEPLUS_NS
186-
python3 provider-kubeconfig.py delete $KUBEPLUS_NS
185+
python3 provider-kubeconfig.py delete -n $KUBEPLUS_NS
187186
```
188187
189188
<!--

0 commit comments

Comments
 (0)