Test Your Application in the Kubernetes Setup on the Google Cloud Platform
Before you begin
- Google cloud account with a project and cluster.
- Google Cloud SDK
- Kubectl
- Procedure
- From a terminal, follow these steps:
gcloud auth login gcloud config set project <your project name> gcloud config set container/cluster <your cluster name> gcloud container clusters get-credentials <your cluster name> --zone <your cluster zone name> kubectl get nodes
- Tag the application image created in the previous step.
docker tag bwce-rest-bookstore-app gcr.io/<your project name>/bwce-rest-bookstore-app
- Push your application image to Google Container Registry.
gcloud docker push gcr.io/<your project name>/bwce-rest-bookstore-app
- Confirm that the image is present in the Google Container Registry.
- Open
manifest.yml
file and update application image name. Ensure the image name follows the format:gcr.io/<your gcloud project name>/<image name>
- Run the following command to create the service:
kubectl create -f manifest.yml
- To check that application has started successfully, run the command
kubectl logs pod-name
- After few minutes, the external IP is available. Check it using the following command:
kubectl get service rest-bookstore-app
- Retrieve the swagger doc using
http://<external ip>/ swagger
. - Click any of the operations, such as POST, GET, PUT, DELETE as displayed on the web page and click Try it out!.
- Expand the Books and Events headers and test the operations