-
Notifications
You must be signed in to change notification settings - Fork 76
/
steps.txt
81 lines (61 loc) · 3.19 KB
/
steps.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
Day2 operation on basic web app
--------------------------------
This example shows how KubePlus can be used to perform day2 operations as part of delivering
managed service for a web app. The app is a Flask server with a MySql database.
The app is packaged as a Helm chart with two versions and is initialized with a single user in the database.
The second version contains a helm post-upgrade hook to add a new user to the
database. The day2 operation is done by upgrading the helm releases by updating
the ResourceComposition instance.
Setup:
Install Helm v3
Install minikube
Create minikube cluster:
$ minikube start
Install KubePlus Operator:
$ KUBEPLUS_NS=default
$ python ../../../provider-kubeconfig.py create $KUBEPLUS_NS
$ cp kubeplus-saas-provider.json provider.conf
$ helm install kubeplus "https://github.com/cloud-ark/operatorcharts/blob/master/kubeplus-chart-3.0.39.tgz?raw=true" -n $KUBEPLUS_NS --kubeconfig=provider.conf
$ kubectl get pods (wait till kubeplus pod is Running)
Install 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
Upload the charts to KubePlus:
$ kubectl upload chart basicwebapp-0.0.1.tgz provider.conf
$ kubectl upload chart basicwebapp-0.0.2.tgz provider.conf
Create basic web app API:
$ kubectl create -f basic-web-app-service-composition-localchart.yaml --kubeconfig=provider.conf
Check that the API was created
$ kubectl get crds
Create app instance:
$ kubectl create -f tenant1.yaml --kubeconfig=provider.conf
Check that the application instance Pods are created in a new namespace:
$ kubectl get pods -A
Connect to the application:
$ kubectl port-forward <web-app-deploy-pod> -n bwa-tenant1 5000:5000
- get the name of the KubePlus Podfrom the previous command
Verify that you can add users and try adding the same user again.
Go to "localhost:5000/users" to see the list of users in the database.
- curl -v http://localhost:5000/users
Perform application-specific day2 operation:
---------------------------------------------
Change the ResourceComposition file "basic-web-app-service-composition-localchart.yaml"
Change the version of the chartURL from 0.0.1 to 0.0.2
If you are curious, take a look in the templates directory of the 0.0.2 helm chart.
You will find that there is a post-upgrade hook: "post-upgrade-job.yaml"
Check the command in that file. This command represents the application-specific day2 operation,
which will be run on all the application instances as part of an upgrade.
The SQL command itself is in the "values.yaml" file of the chart.
Now apply the changes and upgrade the instances:
$ kubectl apply -f basic-web-app-service-composition-localchart.yaml --kubeconfig=provider.conf
The Job should have run and succeeded, proceeding to delete itself.
Verify this by checking the pods once again:
$ kubectl get pods -A
Check the application once again. There should be a new user added.
- curl -v localhost:5000/users
Clean up:
$ kubectl delete -f basic-web-app-service-composition-localchart.yaml --kubeconfig=provider.conf