Target application might be found here:
https://github.com/stantonk/java-docker-example.git
- docker
- docker-machine
- helm
- kubectl
- minikube
- login to dockerhub
docker login
- change
.env
file and setDOCKERHUB_OWNER
to username (the same as in previous login command) java.sh
- build java base image, upload to dockerhubbuild.sh
- build application image, upload to dockerhubdeploy.sh
- spin up kubernetes on minikube, configure RBAC and initialize helm- change something in java code
build.sh
- re-build images, re-upload to dockerhubrefresh.sh
- refresh helm chartcleanup.sh
- clean everything up (excluding dockerhub images)
Resulting service will be available via NodePort at:
http:// < minikube ip > :30303/api/tweets
You may want to open it with:
minikube service demo-example-http --profile demo --namespace default
Or access with port-forward:
POD=$(kubectl get pods -n default --selector app=example \
-o template --template '{{range .items}}{{.metadata.name}} {{.status.phase}}{{"\n"}}{{end}}' \
| grep Running | head -1 | cut -f1 -d' ')
kubectl port-forward -n default ${POD} 8081:8080
Or via Ingress Controller:
echo "$(minikube ip --profile demo) jexmpl.example.com" | sudo tee -a /etc/hosts
Then open:
http://jexmpl.example.com/api/tweets
You may try ngrok as the last chance option
-
Can we do a HA of a database? Any way to keep the data persistent when pods are recreated?
We have stateless frontend, but stateful backend. Of course we can have HA configuration in such configuration.
We can set following option to helm to enable HA:
--set mysql.persistence.enabled=true
-
Add CI to the deployment process.
Just combine shell scripts from workflow above
-
Split your deployment into prd/qa/dev environment.
Tweak .env file
-
Please suggest a monitoring solutions for your system. How would you notify an admin that the resources are scarce?
A lot of option, you may want to start from prometheus-operator from coreos
You may use my work or its parts as you wish, but only with proper credits to me like this:
Viacheslav - avoidik@gmail.com