Deploy your Go application to Kubernetes by building a Docker image, pushing it to a registry, and applying a Deployment manifest.
- 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
- Create a
deployment.yamlfile 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
- Apply the manifest to your cluster to start the application.
kubectl apply -f deployment.yaml
- Verify the deployment is running and healthy.
kubectl get pods -l app=go-app