Kubernetes Deployment
This directory contains Kubernetes manifests for deploying the Go REST API application.
Files
deployment.yaml
: Defines the Deployment for the Go REST API applicationservice.yaml
: Exposes the Deployment as a Service within the clusterconfigmap.yaml
: Contains configuration data as key-value pairsingress.yaml
: Configures ingress for external access to the Service
Local Deployment with Docker Desktop or Minikube
Prerequisites
- Docker Desktop with Kubernetes enabled, or Minikube installed
- kubectl CLI tool installed
Steps for Local Deployment
-
Start your local Kubernetes cluster:
- For Docker Desktop: Enable Kubernetes in Docker Desktop settings
- For Minikube: Run
minikube start
-
Build your Docker image locally:
docker build -t go-rest-api:latest -f ../../deployments/docker/Dockerfile ../..
-
If using Minikube, load the image into Minikube:
minikube image load go-rest-api:latest
-
Update the image in
deployment.yaml
:image: go-rest-api:latest
-
Apply the Kubernetes manifests:
kubectl apply -f .
-
Verify the deployment:
kubectl get deployments
kubectl get services
kubectl get pods -
Access the application:
- The API should now be accessible at
http://localhost:30080
- If you're using Docker Desktop with Kubernetes, you might need to use
http://localhost:30080
- If you're using Minikube, you might need to run
minikube service go-rest-api-service --url
to get the correct URL
- The API should now be accessible at
Deployment Steps (for non-local environments)
-
Ensure you have
kubectl
installed and configured to interact with your Kubernetes cluster. -
Update the image in
deployment.yaml
to point to your container registry:image: your-registry/go-rest-api:latest
-
Apply the Kubernetes manifests:
kubectl apply -f .
-
Verify the deployment:
kubectl get deployments
kubectl get services
kubectl get pods -
If using Ingress, ensure you have an Ingress controller installed in your cluster.
Scaling
To scale the number of replicas, you can use: