From 01993807a9bf5f72f38d6c474bd4d37268605a54 Mon Sep 17 00:00:00 2001 From: Sebastian Rojo Date: Thu, 15 Jul 2021 16:14:23 -0500 Subject: [PATCH 1/5] ADDED env Variable CONFIG_PATH for Kubernetes secret --- cloudflare-ddns.py | 23 ++++++++++++-- examples/k8s/README.md | 29 +++++++++++++++++ examples/k8s/cloudflare-ddns-Deployment.yaml | 33 ++++++++++++++++++++ 3 files changed, 82 insertions(+), 3 deletions(-) create mode 100644 examples/k8s/README.md create mode 100644 examples/k8s/cloudflare-ddns-Deployment.yaml diff --git a/cloudflare-ddns.py b/cloudflare-ddns.py index 051031f..71ae093 100755 --- a/cloudflare-ddns.py +++ b/cloudflare-ddns.py @@ -1,4 +1,22 @@ -import requests, json, sys, signal, os, time, threading +#!/usr/bin/env python +# cloudflare-ddns.py +# Summary: Access your home network remotely via a custom domain name without a static IP! +# Description: Access your home network remotely via a custom domain +# Access your home network remotely via a custom domain +# A small, 🕵️ privacy centric, and ⚡ +# lightning fast multi-architecture Docker image for self hosting projects. + +__version__ = "1.0.1" + +import json +import os +import signal +import sys +import threading +import time +import requests + +CONFIG_PATH = os.environ.get('CONFIG_PATH', os.getcwd() + "/") class GracefulExit: def __init__(self): @@ -159,7 +177,6 @@ def updateIPs(ips): commitRecord(ip) if __name__ == '__main__': - PATH = os.getcwd() + "/" version = float(str(sys.version_info[0]) + "." + str(sys.version_info[1])) shown_ipv4_warning = False shown_ipv6_warning = False @@ -171,7 +188,7 @@ if __name__ == '__main__': config = None try: - with open(PATH + "config.json") as config_file: + with open(CONFIG_PATH + "config.json") as config_file: config = json.loads(config_file.read()) except: print("😡 Error reading config.json") diff --git a/examples/k8s/README.md b/examples/k8s/README.md new file mode 100644 index 0000000..61a251a --- /dev/null +++ b/examples/k8s/README.md @@ -0,0 +1,29 @@ + +Create config File + +``` +cp ../../config-example.json config-cloudflare-ddns-secret.js +``` + +Edit config.json (vim, nvim, nano... ) +``` +${EDITOR} config-cloudflare-ddns-secret.js +``` + +Create config file as Secret. + +``` +kubectl create secret generic config-cloudflare-ddns --from-file=config-cloudflare-ddns-secret.js --dry-run=client -oyaml -n ddns > config-cloudflare-ddns-Secret.yaml +``` + +apply this secret + +``` +kubectl apply -f config-cloudflare-ddns-Secret.yaml +``` + +apply this Deployment + +``` +kubectl apply -f cloudflare-ddns-Deployment.yaml +``` diff --git a/examples/k8s/cloudflare-ddns-Deployment.yaml b/examples/k8s/cloudflare-ddns-Deployment.yaml new file mode 100644 index 0000000..1ee0558 --- /dev/null +++ b/examples/k8s/cloudflare-ddns-Deployment.yaml @@ -0,0 +1,33 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: cloudflate-ddns +spec: + selector: + matchLabels: + app: cloudflate-ddns + + template: + metadata: + labels: + app: cloudflate-ddns + + spec: + containers: + - name: cloudflate-ddns + image: quay.io/arpagon/cloudflare-ddns:v1.0.0 + resources: + limits: + memory: "32Mi" + cpu: "50m" + env: + - name: CONFIG_PATH + value: "/etc/cloudflare-ddns/" + volumeMounts: + - mountPath: "/etc/cloudflare-ddns" + name: config-cloudflare-ddns + readOnly: true + volumes: + - name: config-cloudflare-ddns + secret: + secretName: config-cloudflare-ddns \ No newline at end of file From 4e4d3cebf16151faec408bc55657e4a28b1384b7 Mon Sep 17 00:00:00 2001 From: Sebastian Rojo Date: Thu, 15 Jul 2021 16:17:35 -0500 Subject: [PATCH 2/5] BETTER docs --- examples/k8s/README.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/examples/k8s/README.md b/examples/k8s/README.md index 61a251a..d9f2fd8 100644 --- a/examples/k8s/README.md +++ b/examples/k8s/README.md @@ -1,29 +1,30 @@ Create config File -``` +``` bash cp ../../config-example.json config-cloudflare-ddns-secret.js ``` Edit config.json (vim, nvim, nano... ) -``` +``` bash ${EDITOR} config-cloudflare-ddns-secret.js ``` Create config file as Secret. -``` +``` bash kubectl create secret generic config-cloudflare-ddns --from-file=config-cloudflare-ddns-secret.js --dry-run=client -oyaml -n ddns > config-cloudflare-ddns-Secret.yaml ``` apply this secret -``` +``` bash kubectl apply -f config-cloudflare-ddns-Secret.yaml +rm config-cloudflare-ddns-secret.js # recomended Just keep de secret on Kubernetes Cluster ``` apply this Deployment -``` +``` bash kubectl apply -f cloudflare-ddns-Deployment.yaml ``` From f7d2e7dc00b1d8a608dee0cb50de794e2eb8bd98 Mon Sep 17 00:00:00 2001 From: Sebastian Rojo Date: Thu, 15 Jul 2021 16:18:46 -0500 Subject: [PATCH 3/5] Set default image to timothyjmiller/cloudflare-ddns:latest --- examples/k8s/cloudflare-ddns-Deployment.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/k8s/cloudflare-ddns-Deployment.yaml b/examples/k8s/cloudflare-ddns-Deployment.yaml index 1ee0558..59f9d98 100644 --- a/examples/k8s/cloudflare-ddns-Deployment.yaml +++ b/examples/k8s/cloudflare-ddns-Deployment.yaml @@ -15,7 +15,8 @@ spec: spec: containers: - name: cloudflate-ddns - image: quay.io/arpagon/cloudflare-ddns:v1.0.0 + image: timothyjmiller/cloudflare-ddns:latest + #image: quay.io/arpagon/cloudflare-ddns:v1.0.0 resources: limits: memory: "32Mi" From 96527aaab27ecce4359ba205b18c28d6669cf0c2 Mon Sep 17 00:00:00 2001 From: Sebastian Rojo Date: Thu, 15 Jul 2021 16:26:47 -0500 Subject: [PATCH 4/5] BETTER docs --- examples/k8s/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/k8s/README.md b/examples/k8s/README.md index d9f2fd8..2a0fc93 100644 --- a/examples/k8s/README.md +++ b/examples/k8s/README.md @@ -2,25 +2,25 @@ Create config File ``` bash -cp ../../config-example.json config-cloudflare-ddns-secret.js +cp ../../config-example.json config.js ``` Edit config.json (vim, nvim, nano... ) ``` bash -${EDITOR} config-cloudflare-ddns-secret.js +${EDITOR} config.js ``` Create config file as Secret. ``` bash -kubectl create secret generic config-cloudflare-ddns --from-file=config-cloudflare-ddns-secret.js --dry-run=client -oyaml -n ddns > config-cloudflare-ddns-Secret.yaml +kubectl create secret generic config-cloudflare-ddns --from-file=config.js --dry-run=client -oyaml -n ddns > config-cloudflare-ddns-Secret.yaml ``` apply this secret ``` bash kubectl apply -f config-cloudflare-ddns-Secret.yaml -rm config-cloudflare-ddns-secret.js # recomended Just keep de secret on Kubernetes Cluster +rm config.js # recomended Just keep de secret on Kubernetes Cluster ``` apply this Deployment From 5136c925d20ad2f37a319a09bcf6bd6715c3e038 Mon Sep 17 00:00:00 2001 From: Sebastian Rojo Date: Thu, 15 Jul 2021 16:32:09 -0500 Subject: [PATCH 5/5] FIX confi filename on Docs --- examples/k8s/README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/k8s/README.md b/examples/k8s/README.md index 2a0fc93..f5de8aa 100644 --- a/examples/k8s/README.md +++ b/examples/k8s/README.md @@ -2,25 +2,25 @@ Create config File ``` bash -cp ../../config-example.json config.js +cp ../../config-example.json config.json ``` -Edit config.json (vim, nvim, nano... ) +Edit config.jsonon (vim, nvim, nano... ) ``` bash -${EDITOR} config.js +${EDITOR} config.json ``` Create config file as Secret. ``` bash -kubectl create secret generic config-cloudflare-ddns --from-file=config.js --dry-run=client -oyaml -n ddns > config-cloudflare-ddns-Secret.yaml +kubectl create secret generic config-cloudflare-ddns --from-file=config.json --dry-run=client -oyaml -n ddns > config-cloudflare-ddns-Secret.yaml ``` apply this secret ``` bash kubectl apply -f config-cloudflare-ddns-Secret.yaml -rm config.js # recomended Just keep de secret on Kubernetes Cluster +rm config.json # recomended Just keep de secret on Kubernetes Cluster ``` apply this Deployment