From 3adbf44703892d4486c16501297defb9fcf5bc9c Mon Sep 17 00:00:00 2001 From: Sergey Yakovlev Date: Mon, 17 Jun 2024 22:14:07 +0400 Subject: [PATCH 1/5] feat: allow to set hostAliases for traefik pod --- traefik/VALUES.md | 1 + traefik/templates/_podtemplate.tpl | 4 ++++ traefik/values.yaml | 6 ++++++ 3 files changed, 11 insertions(+) diff --git a/traefik/VALUES.md b/traefik/VALUES.md index b8ca76bf3..017839b68 100644 --- a/traefik/VALUES.md +++ b/traefik/VALUES.md @@ -40,6 +40,7 @@ Kubernetes: `>=1.22.0-0` | deployment.annotations | object | `{}` | Additional deployment annotations (e.g. for jaeger-operator sidecar injection) | | deployment.dnsConfig | object | `{}` | Custom pod DNS policy. Apply if `hostNetwork: true` dnsPolicy: ClusterFirstWithHostNet | | deployment.enabled | bool | `true` | Enable deployment | +| deployment.hostAliases | list | `[]` | Custom [host aliases](https://kubernetes.io/docs/tasks/network/customize-hosts-file-for-pods/) | | deployment.imagePullSecrets | list | `[]` | Additional imagePullSecrets | | deployment.initContainers | list | `[]` | Additional initContainers (e.g. for setting file permission as shown below) | | deployment.kind | string | `"Deployment"` | Deployment or DaemonSet | diff --git a/traefik/templates/_podtemplate.tpl b/traefik/templates/_podtemplate.tpl index c7132c3f1..cf05812fc 100644 --- a/traefik/templates/_podtemplate.tpl +++ b/traefik/templates/_podtemplate.tpl @@ -43,6 +43,10 @@ {{- toYaml .options | nindent 10 }} {{- end }} {{- end }} + {{- with .Values.deployment.hostAliases }} + hostAliases: + {{- toYaml . | nindent 8 }} + {{- end }} {{- with .Values.deployment.initContainers }} initContainers: {{- toYaml . | nindent 6 }} diff --git a/traefik/values.yaml b/traefik/values.yaml index e440dcf62..b4b03ca4e 100644 --- a/traefik/values.yaml +++ b/traefik/values.yaml @@ -91,6 +91,12 @@ deployment: # - name: ndots # value: "2" # - name: edns0 + # -- Custom [host aliases](https://kubernetes.io/docs/tasks/network/customize-hosts-file-for-pods/) + hostAliases: [] + # - ip: "127.0.0.1" # this is an example + # hostnames: + # - "foo.local" + # - "bar.local" # -- Additional imagePullSecrets imagePullSecrets: [] # - name: myRegistryKeySecretName From e3097bea3c3bf401a1dd86a37fcd477d64ce0ab8 Mon Sep 17 00:00:00 2001 From: Sergei Iakovlev Date: Tue, 18 Jun 2024 11:51:58 +0400 Subject: [PATCH 2/5] Update traefik/templates/_podtemplate.tpl Co-authored-by: Michel Loiseleur <97035654+mloiseleur@users.noreply.github.com> --- traefik/templates/_podtemplate.tpl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/traefik/templates/_podtemplate.tpl b/traefik/templates/_podtemplate.tpl index cf05812fc..b370a5eb8 100644 --- a/traefik/templates/_podtemplate.tpl +++ b/traefik/templates/_podtemplate.tpl @@ -44,8 +44,7 @@ {{- end }} {{- end }} {{- with .Values.deployment.hostAliases }} - hostAliases: - {{- toYaml . | nindent 8 }} + hostAliases: {{- toYaml . | nindent 8 }} {{- end }} {{- with .Values.deployment.initContainers }} initContainers: From 7e83cbdffa58349117deccfd5cf20abd34686797 Mon Sep 17 00:00:00 2001 From: Sergey Yakovlev Date: Wed, 19 Jun 2024 18:00:49 +0400 Subject: [PATCH 3/5] code review changes --- EXAMPLES.md | 33 +++++++++++++++++++++++++++++++++ traefik/values.yaml | 17 ++--------------- 2 files changed, 35 insertions(+), 15 deletions(-) diff --git a/EXAMPLES.md b/EXAMPLES.md index da2b59f02..b3e6f5e48 100644 --- a/EXAMPLES.md +++ b/EXAMPLES.md @@ -7,6 +7,39 @@ deployment: kind: DaemonSet ``` +# Configure traefik Pod parameters + +## Extending /etc/hosts records + +In some specific cases, you'll need to add extra records to the `/etc/hosts` file for the Traefik containers. +You could configure it using [hostAliases](https://kubernetes.io/docs/tasks/network/customize-hosts-file-for-pods/): + +```yaml +deployment: + hostAliases: + - ip: "127.0.0.1" # this is an example + hostnames: + - "foo.local" + - "bar.local" +``` +## Extending DNS config + +In order to configure additional DNS servers for your traefik pod, you could use `dnsConfig` option: + +```yaml +deployment: + dnsConfig: + nameservers: + - 192.0.2.1 # this is an example + searches: + - ns1.svc.cluster-domain.example + - my.dns.search.suffix + options: + - name: ndots + value: "2" + - name: edns0 +``` + # Install in a dedicated namespace, with limited RBAC Default install is using Cluster-wide RBAC but it can be restricted to target namespace. diff --git a/traefik/values.yaml b/traefik/values.yaml index b4b03ca4e..616b89714 100644 --- a/traefik/values.yaml +++ b/traefik/values.yaml @@ -81,25 +81,12 @@ deployment: shareProcessNamespace: false # -- Custom pod DNS policy. Apply if `hostNetwork: true` # dnsPolicy: ClusterFirstWithHostNet + # -- Custom pod [DNS config](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#poddnsconfig-v1-core) dnsConfig: {} - # nameservers: - # - 192.0.2.1 # this is an example - # searches: - # - ns1.svc.cluster-domain.example - # - my.dns.search.suffix - # options: - # - name: ndots - # value: "2" - # - name: edns0 # -- Custom [host aliases](https://kubernetes.io/docs/tasks/network/customize-hosts-file-for-pods/) hostAliases: [] - # - ip: "127.0.0.1" # this is an example - # hostnames: - # - "foo.local" - # - "bar.local" - # -- Additional imagePullSecrets + # -- Pull secret for fetching traefik container image imagePullSecrets: [] - # - name: myRegistryKeySecretName # -- Pod lifecycle actions lifecycle: {} # preStop: From b70b515001c5030fcc1a22cc4c0e90561e75b868 Mon Sep 17 00:00:00 2001 From: Sergei Iakovlev Date: Thu, 20 Jun 2024 01:06:13 +0400 Subject: [PATCH 4/5] Update EXAMPLES.md Co-authored-by: Michel Loiseleur <97035654+mloiseleur@users.noreply.github.com> --- EXAMPLES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EXAMPLES.md b/EXAMPLES.md index b3e6f5e48..ce8d6bd55 100644 --- a/EXAMPLES.md +++ b/EXAMPLES.md @@ -12,7 +12,7 @@ deployment: ## Extending /etc/hosts records In some specific cases, you'll need to add extra records to the `/etc/hosts` file for the Traefik containers. -You could configure it using [hostAliases](https://kubernetes.io/docs/tasks/network/customize-hosts-file-for-pods/): +You can configure it using [hostAliases](https://kubernetes.io/docs/tasks/network/customize-hosts-file-for-pods/): ```yaml deployment: From 8c8d603b643a04bbd696e7632538ae7b6651262c Mon Sep 17 00:00:00 2001 From: Sergei Iakovlev Date: Thu, 20 Jun 2024 01:06:26 +0400 Subject: [PATCH 5/5] Update EXAMPLES.md Co-authored-by: Michel Loiseleur <97035654+mloiseleur@users.noreply.github.com> --- EXAMPLES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EXAMPLES.md b/EXAMPLES.md index ce8d6bd55..6ac5afbe0 100644 --- a/EXAMPLES.md +++ b/EXAMPLES.md @@ -24,7 +24,7 @@ deployment: ``` ## Extending DNS config -In order to configure additional DNS servers for your traefik pod, you could use `dnsConfig` option: +In order to configure additional DNS servers for your traefik pod, you can use `dnsConfig` option: ```yaml deployment: