I followed this guide to install the nginx ingress controller in the GKE.
Afterwards I followed this guide to create the ingress resource for my service.
I already setup my test app and service succesfully. Tested this by port-forwarding to the container.
Setting up the ingress seemed fine but I can't get access to it. When opening the external ip the following 502 error is print:
Error: Server Error
The server encountered a temporary error and could not complete your request.
Please try again in 30 seconds.
Please see the describe
of the ingress:
│Name: teamcity │
│Namespace: default │
│Labels: <none> │
│Annotations: ingress.kubernetes.io/backends: {"k8s-be-31984--b5c10175cf4f125b":"UNHEALTHY"} │
│ ingress.kubernetes.io/forwarding-rule: k8s-fw-default-teamcity--b5c10175cf4f125b │
│ ingress.kubernetes.io/target-proxy: k8s-tp-default-teamcity--b5c10175cf4f125b │
│ ingress.kubernetes.io/url-map: k8s-um-default-teamcity--b5c10175cf4f125b │
│ kubectl.kubernetes.io/last-applied-configuration: │
│ {"apiVersion":"extensions/v1beta1","kind":"Ingress","metadata":{"annotations":{},"name":"teamcity","namespace":"default"},"spec":│
│{"backend... │
│API Version: extensions/v1beta1 │
│Kind: Ingress │
│Metadata: │
│ Creation Timestamp: 2019-11-02T12:49:21Z │
│ Generation: 1 │
│ Resource Version: 553521 │
│ Self Link: /apis/extensions/v1beta1/namespaces/default/ingresses/teamcity │
│ UID: 312aa230-fd6f-11e9-ad91-42010a84009d │
│Spec: │
│ Backend: │
│ Service Name: teamcity │
│ Service Port: 8111 │
│Status: │
│ Load Balancer: │
│ Ingress: │
│ Ip: 35.190.86.15 │
│Events: │
│ Type Reason Age From Message │
│ ---- ------ ---- ---- ------- │
│ Normal ADD 18m loadbalancer-controller default/teamcity │
│ Normal CREATE 17m loadbalancer-controller ip: 35.190.86.15
Additionally here is my yaml file for the whole mashup:
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: teamcity
labels:
app: teamcity
spec:
replicas: 1
selector:
matchLabels:
app: teamcity
template:
metadata:
labels:
app: teamcity
spec:
containers:
- name: teamcity-server
image: jetbrains/teamcity-server:latest
ports:
- containerPort: 8111
---
apiVersion: v1
kind: Service
metadata:
name: teamcity
labels:
app: teamcity
spec:
type: NodePort
ports:
- port: 8111
targetPort: 8111
protocol: TCP
selector:
app: teamcity
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: teamcity
spec:
backend:
serviceName: teamcity
servicePort: 8111
I'd like to know what I did wrong here.
You are using GKE ingress controller with that Ingress resource, not Nginx. And the prove is that it is creating all the resources to create a HTTP load balancer; forwarding rule, target proxy, url map, backend service.
You need to pass the annotation kubernetes.io/ingress.class: "nginx"
to your Ingress resource to let it know it shouod use Nginx Ingress Controller.
Now, you are getting 503 for while because GCP load balancers do not start working right away. Probably after about 3-4 minutes you will get 200.
As you are using ingress, the nginx service will be exposed to LoadBalancer, and others can be kept on clusterIPs only.
You can change the service to ClusterIP type instead of Nodeport here and try framing your ingress rule this way -
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
annotations:
kubernetes.io/ingress.class: nginx
name: rule-name
namespace: default
spec:
rules:
- host: hostname
http:
paths:
- backend:
serviceName: teamcity
servicePort: 8111
In the current scenario,you have not mapped any hostname to your ingress rule and if you don't have one specifically, you can just use the DNS name mapped against your publicIP/ ExternalIP of nginx.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.