In this section, we will demonstrate how to automate the backup procedure for an etcd cluster using Kubernetes CronJob. For this, we will need a Dockerfile that has etcdctl and Azure CLI installed for the image in order to create the snapshot and upload it to a selected Azure blob container—exactly as we demonstrated in manual steps. All the configuration and service principal secrets will be injected using environment variables that can be set using Kubernetes secret.
To create the Docker image for the etcd snapshot worker, go through the following steps:
- Use a Linux machine or switch to the Linux containers in Docker Desktop for Windows.
- Open a new PowerShell window.
- Create a new directory for your source code and navigate there.
- Create a Dockerfile file with the following contents:
FROM ubuntu:18.04
ARG ETCD_VERSION="v3.3.15"
WORKDIR /temp...