Skip to content

Commit

Permalink
docs: add Kubernetes examples & documentation (#402)
Browse files Browse the repository at this point in the history
Fix #396
  • Loading branch information
3deep5me authored Jan 14, 2024
1 parent ee495bb commit 679a1d1
Show file tree
Hide file tree
Showing 10 changed files with 164 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ The program reads the configuration from a JSON object, either from a file or fr

### Next steps

#### Docker-Compose

You can also use [docker-compose.yml](https://github.com/qdm12/ddns-updater/blob/master/docker-compose.yml) with:

```sh
Expand All @@ -140,6 +142,10 @@ docker-compose up -d

You can update the image with `docker pull qmcgaw/ddns-updater`. Other [Docker image tags are available](https://hub.docker.com/repository/docker/qmcgaw/ddns-updater/tags).

#### Kubernetes

Check out the [k8s directory](k8s) for an installation guide and examples.

### GHCR

Images are also added to the Github Container Registry. To use the GHCR container replace `qmcgaw/ddns-updater` to `ghcr.io/qdm12/ddns-updater`, further details are available [here](https://github.com/qdm12/ddns-updater/pkgs/container/ddns-updater)
Expand Down
38 changes: 38 additions & 0 deletions k8s/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Kubernetes

This directory has example plain Kubernetes manifests for running DDNS-updater in Kubernetes.

The Manifests have additional [Kustomize](https://kustomize.io/) overlays, which can be used to add an [ingress-route](https://kubernetes.io/docs/concepts/services-networking/ingress/) to ddns-updater.

1. Download the template files from the [`base` directory](base). For example with:

```sh
curl -O https://raw.githubusercontent.com/qdm12/ddns-updater/master/k8s/base/deployment.yaml
curl -O https://raw.githubusercontent.com/qdm12/ddns-updater/master/k8s/base/secret-config.yaml
curl -O https://raw.githubusercontent.com/qdm12/ddns-updater/master/k8s/base/service.yaml
curl -O https://raw.githubusercontent.com/qdm12/ddns-updater/master/k8s/base/kustomization.yaml
```

1. Modify `secret-config.yaml` as described in the [project readme](../README#configuration)
1. Use [kubectl](https://kubernetes.io/docs/reference/kubectl/) to apply the manifest:

```sh
kubectl apply -k .
```

1. Connect the the web UI with a [kubectl port-forward](https://kubernetes.io/docs/tasks/access-application-cluster/port-forward-access-application-cluster/)

```sh
kubectl port-forward svc/ddns-updater 8080:80
```

The web UI should now be available at [http://localhost:8080](http://localhost:8080).

## Advanced usage

Kustomize overlays can extend the installation:

* [overlay/with-ingress](overlay/with-ingress/) - Basic **HTTP** Ingress ressource
* [overlay/with-ingress-cert-manager](overlay/with-ingress-cert-manager/) - Basic **HTTPS** Ingress ressource which uses [cert-manager](https://github.com/cert-manager/cert-manager) to create certificates.

To install with the overlay **just change dirctory in the overlay folder you want to install** and hit `kubectl apply -k .` .
23 changes: 23 additions & 0 deletions k8s/base/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: ddns-updater
labels:
app: ddns-updater
spec:
selector:
matchLabels:
app: ddns-updater
template:
metadata:
labels:
app: ddns-updater
spec:
containers:
- name: ddns
image: qmcgaw/ddns-updater:latest
envFrom:
- secretRef:
name: ddns-updater-config
ports:
- containerPort: 8000
6 changes: 6 additions & 0 deletions k8s/base/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- deployment.yaml
- secret-config.yaml
- service.yaml
7 changes: 7 additions & 0 deletions k8s/base/secret-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v1
kind: Secret
metadata:
name: ddns-updater-config
type: Opaque
stringData:
CONFIG: '{"settings":[{"provider":"ddnss","provider_ip":true,"domain":"YOUR-DOMAIN","host":"@","username":"YOUR-USERNAME","password":"YOUR-PASSWORD","ip_version":"ipv4"}]}'
12 changes: 12 additions & 0 deletions k8s/base/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
kind: Service
metadata:
name: ddns-updater
spec:
selector:
app: ddns-updater
type: ClusterIP
ports:
- name: http
port: 80
targetPort: 8000
23 changes: 23 additions & 0 deletions k8s/overlay/with-ingress-tls-cert-manager/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
cert-manager.io/cluster-issuer: default
ingress.kubernetes.io/force-ssl-redirect: "true"
name: ddns-updater
spec:
rules:
- host: localhost
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
service:
name: ddns-updater
port:
number: 80
tls:
- hosts:
- localhost
secretName: ddns-updater-tls
18 changes: 18 additions & 0 deletions k8s/overlay/with-ingress-tls-cert-manager/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../base
- ingress.yaml

# this patches the hostname of the Ingress
patches:
- patch: |-
- op: replace
path: /spec/rules/0/host
value: localhost # add your fqdn
- op: replace
path: /spec/tls/0/hosts/0
value: localhost # add your fqdn
target:
kind: Ingress
name: ddns-updater
16 changes: 16 additions & 0 deletions k8s/overlay/with-ingress/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ddns-updater
spec:
rules:
- host: localhost
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
service:
name: ddns-updater
port:
name: http
15 changes: 15 additions & 0 deletions k8s/overlay/with-ingress/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../base
- ingress.yaml

# this patches the hostname of the Ingress
patches:
- patch: |-
- op: replace
path: /spec/rules/0/host
value: localhost # add your fqdn
target:
kind: Ingress
name: ddns-updater

0 comments on commit 679a1d1

Please sign in to comment.