|
| 1 | +# Values |
| 2 | + |
| 3 | +## admin |
| 4 | + |
| 5 | +### admin.annotations |
| 6 | + |
| 7 | +By allowing annotations to be added to the password secret, we can use tools like [Reflector](https://github.com/emberstack/kubernetes-reflector) to synchronize secrets across namespaces. |
| 8 | + |
| 9 | +This is interesting e.g. with the [ExternalDNS](https://github.com/kubernetes-sigs/external-dns) 0.14+'s Pi-Hole integration that can automatically expose Ingress host names to the Local DNS configuration: |
| 10 | + |
| 11 | +```yaml |
| 12 | +apiVersion: apps/v1 |
| 13 | +kind: Deployment |
| 14 | +metadata: |
| 15 | + name: external-dns |
| 16 | +spec: |
| 17 | + strategy: |
| 18 | + type: Recreate |
| 19 | + selector: |
| 20 | + matchLabels: |
| 21 | + app: external-dns |
| 22 | + template: |
| 23 | + metadata: |
| 24 | + labels: |
| 25 | + app: external-dns |
| 26 | + spec: |
| 27 | + serviceAccountName: external-dns |
| 28 | + containers: |
| 29 | + - name: external-dns |
| 30 | + image: registry.k8s.io/external-dns/external-dns:v0.14.0 |
| 31 | + # If authentication is disabled and/or you didn't create |
| 32 | + # a secret, you can remove this block. |
| 33 | + envFrom: |
| 34 | + - secretRef: |
| 35 | + # Change this if you gave the secret a different name |
| 36 | + name: pihole-password |
| 37 | + args: |
| 38 | + - --source=service |
| 39 | + - --source=ingress |
| 40 | + # Pihole only supports A/CNAME records so there is no mechanism to track ownership. |
| 41 | + # You don't need to set this flag, but if you leave it unset, you will receive warning |
| 42 | + # logs when ExternalDNS attempts to create TXT records. |
| 43 | + - --registry=noop |
| 44 | + # IMPORTANT: If you have records that you manage manually in Pi-hole, set |
| 45 | + # the policy to upsert-only so they do not get deleted. |
| 46 | + - --policy=upsert-only |
| 47 | + - --provider=pihole |
| 48 | + # Change this to the actual address of your Pi-hole web server |
| 49 | + - --pihole-server=http://pihole-web.pihole.svc.cluster.local |
| 50 | + resources: |
| 51 | + limits: |
| 52 | + cpu: 1 |
| 53 | + memory: 1Gi |
| 54 | + requests: |
| 55 | + cpu: 100m |
| 56 | + memory: 256M |
| 57 | + securityContext: |
| 58 | + fsGroup: 65534 # For ExternalDNS to be able to read Kubernetes token files |
| 59 | +``` |
| 60 | +
|
| 61 | +Since the Secret reference can only refer to a secret in the same namespace as ExternalDNS, using Reflector is a viable option to synchronize the two secrets. This can now be done via |
| 62 | +
|
| 63 | +```yaml |
| 64 | +admin: |
| 65 | + enabled: true |
| 66 | + existingSecret: "" |
| 67 | + passwordKey: "password" |
| 68 | + annotations: |
| 69 | + reflector.v1.k8s.emberstack.com/reflection-allowed: "true" |
| 70 | + reflector.v1.k8s.emberstack.com/reflection-allowed-namespaces: "external-dns" |
| 71 | +``` |
| 72 | +
|
| 73 | +For Reflector to work we also need to create the mirror (target) secret in ExternalDNS' namespace like this: |
| 74 | +
|
| 75 | +```yaml |
| 76 | +apiVersion: v1 |
| 77 | +kind: Secret |
| 78 | +metadata: |
| 79 | + # Change this to match the secretRef used in the ExternalDNS deployment: |
| 80 | + name: pihole-password |
| 81 | + # Change this to ExternalDNS' namespace: |
| 82 | + namespace: external-dns |
| 83 | + annotations: |
| 84 | + # Change this to address the pihole password secret: 'namespace/secret-name': |
| 85 | + reflector.v1.k8s.emberstack.com/reflects: "pihole/pihole-password" |
| 86 | +data: {} # Will be overwritten by Reflector |
| 87 | +``` |
0 commit comments