This uses Spring webflux but in concepts are same for any REST based on Spring boot.
Based on - https://developer.okta.com/blog/2019/04/01/spring-boot-microservices-with-kubernetes https://github.com/oktadeveloper/okta-spring-boot-microservice-kubernetes
While the blog shows how to deploy in GCE, this implementation is generic and can be used to deploy in any cluster.
I had to make a few fixes to the charts and I use istio auto injection. I am not sure if google auto enables istio injection. The blog does not show/talk about envoy proxy injection which is the key feature of istio-service mesh. We will use minikube.
TODO- Deploy in AWS.
istioctl manifest apply --set profile=demo
kubectl label namespace default istio-injection=enabled
kubectl apply -f deployment-mongo.yml
Edit the application config to point to docker mongo, let your Spring app know where is the datasource
server.port=8000
spring.data.mongodb.host=mongodb
spring.data.mongodb.port=27017
gradle clean build
docker build -t demo-app:1.0 .
- Push docker image to repo
docker login
- Tag image first(mandatory) -
docker tag demo-app:1.0 hiteshjoshi1/demo-app:1.0
- Then push -
docker push hiteshjoshi1/demo-app:1.0
Note - if you are making changes and getting older images, check kuberntes image pull policy in deployment.yml
kubectl apply -f <(istioctl kube-inject -f deployment.yml)
export INGRESS_HOST= $(minikube ip)
export INGRESS_HOST=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.status.loadBalancer.ingress[0].ip}');
export INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="http2")].nodePort}')
curl http://$INGRESS_HOST:$INGRESS_PORT/kayaks
For non secured MS(starting point) see the branch
docker build -t demo-app-auth:1.0 .
docker tag demo-app-auth:1.0 hiteshjoshi1/demo-app-auth:1.0
docker push hiteshjoshi1/demo-app-auth:1.0
kubectl delete deployment <dep_name>
kubectl apply -f <(istioctl kube-inject -f deployment.yml)
export INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="http2")].nodePort}')
curl http://$INGRESS_HOST:$INGRESS_PORT/
curl http://$INGRESS_HOST:$INGRESS_PORT/kayaks
curl -H "Authorization: Bearer ${TOKEN}" http://$INGRESS_HOST:$INGRESS_PORT/kayaks