Deploy Go to Kubernetes

Deploy Go to Kubernetes by building a Docker image, creating a Deployment manifest, and applying it with kubectl.

Deploy your Go application to Kubernetes by building a Docker image, pushing it to a registry, and applying a Deployment manifest.

  1. Build the Docker image using your Go binary and push it to your container registry.
docker build -t your-registry/your-app:latest .
docker push your-registry/your-app:latest
  1. Create a deployment.yaml file defining the container image and resource limits.
apiVersion: apps/v1
kind: Deployment
metadata:
  name: go-app
spec:
  replicas: 1
  selector:
    matchLabels:
      app: go-app
  template:
    metadata:
      labels:
        app: go-app
    spec:
      containers:
      - name: go-app
        image: your-registry/your-app:latest
        ports:
        - containerPort: 8080
  1. Apply the manifest to your cluster to start the application.
kubectl apply -f deployment.yaml
  1. Verify the deployment is running and healthy.
kubectl get pods -l app=go-app