diff --git a/cloudflare-dyndns/.helmignore b/cloudflare-dyndns/.helmignore new file mode 100644 index 00000000..f0c13194 --- /dev/null +++ b/cloudflare-dyndns/.helmignore @@ -0,0 +1,21 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*~ +# Various IDEs +.project +.idea/ +*.tmproj diff --git a/cloudflare-dyndns/Chart.yaml b/cloudflare-dyndns/Chart.yaml new file mode 100644 index 00000000..77d2abbc --- /dev/null +++ b/cloudflare-dyndns/Chart.yaml @@ -0,0 +1,16 @@ +apiVersion: v1 +appVersion: "1.0" +description: Dynamic DNS using Cloudflare's DNS Services +name: cloudflare-dyndns +version: 1.0.0 +keywords: +- cloudflare +- dynamicdns +home: https://github.com/billimek/billimek-charts/tree/master/cloudflare-dyndns +icon: https://www.cloudflare.com/img/cf-facebook-card.png +sources: +- https://github.com/hotio/docker-cloudflare-ddns/ +- https://github.com/billimek/billimek-charts +maintainers: +- name: billimek + email: jeff@billimek.com diff --git a/cloudflare-dyndns/README.md b/cloudflare-dyndns/README.md new file mode 100644 index 00000000..a77e94a7 --- /dev/null +++ b/cloudflare-dyndns/README.md @@ -0,0 +1,67 @@ +# Dynamic DNS using Cloudflare's DNS Services + +A script that pushes the public IP address of the running machine to Cloudflare's DNS API's. It requires an existing A record to update. + +## TL;DR; + +```console +$ helm repo add billimek https://billimek.com/billimek-charts/ +$ helm install billimek/cloudflare-dyndns +``` + +## Introduction + +This code is adopted from [this original repo](https://github.com/hotio/docker-cloudflare-ddns) + +## Installing the Chart + +To install the chart with the release name `my-release`: + +```console +$ helm install --name my-release billimek/cloudflare-dyndns +``` + +## Uninstalling the Chart + +To uninstall/delete the `my-release` deployment: + +```console +$ helm delete my-release --purge +``` + +The command removes all the Kubernetes components associated with the chart and deletes the release. + +## Configuration + +The following tables lists the configurable parameters of the Sentry chart and their default values. + +| Parameter | Description | Default | +| ------------------------------- | ------------------------------- | ---------------------------------------------------------- | +| `image.repository` | cloudflare-dyndns image | `hotio/cloudflare-ddns` | +| `image.tag` | cloudflare-dyndns image tag | `latest` | +| `image.pullPolicy` | cloudflare-dyndns image pull policy | `Always` | +| `cloudflare.user` | The username of your Cloudflare account, should be your email address. | `` | +| `cloudflare.token` | The token you generated in Cloudflare's API settings. | `` | +| `cloudflare.zones` | The domain(s) you wish to update, separated by `;` | `` | +| `cloudflare.hosts` | The subdomain(s) you wish to update, separated by `;` | `` | +| `cloudflare.record_types` | The record types to update, separated by `;` | `` | +| `cloudflare.detection_mode` | Source to query for public IP | `dig-google.com` | +| `cloudflare.log_level` | Verbosity of the logs printed to stdout/stderr | `1` | +| `cloudflare.sleep_interval` | Polling time in seconds | `300` | + + +Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example, + +```console +helm install --name my-release \ + --set config.cloudflare.token=thisismyapikey \ + billimek/cloudflare-dyndns +``` + +Alternatively, a YAML file that specifies the values for the above parameters can be provided while installing the chart. For example, + +```console +helm install --name my-release -f values.yaml billimek/cloudflare-dyndns +``` + +Read through the [values.yaml](https://github.com/billimek/billimek-charts/blob/master/cloudflare-dyndns/values.yaml) file. It has several commented out suggested values. diff --git a/cloudflare-dyndns/templates/NOTES.txt b/cloudflare-dyndns/templates/NOTES.txt new file mode 100644 index 00000000..0da2025e --- /dev/null +++ b/cloudflare-dyndns/templates/NOTES.txt @@ -0,0 +1,7 @@ +You can connect to the container running cloudflare-dyndns. To open a shell session in the pod run the following: + +- kubectl exec -i -t --namespace {{ .Release.Namespace }} $(kubectl get pods --namespace {{ .Release.Namespace }} -l app={{ template "cloudflare-dyndns.fullname" . }} -o jsonpath='{.items[0].metadata.name}') /bin/sh + +To trail the logs for the cloudflare-dyndns pod run the following: + +- kubectl logs -f --namespace {{ .Release.Namespace }} $(kubectl get pods --namespace {{ .Release.Namespace }} -l app={{ template "cloudflare-dyndns.fullname" . }} -o jsonpath='{ .items[0].metadata.name }') \ No newline at end of file diff --git a/cloudflare-dyndns/templates/_helpers.tpl b/cloudflare-dyndns/templates/_helpers.tpl new file mode 100644 index 00000000..9cb9725e --- /dev/null +++ b/cloudflare-dyndns/templates/_helpers.tpl @@ -0,0 +1,32 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "cloudflare-dyndns.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "cloudflare-dyndns.fullname" -}} +{{- if .Values.fullnameOverride -}} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- if contains $name .Release.Name -}} +{{- .Release.Name | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} +{{- end -}} +{{- end -}} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "cloudflare-dyndns.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/cloudflare-dyndns/templates/deployment.yaml b/cloudflare-dyndns/templates/deployment.yaml new file mode 100644 index 00000000..d83d0a79 --- /dev/null +++ b/cloudflare-dyndns/templates/deployment.yaml @@ -0,0 +1,68 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ template "cloudflare-dyndns.fullname" . }} + labels: + app: {{ template "cloudflare-dyndns.name" . }} + chart: {{ template "cloudflare-dyndns.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app: {{ template "cloudflare-dyndns.name" . }} + release: {{ .Release.Name }} + template: + metadata: + labels: + app: {{ template "cloudflare-dyndns.name" . }} + release: {{ .Release.Name }} + spec: + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + env: + - name: CF_USER + valueFrom: + secretKeyRef: + name: {{ template "cloudflare-dyndns.fullname" . }} + key: cloudflare-dyndns-user + - name: CF_APIKEY + valueFrom: + secretKeyRef: + name: {{ template "cloudflare-dyndns.fullname" . }} + key: cloudflare-dyndns-token + - name: CF_ZONES + valueFrom: + secretKeyRef: + name: {{ template "cloudflare-dyndns.fullname" . }} + key: cloudflare-dyndns-zones + - name: CF_HOSTS + valueFrom: + secretKeyRef: + name: {{ template "cloudflare-dyndns.fullname" . }} + key: cloudflare-dyndns-hosts + - name: CF_RECORDTYPES + value: "{{ .Values.cloudflare.record_types }}" + - name: DETECTION_MODE + value: "{{ .Values.cloudflare.detection_mode }}" + - name: LOG_LEVEL + value: "{{ .Values.cloudflare.log_level }}" + - name: SLEEP_INTERVAL + value: "{{ .Values.cloudflare.sleep_interval }}" + resources: +{{ toYaml .Values.resources | indent 12 }} + {{- with .Values.nodeSelector }} + nodeSelector: +{{ toYaml . | indent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: +{{ toYaml . | indent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: +{{ toYaml . | indent 8 }} + {{- end }} diff --git a/cloudflare-dyndns/templates/secret.yaml b/cloudflare-dyndns/templates/secret.yaml new file mode 100644 index 00000000..2805a357 --- /dev/null +++ b/cloudflare-dyndns/templates/secret.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Secret +metadata: + name: {{ template "cloudflare-dyndns.fullname" . }} + labels: + app: {{ template "cloudflare-dyndns.name" . }} + chart: {{ template "cloudflare-dyndns.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +type: Opaque +data: + cloudflare-dyndns-user: {{ .Values.cloudflare.user | b64enc | quote }} + cloudflare-dyndns-token: {{ .Values.cloudflare.token | b64enc | quote }} + cloudflare-dyndns-zones: {{ .Values.cloudflare.zones | b64enc | quote }} + cloudflare-dyndns-hosts: {{ .Values.cloudflare.hosts | b64enc | quote }} \ No newline at end of file diff --git a/cloudflare-dyndns/values.yaml b/cloudflare-dyndns/values.yaml new file mode 100644 index 00000000..23c718d2 --- /dev/null +++ b/cloudflare-dyndns/values.yaml @@ -0,0 +1,38 @@ +# Default values for digitalocean-dyndns. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: hotio/cloudflare-ddns + tag: latest + pullPolicy: Always + +cloudflare: + user: someuser # REQUIRED: The username of your Cloudflare account, should be your email address. + token: sometoken # REQUIRED: The token you generate in DigitalOcean's API settings. + zones: somezones # REQUIRED: The domain(s) you wish to update, separated by ; + hosts: somehosts # REQUIRED: The subdomain(s) you wish to update, separated by ; + record_types: somerecordtypes # REQUIRED: The record types to update, separated by ; + detection_mode: dig-google.com # Source to query for public IP + log_level: 1 # Verbosity of the logs printed to stdout/stderr + sleep_interval: 300 # Polling time in seconds + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +nodeSelector: {} + +tolerations: [] + +affinity: {}