I'm deploying a microservices nodejs express application to GKE, I successfully deployed the services (one as Ingress service with static IP @ and one as NodePort service which will not be exposed to Internet).
Now I'm trying to deploy the api gateway which is an express-gateway application, I deployed it in first time as a LoadBalancer service and it's working , here is my service code :
apiVersion: v1
kind: Service
metadata:
name: express-gateway-balancer
spec:
selector:
app: express-gateway
type: LoadBalancer
ports:
- protocol: TCP
port: 80
targetPort: 8080
Now I must transform the trafic to HTTPS to be able to call the API endpoints front my react frontend application which is running with HTTPS, so I did a research and the way is to expose the api gateway application as an Ingress not LoadBalancer.
So I did the changes (the same I did with the rest of my deployments)and created a static IP @ "gateway-ip" to expose it via Ingress :
Here is my service.yaml file :
apiVersion: v1
kind: Service
metadata:
name: express-gateway-service
spec:
selector:
app: express-gateway
type: NodePort
ports:
- protocol: TCP
port: 80
targetPort: 8080
My Ingress.yaml file :
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: gateway-service-ingress
annotations:
kubernetes.io/ingress.global-static-ip-name: "gateway-ip"
spec:
backend:
serviceName: express-gateway-service
servicePort: 80
Here is my deployment file :
apiVersion: apps/v1
kind: Deployment
metadata:
name: express-gateway
labels:
app: express-gateway
spec:
selector:
matchLabels:
app: express-gateway
replicas: 3
template:
metadata:
labels:
app: express-gateway
spec:
containers:
- name: express-gateway
image: gcr.io/PROJECT_ID/apigatewayservice:v1
ports:
- name: gateway
containerPort: 8080
- name: admin
containerPort: 9876
Here are screenshot of the error I got :
Any solutions ? Thanks
Do you have a default endpoint of all your scheduled pods? I mean "/" ? Ingress does the health check readiness prob inbuilt that checks if "/" is reachable or not. If not, it will declare it as unhealthy. Hope this helps.