Demo application
Build this application in your local env using command -
docker build -t my-go-app .
Run this application using below command -
docker run -p 8080:8081 -it my-go-app
or in detached mode
docker run -p 8080:8081 -d my-go-app
Awesome, if we open up http://localhost:8080 within our browser, we should see that our application is successfully responding with Hello, "/".
To run it in cloud, k8s is used and few required objects in the cluster are created as mentioned below.
- certificate
- ingress
- deployment
- service
- service-account
Note - Infra for this application to run is created in https://github.com/contino/demo-infra-gcp
-
Create below mentioned env variables in CircleCi with respective values
CLUSTER_NAME = demo-application CLUSTER_REGION = europe-west1 GCP_CREDS = <cicd-pipeline serviceaccount json key data> GCP_PROJECT = jagendra-atal-prakash-contino IMAGE_NAME = demo-application
-
deployment.yaml file is the only place where 2 variables (IMAGE & VERSION) have to be substituted which is done already in pipeline as given below
cat k8s/*.yaml | envsubst | kubectl apply -f -
-
Create multi-tenant environment using seperate namespace and move application to spicific namespace
-
Introduce podsecuritypolicy to achieve least privelage best practice
-
Introduce securitycontext and container must not run as root
-
Introduce Horizontal Pod Autoscaler/Vertical Pod Autoscaler accordingly
-
Introduce LimitRange for deployments
-
Review "Smoke test" step in pipeline and improve that accordingly