I serve a frontend site with Go, and I deployed my service onto GKE using Docker. Sometimes the website loads “http://staging.crcl-app.com”, “http://www.staging.crcl-app.com”, and sometimes it returns a 502 Bad Gateway. It doesn’t seem to be a problem with my deployment, maybe something with Ingress? I have a cloud DNS setup with the domain as well that routes to the “crcl-global” IP I defined in ingress.yaml, I will attach screenshots of those.
deployment.yaml:
apiVersion: apps/v1
kind: Deployment
metadata:
name: staging-deployment
namespace: admin-ns
labels:
app: staging
spec:
replicas: 1
selector:
matchLabels:
app: staging
tier: web
template:
metadata:
labels:
app: staging
tier: web
spec:
containers:
- name: staging
image: # removed for stackoverflow
ports:
- containerPort: 3001
readinessProbe:
httpGet:
path: /healthz # GKE readinessProbe healthcheck
port: 3001
initialDelaySeconds: 5
periodSeconds: 10
livenessProbe:
httpGet:
path: /healthz # GKE livenessProbe healthcheck
port: 3001
initialDelaySeconds: 15
periodSeconds: 20
resources:
limits:
memory: 512Mi
cpu: "1"
requests:
memory: 256Mi
cpu: "0.2"
serviceAccountName: "admin-sa"
ingress.yaml:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: crcl-staging-ingress # name of service
namespace: admin-ns # this is the role in GCP it has, we need to give it perms so it can access secret manager, storage, etc.
annotations:
spec.ingressClassName: "nginx"
nginx.ingress.kubernetes.io/use-regex: "true"
nginx.ingress.kubernetes.io/rewrite-target: /$1
kubernetes.io/ingress.global-static-ip-name: crcl-global # Expose IP
networking.gke.io/managed-certificates: crcl-app-cert # Google managed certificates
labels:
app: staging
spec:
defaultBackend:
service:
name: crcl-gke-backend
port:
number: 80
rules:
- host: www.staging.crcl-app.com
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
service:
name: crcl-gke-backend
port:
number: 80
- host: api.staging.crcl-app.com
http:
paths:
- path: /api/*
pathType: ImplementationSpecific
backend:
service:
name: crcl-gke-backend
port:
number: 80
- host: staging.crcl-app.com
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
service:
name: crcl-gke-backend
port:
number: 80
---
apiVersion: v1
kind: Service
metadata:
name: crcl-gke-backend
namespace: admin-ns
labels:
app: staging
spec:
type: NodePort # Internal staging IP (Routed to by ingress)
selector:
app: staging
tier: web
ports:
- port: 80
targetPort: 3001