This is a simple application written in nodejs and deployed to knative. This exposes a GET endpoint which returns a message along with the value of environment variable.
# Build the container image (Change the docker hub user name accordingly)
docker build -t abhishekjv/helloworld-nodejs .
# Push the image to docker hub (Change the docker hub user name accordingly)
docker push abhishekjv/helloworld-nodejs
Knative is setup.
kubectl apply -f serving/service.yaml
Note: These commands are for GKE. Minikube has different commands to find the IP. (To be updated)
# Get the IP address
export IP_ADDRESS=$(kubectl get svc istio-ingressgateway --namespace istio-system --output 'jsonpath={.status.loadBalancer.ingress[0].ip}')
# Get the Host URL
export HOST_URL=$(kubectl get route helloworld-nodejs --output jsonpath='{.status.domain}')
curl -H "Host: ${HOST_URL}" http://${IP_ADDRESS}
kubectl delete -f serving/service.yaml
Image is available in docker hub.
kubectl apply -f blue-green/blue-app.yaml
This will deploy blue version of the application and created a route named 'blue-green-app-route'. This route is configured to attract 100% of the traffic. Ref the traffic settings below
traffic:
- configurationName: helloworld-nodejs-blue
percent: 100 # All traffic goes to this revision
Hit the URL
curl -H "Host: blue-green-app-route.default.example.com" http://${IP_ADDRESS}
kubectl apply -f blue-green/green-app.yaml
This will deploy updated version of the application. A new revision will be created here, and the same route created for blue app will be used. Here, the route is configured to not attact any traffic at this moment. Hence, any request on the route will still be served by the blue app. Ref the traffic settings below
traffic:
- configurationName: helloworld-nodejs-blue
percent: 100 # All traffic goes to this revision
- configurationName: helloworld-nodejs-green
percent: 0
kubectl apply -f blue-green/distribute-traffic.yaml
Here, the traffic management is updated to send 50% of the traffic to blue app and 50% of traffic to green app. Hit the route and observe the traffic being split among these apps. Ref the traffic settings below
traffic:
- configurationName: helloworld-nodejs-blue
percent: 50 # All traffic goes to this revision
- configurationName: helloworld-nodejs-green
percent: 50
kubectl apply -f blue-green/green-app-complete-traffic.yaml
This will move all traffic to the updated app. Ref the traffic settings below
traffic:
- configurationName: helloworld-nodejs-blue
percent: 0 # All traffic goes to this revision
- configurationName: helloworld-nodejs-green
percent: 100
kubectl delete -f blue-green/green-app-complete-traffic.yaml
kubectl delete -f blue-green/distribute-traffic.yaml
kubectl delete -f blue-green/green-app.yaml
kubectl delete -f blue-green/blue-app.yaml
This will take the latest code from github, build the container and then will serve it as well. Kaniko build is used here to build the container images and push to dockerhub.
kubectl apply -f build/build-and-serve-docker.yaml
# Get the Host URL
export HOST_URL=$(kubectl get route knative-hw-serve-sample --output jsonpath='{.status.domain}')
TO check the progress of build:
kubectl logs --follow --container=build-step-build-and-push <POD>