I'm trying to set up a simple HTTP web server on Kubernetes and expose it with the Ephemeral external IP. However when launch it and try and visit one of the URLs at x.x.x.x/something
I get:
Error: Server Error
The server encountered a temporary error and could not complete your request.
Please try again in 30 seconds.
My config is simply:
apiVersion: apps/v1
kind: Deployment
metadata:
name: web
labels:
app: web
spec:
replicas: 1
selector:
matchLabels:
app: web
template:
metadata:
labels:
app: web
spec:
containers:
- name: web
image: gcr.io/my-repo-name
ports:
- containerPort: 8080
livenessProbe:
httpGet:
path: /healthz
port: 8080
readinessProbe:
initialDelaySeconds: 10
httpGet:
path: /healthz
port: 8080
---
apiVersion: v1
kind: Service
metadata:
name: web-balancer-service
spec:
selector:
app: web
type: NodePort
ports:
- protocol: TCP
port: 8080
targetPort: 32111
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: my-ingress-app
spec:
backend:
serviceName: web-balancer-service
servicePort: 8080
If I describe the ingress I see that the backend is "Unknown". Is there a problem with my spec?
Name: my-ingress-app
Namespace: default
Address: x.x.x.x
Default backend: web-balancer-service:8080 (10.60.0.57:32111)
Rules:
Host Path Backends
---- ---- --------
* * web-balancer-service:8080 (10.60.0.57:32111)
Annotations:
ingress.kubernetes.io/backends: {"k8s-be-30330--f4bbd8cbe40f4567":"Unknown"}
ingress.kubernetes.io/forwarding-rule: k8s-fw-default-my-ingress-app--f4bbd8cbe40f4567
ingress.kubernetes.io/target-proxy: k8s-tp-default-my-ingress-app--f4bbd8cbe40f4567
ingress.kubernetes.io/url-map: k8s-um-default-my-ingress-app--f4bbd8cbe40f4567
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal ADD 7m18s loadbalancer-controller default/my-ingress-app
Normal CREATE 6m12s loadbalancer-controller ip: x.x.x.x
The error message you are getting is the error from Google Kubernetes Engine (GKE), so I am assuming you are running in in GKE on Google Cloud.
First, make sure that containers (pods of the deployment) are actually listening to the port 32111
. You have this as the targetPort
on the service, which means the service will receive traffic on port 8080
, but send them to the port 32111
of the pods that it matches. Looks like:
--(traffic)---> :8080 (service) ---> :32111 (pods)
I suspect this, because in your pod spec you have containerPort: 8080
, which is an indicator that the pod actually listens to 8080
as well, not 32111
.
Therefore, first, try to change the targetPort
of the Service to 8080
as well.
After giving it some time, if it doesn't start working, check if you have actually HTTP Load Balancing enabled in your cluster. It looks like this, when you are creating the cluster on the Google Cloud Console:
On the existing cluster, go to its details on GCP console, and check the addons section: