This article assumes that you have:
- Docker installed in your local system.Setup Docker
- A DockerHub account. Signup for DockerHub
- A running Kubernetes cluster. Setup a cluster in GKE
2. Write a Dockerfile
docker build -t rounakraj8/demo:latest .
docker push rounakraj8/demo:latest
kubectl create deployment demo --image=rounakraj8/demo:latest
Alternatively, you can create deployment.yaml file and achieve the same results using kubectl apply -f deployment.yaml command.
kubectl expose deployment demo --name=demo --port=80 --target-port=8080 --type=LoadBalancer
Alternatively, you can create service.yaml file and achieve the same results
using kubectl apply -f service.yaml command.
kubectl scale deployment demo --replicas=2
To test this setup/demo, you will have to hit the hello API.
After creating the service, this service will get an external/public API(This may take couple of minutes).
Once you get the IP, you can hit `http://xxx.xxx.xxx.xxx/hello/someName`.
If you get `Hello! SomeName` as response, then you have successfully completed the demo.
kubectl delete svc demo
kubectl delete deployment demo