nginx-ingress

by joaquinito2051

Helm chartv0.21.1App 0.14.0

An nginx Ingress controller that uses ConfigMap to store the nginx configuration.

About this chart

nginx-ingress

nginx-ingress is an Ingress controller that uses ConfigMap to store the nginx configuration.

To use, add the kubernetes.io/ingress.class: nginx annotation to your Ingress resources.

TL;DR;

$ helm install stable/nginx-ingress

Introduction

This chart bootstraps an nginx-ingress deployment on a Kubernetes cluster using the Helm package manager.

Prerequisites

  • Kubernetes 1.6+

Installing the Chart

To install the chart with the release name my-release:

$ helm install --name my-release stable/nginx-ingress

The command deploys nginx-ingress on the Kubernetes cluster in the default configuration. The configuration section lists the parameters that can be configured during installation.

Tip: List all releases using helm list

Uninstalling the Chart

To uninstall/delete the my-release deployment:

$ helm delete my-release

The command removes all the Kubernetes components associated with the chart and deletes the release.

Configuration

The following table lists the configurable parameters of the nginx-ingress chart and their default values.

ParameterDescriptionDefault
controller.namename of the controller componentcontroller
controller.image.repositorycontroller container image repositoryquay.io/kubernetes-ingress-controller/nginx-ingress-controller
controller.image.tagcontroller container image tag0.14.0
controller.image.pullPolicycontroller container image pull policyIfNotPresent
controller.confignginx ConfigMap entriesnone
controller.hostNetworkIf the nginx deployment / daemonset should run on the host's network namespace. Do not set this when controller.service.externalIPs is set and kube-proxy is used as there will be a port-conflict for port 80false
controller.defaultBackendServicedefault 404 backend service; required only if defaultBackend.enabled = false""
controller.electionIDelection ID to use for the status updateingress-controller-leader
controller.extraEnvsany additional environment variables to set in the pods{}
controller.extraContainersSidecar containers to add to the controller pod. See LemonLDAP::NG controller as example{}
controller.extraVolumeMountsAdditional volumeMounts to the controller main container{}
controller.extraVolumesAdditional volumes to the controller pod{}
controller.extraInitContainersContainers, which are run before the app containers are started[]
controller.ingressClassname of the ingress class to route through this controllernginx
controller.scope.enabledlimit the scope of the ingress controllerfalse (watch all namespaces)
controller.scope.namespacenamespace to watch for ingress"" (use the release namespace)
controller.extraArgsAdditional controller container arguments{}
controller.kindinstall as Deployment or DaemonSetDeployment
controller.daemonset.useHostPortIf controller.kind is DaemonSet, this will enable hostPort for TCP/80 and TCP/443false
controller.tolerationsnode taints to tolerate (requires Kubernetes >=1.6)[]
controller.affinitynode/pod affinities (requires Kubernetes >=1.6){}
controller.minReadySecondshow many seconds a pod needs to be ready before killing the next, during update0
controller.nodeSelectornode labels for pod assignment{}
controller.podAnnotationsannotations to be added to pods{}
controller.replicaCountdesired number of controller pods1
controller.minAvailableminimum number of available controller pods for PodDisruptionBudget1
controller.resourcescontroller pod resource requests & limits{}
controller.lifecyclecontroller pod lifecycle hooks{}
controller.service.annotationsannotations for controller service{}
controller.service.labelslabels for controller service{}
controller.publishService.enabledif true, the controller will set the endpoint records on the ingress objects to reflect those on the servicefalse
controller.publishService.pathOverrideoverride of the default publish-service name""
controller.service.clusterIPinternal controller cluster service IP""
controller.service.externalIPscontroller service external IP addresses. Do not set this when controller.hostNetwork is set to true and kube-proxy is used as there will be a port-conflict for port 80[]
controller.service.externalTrafficPolicyIf controller.service.type is NodePort or LoadBalancer, set this to Local to enable source IP preservation"Cluster"
controller.service.healthCheckNodePortIf controller.service.type is NodePort or LoadBalancer and controller.service.externalTrafficPolicy is set to Local, set this to the managed health-check port the kube-proxy will expose. If blank, a random port in the NodePort range will be assigned""
controller.service.loadBalancerIPIP address to assign to load balancer (if supported)""
controller.service.loadBalancerSourceRangeslist of IP CIDRs allowed access to load balancer (if supported)[]
controller.service.targetPorts.httpSets the targetPort that maps to the Ingress' port 8080
controller.service.targetPorts.httpsSets the targetPort that maps to the Ingress' port 443443
controller.service.typetype of controller service to createLoadBalancer
controller.service.nodePorts.httpIf controller.service.type is NodePort and this is non-empty, it sets the nodePort that maps to the Ingress' port 80""
controller.service.nodePorts.httpsIf controller.service.type is NodePort and this is non-empty, it sets the nodePort that maps to the Ingress' port 443""
controller.livenessProbe.initialDelaySecondsDelay before liveness probe is initiated10
controller.livenessProbe.periodSecondsHow often to perform the probe10
controller.livenessProbe.timeoutSecondsWhen the probe times out5
controller.livenessProbe.successThresholdMinimum consecutive successes for the probe to be considered successful after having failed.1
controller.livenessProbe.failureThresholdMinimum consecutive failures for the probe to be considered failed after having succeeded.3
controller.livenessProbe.portThe port number that the liveness probe will listen on.10254
controller.readinessProbe.initialDelaySecondsDelay before readiness probe is initiated10
controller.readinessProbe.periodSecondsHow often to perform the probe10
controller.readinessProbe.timeoutSecondsWhen the probe times out1
controller.readinessProbe.successThresholdMinimum consecutive successes for the probe to be considered successful after having failed.1
controller.readinessProbe.failureThresholdMinimum consecutive failures for the probe to be considered failed after having succeeded.3
controller.readinessProbe.portThe port number that the readiness probe will listen on.10254
controller.stats.enabledif true, enable "vts-status" pagefalse
controller.stats.service.annotationsannotations for controller stats service{}
controller.stats.service.clusterIPinternal controller stats cluster service IP""
controller.stats.service.externalIPscontroller service stats external IP addresses[]
controller.stats.service.loadBalancerIPIP address to assign to load balancer (if supported)""
controller.stats.service.loadBalancerSourceRangeslist of IP CIDRs allowed access to load balancer (if supported)[]
controller.stats.service.typetype of controller stats service to createClusterIP
controller.metrics.enabledif true, enable Prometheus metrics (controller.stats.enabled must be true as well)false
controller.metrics.service.annotationsannotations for Prometheus metrics service{}
controller.metrics.service.clusterIPcluster IP address to assign to service""
controller.metrics.service.externalIPsPrometheus metrics service external IP addresses[]
controller.metrics.service.loadBalancerIPIP address to assign to load balancer (if supported)""
controller.metrics.service.loadBalancerSourceRangeslist of IP CIDRs allowed access to load balancer (if supported)[]
controller.metrics.service.servicePortPrometheus metrics service port9913
controller.metrics.service.targetPortPrometheus metrics target port10254
controller.metrics.service.typetype of Prometheus metrics service to createClusterIP
controller.customTemplate.configMapNameconfigMap containing a custom nginx template""
controller.customTemplate.configMapKeyconfigMap key containing the nginx template""
controller.headersconfigMap key:value pairs containing the custom headers for Nginx{}
controller.updateStrategyallows setting of RollingUpdate strategy{}
defaultBackend.namename of the default backend componentdefault-backend
defaultBackend.image.repositorydefault backend container image repositoryk8s.gcr.io/defaultbackend
defaultBackend.image.tagdefault backend container image tag1.3
defaultBackend.image.pullPolicydefault backend container image pull policyIfNotPresent
defaultBackend.extraArgsAdditional default backend container arguments{}
defaultBackend.tolerationsnode taints to tolerate (requires Kubernetes >=1.6)[]
defaultBackend.affinitynode/pod affinities (requires Kubernetes >=1.6){}
defaultBackend.nodeSelectornode labels for pod assignment{}
defaultBackend.podAnnotationsannotations to be added to pods{}
defaultBackend.replicaCountdesired number of default backend pods1
defaultBackend.minAvailableminimum number of available default backend pods for PodDisruptionBudget1
defaultBackend.resourcesdefault backend pod resource requests & limits{}
defaultBackend.service.annotationsannotations for default backend service{}
defaultBackend.service.clusterIPinternal default backend cluster service IP""
defaultBackend.service.externalIPsdefault backend service external IP addresses[]
defaultBackend.service.loadBalancerIPIP address to assign to load balancer (if supported)""
defaultBackend.service.loadBalancerSourceRangeslist of IP CIDRs allowed access to load balancer (if supported)[]
defaultBackend.service.typetype of default backend service to createClusterIP
imagePullSecretsname of Secret resource containing private registry credentialsnil
rbac.createif true, create & use RBAC resourcestrue
serviceAccount.createif true, create a service account``
serviceAccount.nameThe name of the service account to use. If not set and create is true, a name is generated using the fullname template.``
revisionHistoryLimitThe number of old history to retain to allow rollback.10
tcpTCP service key:value pairs{}
udpUDP service key:value pairs{}
$ helm install stable/nginx-ingress --name my-release \
    --set controller.stats.enabled=true

