-
Notifications
You must be signed in to change notification settings - Fork 82
/
steps.txt
72 lines (50 loc) · 3.07 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
Day2 operation on a 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 ResourceComposition instance, which upgrades
the application instance, which in turn updates application's kubernetes resources..
Install KubePlus:
$ 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-4.0.1.tgz?raw=true" -n $KUBEPLUS_NS --kubeconfig=provider.conf
$ until kubectl get pods -A | grep kubeplus | grep Running; do echo "Waiting for KubePlus to start.."; sleep 1; done
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
$ until kubectl get crds | grep webappservices.platformapi.kubeplus; do echo "Waiting for CRD to be registered.."; sleep 1; done
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
Open a new terminal and run:
$ kubectl port-forward <web-app-deploy-pod> -n bwa-tenant1 5000:5000
- get the name of the KubePlus Pod from the previous command.
From another terminal window run the following command to verify the list of users:
$ curl -v http://localhost:5000/users
There should be one user named 'kulkarni' present.
Perform application-specific day2 operation:
---------------------------------------------
Change the chartURL in the ResourceComposition file "basic-web-app-service-composition-localchart.yaml"
from basicwebapp-0.0.1.tgz to basicwebapp-0.0.2.tgz.
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.
- curl -v localhost:5000/users
There should be a new user named 'emin' present.
Clean up:
$ kubectl delete -f basic-web-app-service-composition-localchart.yaml --kubeconfig=provider.conf