Skip to content

Instantly share code, notes, and snippets.

@taking
Created January 6, 2023 03:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taking/952c499c0f4e90b59493293e6eb8e2fc to your computer and use it in GitHub Desktop.
Save taking/952c499c0f4e90b59493293e6eb8e2fc to your computer and use it in GitHub Desktop.

External-DNS Installation with Helm

  • external-dns on Kubernetes

Prerequisites

  • Kubernetes 1.20+
  • Helm 3.2.0+

helm update

helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo update

install

cat <<EOF > external-dns-values.yaml

sources:
#  - service
  - ingress

# sync, upsert-only
# policy: upsert-only

provider: cloudflare
cloudflare:
  email: "cloudflareEMAIL"
  apiKey: "cloudflareAPIKEY"
  proxied: false
EOF
helm install my-external-dns bitnami/external-dns \
  --create-namespace \
  --namespace external-dns \
  -f external-dns-values.yaml

Service

kubectl run nginx-test --image=nginx
kubectl expose pod/nginx-test --port=80 --target-port=80 --type=NodePort
kubectl annotate service nginx-test -n default --overwrite kubernetes.io/ingress.class=nginx
kubectl annotate service nginx-test -n default --overwrite external-dns.alpha.kubernetes.io/hostname=nginx.dev-t.xyz
kubectl annotate service nginx-test --overwrite external-dns.alpha.kubernetes.io/access=public

kubectl logs -n external-dns -l app.kubernetes.io/name=external-dns

Ingress

cat <<EOF > nginx.yaml
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: nginx
  annotations:
    kubernetes.io/ingress.class: nginx
spec:
  rules:
  - host: test.dev-t.xyz
    http:
      paths:
      - path: /
        backend:
          service:
            name: nginx
            port:
              number: 80
        pathType: Prefix
---
apiVersion: v1
kind: Service
metadata:
  name: nginx
spec:
  ports:
  - port: 80
    targetPort: 80
  selector:
    app: nginx
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx
spec:
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - image: nginx
        name: nginx
        ports:
        - containerPort: 80
---
EOF

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment