A Kuberbetes Kustomization KRM config example to run the kubernetes-hello-world-api project.
Before we begin, make sure that you have the adjacent kubernetes-hello-world-api project and build the corresponding Docker image using the commands in the project's README.md.
It is also worth viewing the Makefile in this project. This houses most of the initial commands to manage the cluster.
In order to serve local Docker images to your Kubernetes cluster, we firstly need to call a script that will pull and run another Docker a registry container.
make local-registryAt this point, you should run the make docker-build-and-push-local command in the kubernetes-hello-world-api project to make the API Docker image available locally.
This will create the cluster and configure it to use the local Docker registry. It will also ensure that the local registry is running prior to the cluster's creation.
make create-clusterNow the cluster is running, you can now apply the KRM object configuration,
make apply-kustomize-baseYou can monitor the deployment rollout(s) by running the following command,
kubectl get pods -w
NAME READY STATUS RESTARTS AGE
hello-world-api-deployment-c8457c4df-nss7g 1/1 Running 0 11m
hello-world-api-deployment-c8457c4df-wjm5v 1/1 Running 0 11mYou can gain access to the hosted API using port forwarding to create a local relationship to the containerized API service.
kubectl port-forward service/hello-world-api-service 8080:80
Forwarding from 127.0.0.1:8080 -> 3000
Forwarding from [::1]:8080 -> 3000
curl http://127.0.0.1:8080/v1/hello/
{"message":"Hello world"}