Python RestAPI for demo testing and creating platforms while development is still underway
The output you should get is:
{
"hostname": "pyhellow-api-xxxxxxxx-xxxxxx",
"greeting": "Hello World",
"now": "Fri, 24 Jul 2020 09:55:54 GMT"
}
If the OS Env variable HOSTNAME
isn't set your request will be:
{
"greeting": "Hello World",
"now": "Fri, 24 Jul 2020 09:55:54 GMT"
}
$ python3 src/main.api
- Python 3
- minikube
- kubectl
- helm version 3.x.x
- git
- curl
- EKS Cluster
- RBAC enabled
- Metrics server
Add helm repo
$ helm repo add pyhellow https://boldlink.github.io/pyhellow/charts/
$ helm repo update
Install the app
$ kubectl --context minikube create ns pyhellow
$ helm install pyhellow-api pyhellow/pyhellow-api -f charts/values-mini.yaml --kube-context=minikube -n pyhellow
Navigate service
$ minikube service pyhellw-api --url
$ curl http://192.168.99.100:31252/v1/api
Upgrade the app
$ helm upgrade pyhellow-api pyhellow/pyhellow-api -f charts/values-mini.yaml --kube-context=minikube -n pyhellow
Add helm repo
$ helm repo add pyhellow https://boldlink.github.io/pyhellow/charts/
$ helm repo update
Make sure your eks config is up-to-date
$ aws eks update-kubeconfig --name CLUSTER_NAME
Install the app
$ kubectl create ns pyhellow
$ helm install pyhellow-api pyhellow/pyhellow-api -f charts/values-aws.yaml -n pyhellow
Navigate to the service
$ kubectl get svc
# Add /vi/api to curl
$ curl http://xxxxxxxxx-xxxxxx.xx-xxxx-x.elb.amazonaws.com:31252/v1/api
Ugrade the app
helm upgrade pyhellow-api pyhellow/pyhellow-api -f charts/values-aws.yaml -n pyhellow
A demo pipeline was added as well configured for our environment, it includes the following steps:
- github: Run Superlinter to validate code syntax
- drone: SonarCube scanner for code analysis
- drone: Build and push docker image
- drone: Scan image with Clair
- drone: Deploy helm chart to dev
- drone: Deploy helm chart to prod
This github repo is also the Helm repo, bellow are the commands helm chart related (Yes still manual)
$ cd charts/
$ helm lint helm-chart-sources/*
$ helm package pyhellow-api/
$ helm repo index --url https://boldlink.github.io/pyhellow/charts/ --merge index.yaml .
Commit the changes and have fun :)