n42-gateway
by jcmoraisjr
N42 Gateway - Ingress and Gateway API controller built on HAProxy®
About this chart
N42 Gateway helm chart
N42 Gateway - Ingress and Gateway API controller built on HAProxy®
Introduction
This chart bootstraps a N42 Gateway deployment on a Kubernetes cluster using the Helm package manager.
Prerequisites
- Helm 3 installed, see helm 3 installation instructions
- Kubernetes 1.19+ with Beta APIs enabled
Installing the Chart
To install the latest stable version with the release name n42 in the current namespace and using default configurations:
$ helm repo add n42 https://n42-gateway.github.io/charts
$ helm install n42 n42/n42-gateway
The configuration section lists the parameters that can be configured during installation.
Installation tips:
- All resources will be created in the current namespace. Add
--create-namespace --namespace=<ns>command-line options to install N42 Gateway in another one - The default configuration installs N42 Gateway as a deployment, add
--set controller.kind=DaemonSetcommand-line option to install as a DaemonSet - The default service type is
LoadBalancer, add--set controller.service.type=<type>command-line option to change toClusterIPorNodePort - Ingress status will not report the IP address of the service unless you add
--set controller.publishService.enabled=truecommand line option - If the release name is
"n42"or contains"n42-gateway", the resource names will not add the release name prefix and will have a shorter name - Chart versions are in sync with minor N42 Gateway versions, so:
- Use eg
--version '~0.16'command-line option to install the latestv0.16release of N42 Gateway - See available chart and controller versions with
helm search repo n42 -l - Add
--develcommand-line option to enable or list non stable versions as well
- Use eg
Upgrading to a new Chart version
To upgrade the release n42-gateway to the latest stable version:
$ helm repo update n42
$ helm upgrade n42 n42/n42-gateway
Upgrade warning:: chart since v0.17 changed its name to N42 Gateway, see in the v0.17 release notes how to preserve backward compatibility.
Upgrade tips:
- helm preserve the installation options, eg a
--set controller.service.type=ClusterIPused when installing the chart doesn't need to be configured when upgrading it --versionand--develalso available to point to an older version or a non stable one
Uninstalling the Chart
To uninstall/delete the n42 release:
$ helm uninstall n42
The command removes all the Kubernetes components associated with the chart and deletes the release.
Running in Dual-Stack Mode
To run the N42 Gateway in dual-stack mode you will need a Kubernetes cluster that supports dual-stack services (v1.20+ with the IPv6DualStack feature gate enabled), and make the following configuration changes:
controller:
config:
bind-ip-addr-http: "[::]"
bind-ip-addr-tcp: "[::]"
bind-ip-addr-healthz: "::"
service:
ipFamilyPolicy: RequireDualStack
You may need to make additional configuration changes if you have an IPv6-only or IPv6-first dual-stack cluster.
For more information, see the Kubernetes IPv4/IPv6 dual-stack documentation for instructions on configuring your cluster.
Note that in IPv6-only mode, logging does not work by default. Enable the external/sidecar HAProxy setting and leave logs disabled to work around this:
controller:
logs:
enabled: false
haproxy:
enabled: true
Configuration
The following table lists the configurable parameters of the N42 Gateway chart and their default values.
| Parameter | Description | Default |
|---|---|---|
rbac.create | If true, create & use RBAC resources | true |
rbac.secret.write | If true, and rbac.create is true, add write access to secrets, used by acme | false |
rbac.security.enable | If true, and rbac.create is true, create & use PSP resources on Kubernetes clusters up to v1.25 | false |
serviceAccount.create | If true, create serviceAccount | true |
serviceAccount.name | ServiceAccount to be used | `` |
serviceAccount.automountServiceAccountToken | Automount API credentials for the ServiceAccount | true |
serviceAccount.annotations | A list of annotations to add to the ServiceAccount | `` |
controller.automountServiceAccountToken | Automount API credentials to the controller's pod | true |
controller.name | name of the controller component | controller |
controller.image.registry | controller container image registry | quay.io |
controller.image.repository | controller container image repository | n42-gateway/n42-gateway |
controller.image.tag | controller container image tag | v0.17.0-beta.3 |
controller.image.pullPolicy | controller container image pullPolicy | IfNotPresent |
controller.imagePullSecrets | controller image pull secrets | [] |
controller.extraArgs | extra command line arguments for N42 Gateway | {} |
controller.extraEnvs | extra environment variables for N42 Gateway | [] |
controller.extraVolumes | extra volumes for N42 Gateway | [] |
controller.extraVolumeMounts | extra volume mounts for N42 Gateway | [] |
controller.extraContainers | extra containers to N42 Gateway | [] |
controller.initContainers | extra init containers to N42 Gateway | [] |
controller.runtimeClassName | Runtime Class to be used | "" |
controller.template | custom template for N42 Gateway | {} |
controller.templateFile | custom haproxy template path for N42 Gateway | "" |
controller.defaultBackendService | backend service to use if defaultBackend.enabled==false | "" |
controller.ingressClass | name of the ingress class to route through this controller | haproxy |
controller.ingressClassResource.enabled | create an IngressClass resource for this controller | false |
controller.ingressClassResource.default | mark the IngressClass as default for the cluster | false |
controller.ingressClassResource.controllerClass | customizes the controller name | '' |
controller.ingressClassResource.parameters | {} | |
controller.gatewayClassResource.enabled | create a GatewayClass resource for this controller | false |
controller.haproxy.enabled | set true to configure haproxy as a sidecar instead of use the embedded version | false |
controller.haproxy.image.registry | haproxy container image registry, when enabled | docker.io |
controller.haproxy.image.repository | haproxy container image repository, when enabled | haproxy |
controller.haproxy.image.tag | haproxy container image tag | 3.0.31-alpine |
controller.haproxy.image.pullPolicy | haproxy container image pullPolicy | IfNotPresent |
controller.haproxy.extraArgs | extra command line arguments for haproxy | {} |
controller.haproxy.resources | haproxy container resource requests & limits | {} |
controller.haproxy.lifecycle | Lifecycle hooks for haproxy container | {} |
controller.haproxy.securityContext | Security context settings for the haproxy container | {} |
controller.healthzPort | The haproxy health check (monitoring) port | 10253 |
controller.legacySecurityContext | Defines if controller.securityContext should be applied to the controller's pod (legacy: true) or container (legacy: false) | true |
controller.livenessProbe.path | The liveness probe path | /healthz |
controller.livenessProbe.port | The liveness probe port | 10253 |
controller.livenessProbe.failureThreshold | The liveness probe failure threshold | 3 |
controller.livenessProbe.initialDelaySeconds | The liveness probe initial delay (in seconds) | 60 |
controller.livenessProbe.periodSeconds | The liveness probe period (in seconds) | 10 |
controller.livenessProbe.successThreshold | The liveness probe success threshold | 1 |
controller.livenessProbe.timeoutSeconds | The liveness probe timeout (in seconds) | 1 |
controller.readinessProbe.path | The readiness probe path | /healthz |
controller.readinessProbe.port | The readiness probe port | 10253 |
controller.readinessProbe.failureThreshold | The readiness probe failure threshold | 3 |
controller.readinessProbe.initialDelaySeconds | The readiness probe initial delay (in seconds) | 10 |
controller.readinessProbe.periodSeconds | The readiness probe period (in seconds) | 10 |
controller.readinessProbe.successThreshold | The readiness probe success threshold | 1 |
controller.readinessProbe.timeoutSeconds | The readiness probe timeout (in seconds) | 1 |
controller.annotations | Annotations to be added to DaemonSet/Deployment definitions | {} |
controller.podAnnotations | Annotations for N42 Gateway pod | {} |
controller.labels | Labels to be added to DaemonSet/Deployment definitions | {} |
controller.podLabels | Labels for N42 Gateway pod | {} |
controller.podAffinity | Add affinity to the controller pods to control scheduling | {} |
controller.podSecurityContext | Security context settings for N42 Gateway pod | {} |
controller.priorityClassName | Priority Class to be used | `` |
controller.securityContext | Security context settings for N42 Gateway pod or container, see controller.legacySecurityContext | {} |
controller.securityContextInitContainer | Security context settings for the init container | {} |
controller.config | additional N42 Gateway ConfigMap entries | {} |
controller.customFiles | Custom files to be mounted in the controller pod(s) | {} |
controller.hostNetwork | Optionally set to true when using CNI based kubernetes installations | false |
controller.dnsPolicy | Optionally change this to ClusterFirstWithHostNet in case you have 'hostNetwork: true' | ClusterFirst |
controller.terminationGracePeriodSeconds | How much to wait before terminating a pod (in seconds) | 60 |
controller.topologySpreadConstraints | Configures topology spread constraints in the controller pod | {} |
controller.lifecycle | Lifecycle hooks for controller container | {} |
controller.kind | Type of deployment, DaemonSet or Deployment | Deployment |
controller.tcp | TCP service ConfigMap: <port>: <namespace>/<servicename>:<portnumber>[:[<in-proxy>][:<out-proxy>]] | {} |
controller.enableStaticPorts | Set to false to only rely on ports from controller.tcp | true |
controller.containerPorts.http | HTTP container port in the controller | 80 |
controller.containerPorts.https | HTTPS container port in the controller | 443 |
controller.daemonset.useHostPort | Set to true to use host ports 80 and 443 | false |
controller.daemonset.hostIP | Change the IP the host ports will bind to | nil |
controller.daemonset.hostPorts.http | If controller.daemonset.useHostPort is true and this is non-empty sets the hostPort for http | "80" |
controller.daemonset.hostPorts.https | If controller.daemonset.useHostPort is true and this is non-empty sets the hostPort for https | "443" |
controller.daemonset.hostPorts.tcp | If controller.daemonset.useHostPort is true use hostport for these ports from tcp | [] |
controller.daemonset.extraHostPorts | If controller.daemonset.useHostPort is true configure additional host ports mapping. Each entry should specify containerPort, hostPort and optional hostIP | [] |
controller.updateStrategy | the update strategy settings | see defaults below |
controller.updateStrategy.type | the update strategy type to use | RollingUpdate |
controller.updateStrategy.rollingUpdate.maxUnavailable | the max number of unavailable controllers when doing rolling updates | 1 |
controller.minReadySeconds | seconds to avoid killing pods before we are ready | 0 |
controller.replicaCount | the number of replicas to deploy (when controller.kind is Deployment) | 1 |
controller.minAvailable | PodDisruptionBudget minimum available controller pods | 1 |
controller.resources | controller container resource requests & limits | {} |
controller.autoscaling.enabled | enabling controller horizontal pod autoscaling (when controller.kind is Deployment) | false |
controller.autoscaling.minReplicas | minimum number of replicas | |
controller.autoscaling.maxReplicas | maximum number of replicas | |
controller.autoscaling.targetCPUUtilizationPercentage | target cpu utilization | |
controller.autoscaling.targetMemoryUtilizationPercentage | target memory utilization | |
controller.autoscaling.customMetrics | Extra custom metrics to add to the HPA | [] |
controller.autoscaling.useExternalHPA | Allow the use of an external HPA resource by not deploying the default one | false |
controller.autoscaling.behavior | Allows for specifying HPA behavior to control how to scale up or down | {} |
controller.tolerations | to control scheduling to servers with taints | [] |
controller.affinity | to control scheduling | {} |
controller.nodeSelector | to control scheduling | {} |
controller.publishService.enabled | Enable 'publishService' or not, ignored if controller.extraArgs.publish-service is set | false |
controller.publishService.pathOverride | Allows overriding of the publish service to bind to, ignored if controller.extraArgs.publish-service is set | "" |
controller.service.enabled | toggle controller se |
Deploy n42-gateway with OpenTenant
Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has n42-gateway 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.
- Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
- Place the chartn42-gateway is pinned at v0.17.0-beta.3 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
- 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