From 546e3b9e177caa7ebc44729aea3afbbb8a27fa1a Mon Sep 17 00:00:00 2001 From: Jeff Billimek Date: Thu, 28 Jun 2018 10:52:09 -0400 Subject: [PATCH] adding digitalocean-dyndns chart --- digitalocean-dyndns/.helmignore | 21 +++++++ digitalocean-dyndns/Chart.yaml | 15 +++++ digitalocean-dyndns/README.md | 62 +++++++++++++++++++ digitalocean-dyndns/templates/NOTES.txt | 7 +++ digitalocean-dyndns/templates/_helpers.tpl | 32 ++++++++++ digitalocean-dyndns/templates/deployment.yaml | 51 +++++++++++++++ digitalocean-dyndns/templates/secret.yaml | 12 ++++ digitalocean-dyndns/values.yaml | 34 ++++++++++ 8 files changed, 234 insertions(+) create mode 100644 digitalocean-dyndns/.helmignore create mode 100644 digitalocean-dyndns/Chart.yaml create mode 100644 digitalocean-dyndns/README.md create mode 100644 digitalocean-dyndns/templates/NOTES.txt create mode 100644 digitalocean-dyndns/templates/_helpers.tpl create mode 100644 digitalocean-dyndns/templates/deployment.yaml create mode 100644 digitalocean-dyndns/templates/secret.yaml create mode 100644 digitalocean-dyndns/values.yaml diff --git a/digitalocean-dyndns/.helmignore b/digitalocean-dyndns/.helmignore new file mode 100644 index 00000000..f0c13194 --- /dev/null +++ b/digitalocean-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/digitalocean-dyndns/Chart.yaml b/digitalocean-dyndns/Chart.yaml new file mode 100644 index 00000000..3ce35c36 --- /dev/null +++ b/digitalocean-dyndns/Chart.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +appVersion: "1.0" +description: Dynamic DNS using DigitalOcean's DNS Services +name: digitalocean-dyndns +version: 0.1.0 +keywords: +- digitalocean +- dynamicdns +home: https://github.com/tunix/digitalocean-dyndns +sources: +- https://github.com/tunix/digitalocean-dyndns +- https://github.com/billimek/billimek-charts +maintainers: +- name: billimek + email: jeff@billimek.com \ No newline at end of file diff --git a/digitalocean-dyndns/README.md b/digitalocean-dyndns/README.md new file mode 100644 index 00000000..ca700d44 --- /dev/null +++ b/digitalocean-dyndns/README.md @@ -0,0 +1,62 @@ +# Dynamic DNS using DigitalOcean's DNS Services + +A script that pushes the public IP address of the running machine to DigitalOcean's DNS API's. It requires an existing A record to update. The resulting container image is roughly around 7 MB (thanks to Alpine Linux). + +## TL;DR; + +```console +$ helm repo add billimek https://raw.githubusercontent.com/billimek/helm-repo/master +$ helm install billimek/digitalocean-dyndns +``` + +## Introduction + +This code is adopted from [this original repo](https://github.com/tunix/digitalocean-dyndns) + +## Installing the Chart + +To install the chart with the release name `my-release`: + +```console +$ helm install --name my-release billimek/digitalocean-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` | digitalocean-dyndns image | `tunix/digitalocean-dyndns` | +| `image.tag` | digitalocean-dyndns image tag | `latest` | +| `image.pullPolicy` | digitalocean-dyndns image pull policy | `Always` | +| `digitialocean.token` | The token you generate in DigitalOcean's API settings. | `` | +| `digitialocean.domain` | The domain your subdomain is registered at. (i.e. foo.com for home.foo.com) | `` | +| `digitialocean.name` | Subdomain to use. (name in A record) (i.e. home for home.foo.com or @ for no subdomain) | `@` | +| `digitialocean.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.digitalocean.token=thisismyapikey \ + billimek/digitalocean-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/digitalocean-dyndns +``` + +Read through the [values.yaml](values.yaml) file. It has several commented out suggested values. diff --git a/digitalocean-dyndns/templates/NOTES.txt b/digitalocean-dyndns/templates/NOTES.txt new file mode 100644 index 00000000..0dcdac10 --- /dev/null +++ b/digitalocean-dyndns/templates/NOTES.txt @@ -0,0 +1,7 @@ +You can connect to the container running digitalocean-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 "digitalocean-dyndns.fullname" . }} -o jsonpath='{.items[0].metadata.name}') /bin/sh + +To trail the logs for the digitalocean-dyndns pod run the following: + +- kubectl logs -f --namespace {{ .Release.Namespace }} $(kubectl get pods --namespace {{ .Release.Namespace }} -l app={{ template "digitalocean-dyndns.fullname" . }} -o jsonpath='{ .items[0].metadata.name }') \ No newline at end of file diff --git a/digitalocean-dyndns/templates/_helpers.tpl b/digitalocean-dyndns/templates/_helpers.tpl new file mode 100644 index 00000000..eb36ff34 --- /dev/null +++ b/digitalocean-dyndns/templates/_helpers.tpl @@ -0,0 +1,32 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "digitalocean-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 "digitalocean-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 "digitalocean-dyndns.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/digitalocean-dyndns/templates/deployment.yaml b/digitalocean-dyndns/templates/deployment.yaml new file mode 100644 index 00000000..90464111 --- /dev/null +++ b/digitalocean-dyndns/templates/deployment.yaml @@ -0,0 +1,51 @@ +apiVersion: apps/v1beta2 +kind: Deployment +metadata: + name: {{ template "digitalocean-dyndns.fullname" . }} + labels: + app: {{ template "digitalocean-dyndns.name" . }} + chart: {{ template "digitalocean-dyndns.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app: {{ template "digitalocean-dyndns.name" . }} + release: {{ .Release.Name }} + template: + metadata: + labels: + app: {{ template "digitalocean-dyndns.name" . }} + release: {{ .Release.Name }} + spec: + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + env: + - name: DIGITALOCEAN_TOKEN + valueFrom: + secretKeyRef: + name: {{ template "digitalocean-dyndns.fullname" . }} + key: digitalocean-dyndns-apikey + - name: DOMAIN + value: "{{ .Values.digitialocean.domain }}" + - name: NAME + value: "{{ .Values.digitialocean.name }}" + - name: SLEEP_INTERVAL + value: "{{ .Values.digitialocean.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/digitalocean-dyndns/templates/secret.yaml b/digitalocean-dyndns/templates/secret.yaml new file mode 100644 index 00000000..42fe192c --- /dev/null +++ b/digitalocean-dyndns/templates/secret.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Secret +metadata: + name: {{ template "digitalocean-dyndns.fullname" . }} + labels: + app: {{ template "digitalocean-dyndns.name" . }} + chart: {{ template "digitalocean-dyndns.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +type: Opaque +data: + digitalocean-dyndns-apikey: {{ .Values.digitialocean.token | b64enc | quote }} \ No newline at end of file diff --git a/digitalocean-dyndns/values.yaml b/digitalocean-dyndns/values.yaml new file mode 100644 index 00000000..7b593685 --- /dev/null +++ b/digitalocean-dyndns/values.yaml @@ -0,0 +1,34 @@ +# Default values for digitalocean-dyndns. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: tunix/digitalocean-dyndns + tag: latest + pullPolicy: Always + +digitialocean: + token: sometoken # REQUIRED: The token you generate in DigitalOcean's API settings. + domain: somedomain # REQUIRED: The domain your subdomain is registered at. (i.e. foo.com for home.foo.com) + name: "@" # REQUIRED: Subdomain to use. (name in A record) (i.e. home for home.foo.com or @ for no subdomain) + 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: {}