external-dns
external-dns copied to clipboard
Support vault agent sidecar injector
Hello,
I'm using hashicorp vault to provide environment variables to configure exertnal-dns, unfortunately the current helm chart doesn't allow us to edit the container command that is needed to source environment variables as stated by hashicorp vault documentation.
If you agree with the idea, I can create a PR to add this feature.
Here is my current deployment
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: external-dns
namespace: external-dns-internal
spec:
replicas: 1
strategy:
type: Recreate
selector:
matchLabels:
app: external-dns
template:
metadata:
labels:
app: external-dns
annotations:
vault.hashicorp.com/agent-inject: 'true'
vault.hashicorp.com/agent-inject-secret-config: secret/data/homelab/prod/external_dns/internal
vault.hashicorp.com/agent-inject-secret-tls-ca: secret/data/homelab/prod/external_dns/internal
vault.hashicorp.com/agent-inject-template-config: |
{{- with secret "secret/data/homelab/prod/external_dns/internal" -}}
export EXTERNAL_DNS_PDNS_SERVER="{{ .Data.data.EXTERNAL_DNS_PDNS_SERVER }}"
export EXTERNAL_DNS_PDNS_API_KEY="{{ .Data.data.EXTERNAL_DNS_PDNS_API_KEY }}"
export EXTERNAL_DNS_PDNS_TLS_ENABLED="{{ .Data.data.EXTERNAL_DNS_PDNS_TLS_ENABLED }}"
export EXTERNAL_DNS_TLS_CA="/vault/secrets/tls-ca"
{{- end }}
vault.hashicorp.com/agent-inject-template-tls-ca: |
{{- with secret "secret/data/homelab/prod/external_dns/internal" -}}
{{ .Data.data.EXTERNAL_DNS_TLS_CA }}
{{- end }}
vault.hashicorp.com/ca-cert: /vault/tls/ca.crt
vault.hashicorp.com/role: external-dns-internal
vault.hashicorp.com/tls-secret: vault-ca
spec:
serviceAccountName: external-dns
containers:
- name: external-dns
image: registry.k8s.io/external-dns/external-dns:v0.13.5
command:
- sh
- '-c'
args:
- >-
source /vault/secrets/config && /bin/external-dns --source=ingress
--provider=pdns --domain-filter=unicornafk.fr --registry=txt
--txt-owner-id=homelab.kubernetes --ingress-class=traefik-internal
--default-targets=192.168.10.101
--default-targets=2a0c:b641:2c0:110::101
It appears that this deployment no longer works with v0.13.6 because the new image has no shell
As a workaround (really ugly), i'm using an init container to add shell back to external-dns image
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: external-dns
namespace: external-dns-internal
spec:
replicas: 1
strategy:
type: Recreate
selector:
matchLabels:
app: external-dns
template:
metadata:
labels:
app: external-dns
annotations:
vault.hashicorp.com/agent-inject: 'true'
vault.hashicorp.com/agent-inject-secret-config: secret/data/homelab/prod/external_dns/internal
vault.hashicorp.com/agent-inject-secret-tls-ca: secret/data/homelab/prod/external_dns/internal
vault.hashicorp.com/agent-inject-template-config: |
{{- with secret "secret/data/homelab/prod/external_dns/internal" -}}
export EXTERNAL_DNS_PDNS_SERVER="{{ .Data.data.EXTERNAL_DNS_PDNS_SERVER }}"
export EXTERNAL_DNS_PDNS_API_KEY="{{ .Data.data.EXTERNAL_DNS_PDNS_API_KEY }}"
export EXTERNAL_DNS_PDNS_TLS_ENABLED="{{ .Data.data.EXTERNAL_DNS_PDNS_TLS_ENABLED }}"
export EXTERNAL_DNS_TLS_CA="/vault/secrets/tls-ca"
{{- end }}
vault.hashicorp.com/agent-inject-template-tls-ca: |
{{- with secret "secret/data/homelab/prod/external_dns/internal" -}}
{{ .Data.data.EXTERNAL_DNS_TLS_CA }}
{{- end }}
vault.hashicorp.com/ca-cert: /vault/tls/ca.crt
vault.hashicorp.com/role: external-dns-internal
vault.hashicorp.com/tls-secret: vault-ca
spec:
serviceAccountName: external-dns
initContainers:
- name: copy-shell
image: busybox:uclibc
command: ["cp", "/bin/sh", "/shell/sh"]
volumeMounts:
- name: shell
mountPath: /shell
containers:
- name: external-dns
image: registry.k8s.io/external-dns/external-dns:v0.13.6
command:
- /shell/sh
- '-c'
args:
- >-
source /vault/secrets/config && /bin/external-dns --source=ingress
--provider=pdns --domain-filter=unicornafk.fr --registry=txt
--txt-owner-id=homelab.kubernetes --ingress-class=traefik-internal
--default-targets=192.168.10.101
--default-targets=2a0c:b641:2c0:110::101
volumeMounts:
- name: shell
mountPath: /shell
volumes:
- name: shell
emptyDir: {}
The Kubernetes project currently lacks enough contributors to adequately respond to all issues.
This bot triages un-triaged issues according to the following rules:
- After 90d of inactivity,
lifecycle/staleis applied - After 30d of inactivity since
lifecycle/stalewas applied,lifecycle/rottenis applied - After 30d of inactivity since
lifecycle/rottenwas applied, the issue is closed
You can:
- Mark this issue as fresh with
/remove-lifecycle stale - Close this issue with
/close - Offer to help out with Issue Triage
Please send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle stale
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues.
This bot triages un-triaged issues according to the following rules:
- After 90d of inactivity,
lifecycle/staleis applied - After 30d of inactivity since
lifecycle/stalewas applied,lifecycle/rottenis applied - After 30d of inactivity since
lifecycle/rottenwas applied, the issue is closed
You can:
- Mark this issue as fresh with
/remove-lifecycle rotten - Close this issue with
/close - Offer to help out with Issue Triage
Please send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle rotten
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.
This bot triages issues according to the following rules:
- After 90d of inactivity,
lifecycle/staleis applied - After 30d of inactivity since
lifecycle/stalewas applied,lifecycle/rottenis applied - After 30d of inactivity since
lifecycle/rottenwas applied, the issue is closed
You can:
- Reopen this issue with
/reopen - Mark this issue as fresh with
/remove-lifecycle rotten - Offer to help out with Issue Triage
Please send feedback to sig-contributor-experience at kubernetes/community.
/close not-planned
@k8s-triage-robot: Closing this issue, marking it as "Not Planned".
In response to this:
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.
This bot triages issues according to the following rules:
- After 90d of inactivity,
lifecycle/staleis applied- After 30d of inactivity since
lifecycle/stalewas applied,lifecycle/rottenis applied- After 30d of inactivity since
lifecycle/rottenwas applied, the issue is closedYou can:
- Reopen this issue with
/reopen- Mark this issue as fresh with
/remove-lifecycle rotten- Offer to help out with Issue Triage
Please send feedback to sig-contributor-experience at kubernetes/community.
/close not-planned
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.