- Clone this repo.
- cd to softwarecontainerization/helm_chart
- run
helm install . --generate-nameon google kubernetes engine or,
runmicrok8s helm3 install . --generate-nameon local machine / microk8s. - The app can be accessed on port 30002, or on the IP of Google Cloud's load balancer, which can be seen in the ingress section of google kubernetes engine.
We made a to-do list which can:
- Add Tasks
- Delete Tasks
- Filter tasks as Completed or Active
It has 3 components:
- The Front-end, made using ReactJS.
- The API server, made using Python-Flask.
- The database, which is a postgres DB.
All the components mentioned above run in their own containers and are exposed via services called inventory-ui-service, inventory-api-service and postgres-service respectively.
We also have 2 ingress rules that allow https connections to the UI and API called ui-ingress and api-ingress respectively.
-
Persistent layer (SQL or No-SQL database)
We have created a deployment for the postgresql DB calledpostgres-deployment, along with a persistent volume and a persistent volume claim calledpostgres-pv-claim.
The database is exposed via a service calledpostgres-service.
The credentials for the database is stored in a secret calledpostgres-secret.
All the yaml files for the database are in the directory/helm_chart/charts/db/templates. -
REST API
We have made an API server with python-flask which handles GET, POST and DELETE requests to the database. The API is exposed via a service calledinventory-api-service.
Since our front-end is client-side rendered, it means the requests to the API from the front-end will be coming from the client's browser, and not from somewhere within our k8s cluster. So we have decided to make aNodePortfor theinventory-api-service.
We have also made an ingress calledapi-ingressto serve requests over https with a self-signed certificate.
All the yaml files for the API are in the directory/helm_chart/charts/api/templates. -
Web front-end
The front-end is made using ReactJS.
It is exposed via a service calledinventory-ui-service, which uses aNodePortsince the requests to the front-end will be coming from outside the cluster.
We also have an ingress calledui-ingressto serve requests over https with a self signed certificate.
All the yaml files for the front-end are in the directory/helm_chart/templates. -
Transport Level Security
We have configured TLS and serve https requests by using a self-signed certificate generated with openssl. The key and certificate secrets are stored inside a secret calledmy-tls-secret. Both our ingress use the same TLS secret. -
Helm Chart
We have configured a helm chart to manage installation, updates, rollbacks and uninstallation.
Everything can be installed by a single command from within the /helm_chart directory:helm install . --generate nameon google kubernetes engine or,microk8s helm3 install . --generate-nameon local machine / microk8s. -
Security - Network Policies
We have configured a network policy namedapi-allowwhich only allows ingress traffic from the API to the DB and blocks everything else. Since the DB is only ever accessed by the API, doing this made sense. -
Security - RBAC
We have created 2 users -readeruserandwriteruser. Thereaderusercan only executekubectl get,kubectl watchandkubectl listcommands. So it is a 'read-only' user. Thewriteruser, in addition to the commands executed by thereaderusercan also executekubectl create,kubectl update,kubectl patchandkubectl deletecommands.
We able to get RBAC working on our local machine, but not on google cloud. -
Google Cloud Platform
We were able to perform everything on google cloud, except for RBAC.
