Hydrate pod virtual env from secret-env-values

This commit is contained in:
2024-01-13 22:48:13 +01:00
parent 07ddf43bae
commit 24446a26fd
2 changed files with 28 additions and 3 deletions

View File

@@ -12,6 +12,9 @@ spec:
containers:
- name: cf-ddns
image: ${IMAGE}
envFrom:
- secretRef:
name: secret-env-values
imagePullPolicy: IfNotPresent
restartPolicy: OnFailure

View File

@@ -11,7 +11,7 @@ cp .env.example .env
Fill inn `API_TOKEN` and `ZONE_ID`.
`API_TOKEN` should be generated from https://cloudflare.com/profile/generate-token and have access to all zones you wish to update.
`API_TOKEN` should be generated from [https://cloudflare.com/profile/generate-token](https://dash.cloudflare.com/profile/api-tokens) and have access to all zones you wish to update.
`ZONE_ID` should be the zone where a `addr` A record that will be compared to actual address to see if it should be updated.
@@ -20,7 +20,7 @@ Fill inn `API_TOKEN` and `ZONE_ID`.
Prefered way to Build using dockerfile:
```
(sudo) docker build -t cloudflare-ddns .
docker run --rm cloudflare-dns
docker run --rm -it cloudflare-dns
```
(Optional Installing python dependencies and running:)
@@ -30,4 +30,26 @@ source -p $(which python3) env/bin/activate
pip install -r requirements.txt
python main.py
```
```
## Kubernetes
I am currenly running in kubernetes cluster as a cronjob checking periodically. Substitute `${IMAGE}` in `job.yml` manually or using CI script similar to: https://github.com/KevinMidboe/cloudflare-ddns/blob/main/.drone.yml#L49-L51.
After job is created you also want to set environment variables from kubernetes secret, example `.kuberenetes/secret.yml`:
```yaml
apiVersion: v1
kind: Secret
metadata:
name: secret-env-values
namespace: cloudflare-ddns
type: Opaque
data:
API_KEY: BASE_64_ENCODED_CLOUDFLARE_API_KEY
DDNS_ZONE: BASE64_ENCODED_CLOUDFLARE_ZONE_ID
```
```
kubectl apply -f .kuberenetes/secret.yml
```