DevPill #3: How to deploy a container to your Kubernetes cluster (GKE)
Source: Dev.to

Deployment Manifest
apiVersion: apps/v1
kind: Deployment
metadata:
name: api-gateway
spec:
replicas: 1
selector:
matchLabels:
app: api-gateway
template:
metadata:
labels:
app: api-gateway
spec:
containers:
- name: api-gateway
image: us-central1-docker.pkg.dev///api-gateway
ports:
- containerPort: 8081
resources:
requests:
memory: "128Mi"
cpu: "125m"
limits:
memory: "128Mi"
cpu: "125m"
env:
# Accessing an env variable from the app-config config map
- name: GATEWAY_HTTP_ADDR
valueFrom:
configMapKeyRef:
name: app-config
key: GATEWAY_HTTP_ADDR
- name: JAEGER_ENDPOINT
valueFrom:
configMapKeyRef:
name: app-config
key: JAEGER_ENDPOINT
Service Manifest
apiVersion: v1
kind: Service
metadata:
name: api-gateway
spec:
type: LoadBalancer
ports:
- port: 8081
targetPort: 8081
selector:
app: api-gateway
Deploy to GKE
-
Access Google Cloud Console and create your GKE cluster (this might take a while).
-
Retrieve cluster credentials:
gcloud container clusters get-credentials --region us-central-1 --project -
Upload the manifests:
kubectl apply -f infra/production/k8s/app-config.yaml kubectl apply -f infra/production/k8s/secrets.yaml kubectl apply -f infra/production/k8s/api-gateway-deployment.yaml -
Check the status of the deployments:
kubectl get deployments kubectl get pods