Alternatively, a YAML file that specifies the values for the parameters can be provided while installing the chart. For example,

$ helm install stable/nginx-ingress --name my-release -f values.yaml

A useful trick to debug issues with ingress is to increase the logLevel as described here

$ helm install stable/nginx-ingress --set controller.extraArgs.v=2

Prometheus Metrics

The Nginx ingress controller can export Prometheus metrics. In order for this to work, the VTS dashboard must be enabled as well.

$ helm install stable/nginx-ingress --name my-release \
    --set controller.stats.enabled=true \
    --set controller.metrics.enabled=true

You can add Prometheus annotations to the metrics service using controller.metrics.service.annotations. Alternatively, if you use the Prometheus Operator, you need to create a ServiceMonitor as follows:

apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: nginx-ingress-service-monitor
spec:
  jobLabel: nginx-ingress
  selector:
    matchLabels:
      app: nginx-ingress
      release: <RELEASE>
  namespaceSelector:
    matchNames:
      - <RELEASE_NAMESPACE>
  endpoints:
    - port: metrics
      interval: 30s

Tip: You can use the default values.yaml

ExternalDNS Service configuration

Add an ExternalDNS annotation to the LoadBalancer service:

annotations:
  external-dns.alpha.kubernetes.io/hostname: kubernetes-example.com.

AWS L7 ELB with SSL Termination

Annotate the controller as shown in the nginx-ingress l7 patch:

controller:
  service:
    targetPorts:
      http: http
      https: http
    annotations:
      service.beta.kubernetes.io/aws-load-balancer-ssl-cert: arn:aws:acm:XX-XXXX-X:XXXXXXXXX:certificate/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX
      service.beta.kubernetes.io/aws-load-balancer-b

Deploy nginx-ingress with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has nginx-ingress on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartnginx-ingress is pinned at v0.21.1 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply