traefik-whitelist-ddns

by Kubito

Helm chartv1.0.5App 2.x.xVerified publisher

Kubito Traefik Whitelist DDNS Helm Chart

About this chart

Traefik Whitelist DDNS

This is a simple Traefik v2 DDNS updater script, which can be used in home lab setups to synchronize the allowed IP addresses for your IP Whitelist Middleware, which allows you to configure a VPN protected setup for your applications. It also support setting a custom domain for its IP(s) to be added to the whitelist range of the middleware.

TL;DR

helm repo add kubitodev https://charts.kubito.dev
helm install traefik-whitelist-ddns --namespace traefik kubitodev/traefik-whitelist-ddns

Introduction

This chart can be used to solve the problem of a whitelisting a single IP address by using a Traefik Middleware, which can allow you to use your own VPN to protect services from external access. It also support setting a custom domain for its IP(s) to be added to the whitelist range of the middleware.

Prerequisites

  • Kubernetes 1.12+
  • Helm 3.2.0+
  • The namespace should always be Traefik's namespace!

Installing the Chart

To install the chart with the release name traefik-whitelist-ddns:

helm install traefik-whitelist-ddns --namespace traefik kubitodev/traefik-whitelist-ddns

The command deploys traefik-whitelist-ddns on the Kubernetes cluster in the default configuration. The Parameters section lists the parameters that can be configured during installation.

Tip: List all releases using helm list

Uninstalling the Chart

To uninstall/delete the traefik-whitelist-ddns deployment:

helm delete traefik-whitelist-ddns

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

Parameters

Image parameters

NameDescriptionValue
image.repositoryThe Docker repository to pull the image from.kubitodev/traefik-ip-whitelist-sync
image.tagThe image tag to use.1.0.2

Cron parameters

NameDescriptionValue
cron.job.scheduleInterval for how often the job should run."*/5 * * * *"
cron.job.successfulJobsHistoryLimitLimit of the successful jobs saved in history as completed pods.1
cron.pod.restartPolicyThe logic for restarting the cron pod.OnFailure

Middleware parameters

NameDescriptionValue
middleware.nameThe name of the IP whitelist middleware.ip-whitelist
middleware.customDomainThe custom domain that you want to whitelist instead of your public IP.""
middleware.ipStrategy.enabledThe ipStrategy option defines two parameters that set how Traefik determines the client IP: depth, and excludedIPs.false
middleware.ipStrategy.depthThe depth option tells Traefik to use the X-Forwarded-For header and take the IP located at the depth position (starting from the right).1
middleware.ipStrategy.excludedIPsexcludedIPs configures Traefik to scan the X-Forwarded-For header and select the first IP not in the list.[]

RBAC parameters

NameDescriptionValue
rbac.serviceAccountNameThe name of the default traefik service account in traefik's namespace.traefik

Specify each parameter using the --set key=value[,key=value] argument to helm install. For example,

helm install --namespace traefik example \
  --set user=example \
  --set password=example \
    kubitodev/example

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

helm install --namespace traefik example -f values.yaml kubitodev/example

Tip: You can use the default values.yaml

Configuration and installation details

Default namespace

This chart is intended to run where Traefik is installed, so always run it in that namespace, as it uses the Traefik service account to run the job.

Custom domain

If you have your VPN on a custom domain and it is not a part of your network, you can set the middleware.customDomain value to that domain. It will get the IP(s) and whitelist them in the middleware as well, including your public IP so you can access it from home without VPN.

Using ArgoCD

If you are using ArgoCD, the chart will not work if you don't set the ArgoCD application to ignore the sourceRange field of the Middleware CRD. So, in your application, set the following:

ignoreDifferences:
    - group: traefik.containo.us
      kind: Middleware
      jsonPointers:
      - /spec/ipWhiteList/sourceRange
  syncPolicy:
    syncOptions:
      - RespectIgnoreDifferences=true

Troubleshooting

The IP is incorrect

If the IP you are getting in Traefik's logs is incorrect, and it is the one of the Traefik Load Balancer, try setting the externalTrafficPolicy of the Traefik's service to Local. For example, if you ran Traefik with Helm, set the --set service.spec.externalTrafficPolicy=Local flag.

License

Copyright © 2022 Kubito

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Deploy traefik-whitelist-ddns with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has traefik-whitelist-ddns 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 charttraefik-whitelist-ddns is pinned at v1.0.5 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