Nginx ingress in kubernetes

There are 3 ways to expose your service: NodePort, LoadBalancer, Ingress, next I will introduce about how to use ingress.

1.Deploy ingress controller

You need deploy ingress controller at first which will start nginx pods, then nginx will bind domains and listen to the requests.

I built a common ingress chart for different service, I only need change values-<service>.yaml and deploy script if any changes.

Another key point is that you must be clear about ingress-class, different service use different ingress-class, it will be quite messy if you mistake them.

  - /nginx-ingress-controller
  - --default-backend-service=$(POD_NAMESPACE)/default-http-backend
  - --configmap=$(POD_NAMESPACE)/nginx-configuration
  - --tcp-services-configmap=$(POD_NAMESPACE)/tcp-services
  - --udp-services-configmap=$(POD_NAMESPACE)/udp-services
  - --ingress-class={{ .Values.server.namespace }}
  - --sort-backends=true

2.Configure service ingress

Next we need configure service ingress which will append nginx server configuration dynamically.

I also built a service chart which include environment configurations, Jenkins & Helm will use different values-<env>.yaml when execute pipeline deployment.

Ingress example:

apiVersion: extensions/v1beta1
kind: Ingress
  name: {{ }}{{ .Values.deploy.subfix }}
  namespace: {{ }}
  annotations: "{{ .Values.ingress.class }}" "true" "false" / 10m
  - host: {{ .Values.ingress.hostname }}
      - path: {{ .Values.ingress.path }}
          serviceName: {{ }}{{ .Values.deploy.subfix }}
          servicePort: {{ .Values.container.port }}