daxio / k8s-lemp

LEMP stack in a Kubernetes cluster
GNU General Public License v3.0
80 stars 44 forks source link

GCE Ingress health check failed #13

Closed Coolfeather2 closed 6 years ago

Coolfeather2 commented 7 years ago

Trying to convert this setup to use GCE ingress instead of nginx. The backend health check fails, I have changed the wp-service to type: NodePort instead of type: ClusterIP which gets created fine.

But when I create the ingress with kubernetes.io/ingress.class: "gce" the health check for the NodePort webpath: "/" fails.

Service: image Health check: image

chepurko commented 7 years ago

Any particular reason you're going with the GCE controller instead of the NGINX one?

Coolfeather2 commented 7 years ago

the NGINX one is stuck on creating ingress, and I don't understand how it works.

Coolfeather2 commented 7 years ago

Any updates?

chepurko commented 7 years ago

But when I create the ingress with kubernetes.io/ingress.class: "gce" the health check for the NodePort webpath: "/" fails.

Don't think this is the intended usage of that annotation. As far as I know, there are big implementation differences in the NGINX ingress vs the GCE ingress and the GCE ingress is still in beta.

I'm unfamiliar with the GCE ingress myself but I think it would involve more than changing the annotation for ingress. I would start by implementing the GCE ingress from scratch using the documentation.

Also, if you'd like to familiarise yourself with the NGINX ingress, there is a very in-depth documentation available at https://github.com/kubernetes/ingress-nginx

Regarding the NGINX being stuck on ingress creation, do you get any output from the NGINX ingress logs?

kubectl --namespace=nginx-ingress logs nginx-1524356077-l72fv --tail=20 -f

If there is no log output because the container isn't getting created, you should try pinpointing the reason why it's not being creating. Are there any errors if you run kubectl --namespace=nginx-ingress describe deployment nginx after creating the ingress?

Coolfeather2 commented 7 years ago

the GCE ingress so far just requires a backend url health check to the wordpress deployment cluster pod

basically where is the webpage that returns the http header: 200

chepurko commented 7 years ago

Are you bringing up a GCE ingress controller deployment? It sounds like you’re just changing the annotation in the wp/notls-Ingress.yaml file. In order to use an ingress you need an ingress controller (GCE or NGINX).

Unfortunately it’s a little more involved than that, the annotation is sort of just pointing to an ingress controller that you need to have running in another pod.

The default configuration in this repo uses an NGINX ingress controller which is under k8s-lemp/nginx.

You would need to bring up another pod using a deployment or replication controller similar to the rc.yaml in the GGE controller repo.

Then you would create the ingress resource. Start with the example in ingress-app.yaml. You’ll see an echoserver replication controller there which is like a simple web sever for testing your setup by echoing your IP address each time you hit it. And there is actually no such annotation kubernetes.io/ingress.class: "gce" specified in it that I can see...

Please try to bring up that example GCE controller and ingress and then gradually work in the wp deployment in this repo.

Coolfeather2 commented 7 years ago

it works like this for other deployments I've made and GCE ingresses do not require a ingress controller:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: jenkins
  namespace: jenkins
  annotations:
    kubernetes.io/tls-acme: "true"
    kubernetes.io/ingress.class: "gce"
spec:
  tls:
  - hosts:
    - jenkins.birdtronics.net
    secretName: jenkins-tls
  rules:
  - host: jenkins.birdtronics.net
    http:
      paths:
      - path: /
        backend:
          serviceName: jenkins-ui
          servicePort: 8080
  backend:
    serviceName: jenkins-ui
    servicePort: 8080
---
  kind: Service
  apiVersion: v1
  metadata:
    name: jenkins-ui
    namespace: jenkins
  spec:
    type: NodePort
    selector:
      app: master
    ports:
      - protocol: TCP
        port: 8080
        targetPort: 8080
        name: ui

I edited the notls-ingress.yaml to:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: wp-birdtronics
  namespace: wp-birdtronics
  annotations:
    kubernetes.io/ingress.class: "gce"
spec:
  rules:
  - host: birdtronics.net
    http:
      paths:
      - path: /
        backend:
          serviceName: wp-birdtronics
          servicePort: 80
  backend:
    serviceName: wp-birdtronics
    servicePort: 80
---
apiVersion: v1
kind: Service
metadata:
  name: wp-birdtronics
  namespace: wp-birdtronics
  labels:
    app: wp-birdtronics
spec:
  ports:
    - port: 80
      targetPort: 80
      protocol: TCP
      name: http
  selector:
    app: wp-birdtronics
    tier: frontend
  type: NodePort