Data Smith

The Data Blog

Musings and ramblings on a variety of topics.

Dynamic DNS and Kubernetes

How to use Dynamic DNS within Kubernetes.

Greg Smith

2 minute read

I have used Dynamic DNS for many years and it has worked well for ensuring that my domain name or home network is accessible via the interweb, when my ISP chooses to update my IP address. I wanted to try and emulate the same behaviour within Kubernetes.

First I want to introduce a new volume type specifically designed for holding confidential configuration information. Below is an example of a Secret Volume specification:

apiVersion: v1
kind: Secret
metadata:
  name: ddclient-secret
  labels:
    app: ddclient
stringData:
  ddclient.conf: |
    daemon=300
    syslog=yes
    protocol=cloudflare
    zone=some-site.com
    use=web
    web=https://domains.google.com/checkip
    ssl=yes
    ttl=1
    login=you@gmail.com
    password=some-password
    blog.some-site.com

The stringData section contains the content of your ddclient.conf and getting this bit right is probably the most difficult bit of this entire exercise. Save your Secret in a file called ddclient-secret.yml. Once you have your secret then it is a case of simply creating a Deployment (ddclient.yml) to use it. This is a lot simpler than the previous example as we do not need a Service or Ingress.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: ddclient-deployment
  labels:
    app: ddclient
spec:
  replicas: 1
  selector:
    matchLabels:
      app: ddclient
  template:
    metadata:
      labels:
        app: ddclient
    spec:
      volumes:
        - name: ddclient-config-file
          secret:
            secretName: ddclient-secret
      containers:
        - name: ddclient
          image: linuxserver/ddclient
          imagePullPolicy: Always
          volumeMounts:
            - mountPath: /config
              name: ddclient-config-file

Finally, create your ddclient Secret and Deployment and you are away!

kubectl create -f ddclient-secret.yml
kubectl create -f ddclient.yml

Even though this is an interesting exercise, I have started to think about better ways of hosting, securing and maintaining my websites and have finally came to the conclusion that the public clouds just do it so much better. So for my next blog post on hosting my blog, I am moving into the 21st Century and will describe how I now host my public website using Amazon CloudFront.

Recent posts

About

This is my personal blog space that I use to write about the many different things that interest me. To find out a little more about me click on the link