From 60b0ee2959d911c721cafee0e8c9ce3be61e3a34 Mon Sep 17 00:00:00 2001 From: Carl Sander Date: Wed, 18 Aug 2021 08:38:05 +0000 Subject: [PATCH 1/7] added K8s-Deployment and edited README --- README.md | 4 +++ kubernetes/README.md | 27 ++++++++++++++++ kubernetes/kustomization.yml | 10 ++++++ kubernetes/uptime-kuma/deployment.yml | 34 +++++++++++++++++++++ kubernetes/uptime-kuma/ingressroute.yml | 39 ++++++++++++++++++++++++ kubernetes/uptime-kuma/kustomization.yml | 5 +++ kubernetes/uptime-kuma/pvc.yml | 10 ++++++ kubernetes/uptime-kuma/service.yml | 13 ++++++++ 8 files changed, 142 insertions(+) create mode 100644 kubernetes/README.md create mode 100644 kubernetes/kustomization.yml create mode 100644 kubernetes/uptime-kuma/deployment.yml create mode 100644 kubernetes/uptime-kuma/ingressroute.yml create mode 100644 kubernetes/uptime-kuma/kustomization.yml create mode 100644 kubernetes/uptime-kuma/pvc.yml create mode 100644 kubernetes/uptime-kuma/service.yml diff --git a/README.md b/README.md index 7984a31aa..82970675e 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,10 @@ docker run -d --restart=always -p 3001:3001 -v uptime-kuma:/app/data --name upti Browse to http://localhost:3001 after started. +### ☸️ Kubernetes + +See more [here](kubernetes/README.md) + If you want to change **port** and **volume**, or need to browse via a reserve proxy, please read wiki. diff --git a/kubernetes/README.md b/kubernetes/README.md new file mode 100644 index 000000000..1f243b524 --- /dev/null +++ b/kubernetes/README.md @@ -0,0 +1,27 @@ +# Uptime-Kuma K8s Deployment +## How does it work? + +Kustomize is a tool which builds a complete deployment file for all config elements. +You can edit the files in the ```uptime-kuma``` folder except the ```kustomization.yml``` until you know what you're doing. + +It creates a certificate with the specified Issuer and creates the Ingress for the Uptime-Kuma ClusterIP-Service + +## What do i have to edit? +You have to edit the ```ingressroute.yml``` to your needs. +This ingressroute.yml is for the [nginx-ingress-controller](https://kubernetes.github.io/ingress-nginx/) in combination with the [cert-manager](https://cert-manager.io/). + +- host +- secrets and secret names +- (Cluster)Issuer (optional) +- the Version in the Deployment-File + - update: + - change to newer version and run the above commands, it will update the pods one after another + +## How To use: + +- install [kustomize](https://kubectl.docs.kubernetes.io/installation/kustomize/) +- Edit files mentioned above to your needs +- run ```kustomize build > apply.yml``` +- run ```kubectl apply -f apply.yml``` + +Now you should see some k8s magic and Uptime-Kuma should be available at the specified address. \ No newline at end of file diff --git a/kubernetes/kustomization.yml b/kubernetes/kustomization.yml new file mode 100644 index 000000000..0daf10f4d --- /dev/null +++ b/kubernetes/kustomization.yml @@ -0,0 +1,10 @@ +namespace: uptime-kuma +namePrefix: uptime-kuma- + +commonLabels: + app: uptime-kuma + +bases: + - uptime-kuma + + diff --git a/kubernetes/uptime-kuma/deployment.yml b/kubernetes/uptime-kuma/deployment.yml new file mode 100644 index 000000000..9ea1bdffc --- /dev/null +++ b/kubernetes/uptime-kuma/deployment.yml @@ -0,0 +1,34 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + component: uptime-kuma + name: uptime-kuma +spec: + selector: + matchLabels: + component: uptime-kuma + replicas: 3 + strategy: + rollingUpdate: + maxSurge: 1 + maxUnavailable: 1 + type: RollingUpdate + + template: + metadata: + labels: + component: uptime-kuma + spec: + containers: + - name: uptime-kuma + image: louislam/uptime-kuma:1.2.0 + ports: + - containerPort: 3001 + volumeMounts: + - mountPath: /app/data + name: uptime-kuma-storage + volumes: + - name: uptime-kuma-storage + persistentVolumeClaim: + claimName: uptime-kuma-pvc diff --git a/kubernetes/uptime-kuma/ingressroute.yml b/kubernetes/uptime-kuma/ingressroute.yml new file mode 100644 index 000000000..66ad6fb7e --- /dev/null +++ b/kubernetes/uptime-kuma/ingressroute.yml @@ -0,0 +1,39 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + annotations: + kubernetes.io/ingress.class: nginx + cert-manager.io/cluster-issuer: letsencrypt-prod + nginx.ingress.kubernetes.io/proxy-read-timeout: "3600" + nginx.ingress.kubernetes.io/proxy-send-timeout: "3600" + nginx.ingress.kubernetes.io/server-snippets: | + location / { + proxy_set_header Upgrade $http_upgrade; + proxy_http_version 1.1; + proxy_set_header X-Forwarded-Host $http_host; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Forwarded-For $remote_addr; + proxy_set_header Host $host; + proxy_set_header Connection "upgrade"; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header Upgrade $http_upgrade; + proxy_cache_bypass $http_upgrade; + } + name: uptime-kuma-ingress +spec: + tls: + - hosts: + - monitor.cxde.link + secretName: monitor-cxde-link-tls + rules: + - host: monitor.cxde.link + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: uptime-kuma-uptime-kuma + port: + number: 3001 diff --git a/kubernetes/uptime-kuma/kustomization.yml b/kubernetes/uptime-kuma/kustomization.yml new file mode 100644 index 000000000..638a2ab69 --- /dev/null +++ b/kubernetes/uptime-kuma/kustomization.yml @@ -0,0 +1,5 @@ +resources: + - deployment.yml + - service.yml + - ingressroute.yml + - pvc.yml \ No newline at end of file diff --git a/kubernetes/uptime-kuma/pvc.yml b/kubernetes/uptime-kuma/pvc.yml new file mode 100644 index 000000000..c20e5d06c --- /dev/null +++ b/kubernetes/uptime-kuma/pvc.yml @@ -0,0 +1,10 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: uptime-kuma-pvc +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 4Gi \ No newline at end of file diff --git a/kubernetes/uptime-kuma/service.yml b/kubernetes/uptime-kuma/service.yml new file mode 100644 index 000000000..67f50a370 --- /dev/null +++ b/kubernetes/uptime-kuma/service.yml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: Service +metadata: + name: uptime-kuma +spec: + selector: + component: uptime-kuma + type: ClusterIP + ports: + - name: http + port: 3001 + targetPort: 3001 + protocol: TCP From b41799f801e123d52f94a0295195dc2d31681878 Mon Sep 17 00:00:00 2001 From: Carl Dominik Sander Date: Wed, 18 Aug 2021 16:09:06 +0200 Subject: [PATCH 2/7] reolved suggestions from @srgvg and @louislam --- kubernetes/uptime-kuma/deployment.yml | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/kubernetes/uptime-kuma/deployment.yml b/kubernetes/uptime-kuma/deployment.yml index 9ea1bdffc..8082d06bc 100644 --- a/kubernetes/uptime-kuma/deployment.yml +++ b/kubernetes/uptime-kuma/deployment.yml @@ -8,12 +8,9 @@ spec: selector: matchLabels: component: uptime-kuma - replicas: 3 + replicas: 1 strategy: - rollingUpdate: - maxSurge: 1 - maxUnavailable: 1 - type: RollingUpdate + type: Recreate template: metadata: @@ -28,6 +25,17 @@ spec: volumeMounts: - mountPath: /app/data name: uptime-kuma-storage + livenessProbe: + exec: + command: + - node + - extra/healthcheck.js + readinessProbe: + httpGet: + path: / + port: 3001 + scheme: HTTP + volumes: - name: uptime-kuma-storage persistentVolumeClaim: From 21640e1bbe88a4cd918af8b1fdba75d710bdfc77 Mon Sep 17 00:00:00 2001 From: Carl Dominik Sander Date: Wed, 18 Aug 2021 17:58:17 +0200 Subject: [PATCH 3/7] changed to tag 1 --- kubernetes/uptime-kuma/deployment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kubernetes/uptime-kuma/deployment.yml b/kubernetes/uptime-kuma/deployment.yml index 8082d06bc..f6726202e 100644 --- a/kubernetes/uptime-kuma/deployment.yml +++ b/kubernetes/uptime-kuma/deployment.yml @@ -19,7 +19,7 @@ spec: spec: containers: - name: uptime-kuma - image: louislam/uptime-kuma:1.2.0 + image: louislam/uptime-kuma:1 ports: - containerPort: 3001 volumeMounts: From 5b5a32967c67fdb31b45243a4d2caab871ebe26a Mon Sep 17 00:00:00 2001 From: Carl Sander Date: Thu, 19 Aug 2021 09:55:43 +0000 Subject: [PATCH 4/7] fixed README --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e17b0c742..4c1f45878 100644 --- a/README.md +++ b/README.md @@ -41,11 +41,12 @@ docker volume create uptime-kuma docker run -d --restart=always -p 3001:3001 -v uptime-kuma:/app/data --name uptime-kuma louislam/uptime-kuma:1 ``` +Browse to http://localhost:3001 after started. + ### ☸️ Kubernetes See more [here](kubernetes/README.md) -Browse to http://localhost:3001 after started. ### Advanced Installation From 22047fe9323609a5e1793ee407a67b80783e763a Mon Sep 17 00:00:00 2001 From: Carl Sander Date: Thu, 19 Aug 2021 11:50:05 +0000 Subject: [PATCH 5/7] removed doubled names of ressources --- kubernetes/README.md | 1 + kubernetes/uptime-kuma/deployment.yml | 10 +++++----- kubernetes/uptime-kuma/ingressroute.yml | 6 +++--- kubernetes/uptime-kuma/pvc.yml | 4 ++-- kubernetes/uptime-kuma/service.yml | 2 +- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/kubernetes/README.md b/kubernetes/README.md index 1f243b524..26ab2f6a4 100644 --- a/kubernetes/README.md +++ b/kubernetes/README.md @@ -3,6 +3,7 @@ Kustomize is a tool which builds a complete deployment file for all config elements. You can edit the files in the ```uptime-kuma``` folder except the ```kustomization.yml``` until you know what you're doing. +If you want to choose another namespace you can edit the ```kustomization.yml``` in the ```kubernetes```-Folder and change the ```namespace: uptime-kuma``` to something you like. It creates a certificate with the specified Issuer and creates the Ingress for the Uptime-Kuma ClusterIP-Service diff --git a/kubernetes/uptime-kuma/deployment.yml b/kubernetes/uptime-kuma/deployment.yml index f6726202e..a122509b0 100644 --- a/kubernetes/uptime-kuma/deployment.yml +++ b/kubernetes/uptime-kuma/deployment.yml @@ -3,7 +3,7 @@ kind: Deployment metadata: labels: component: uptime-kuma - name: uptime-kuma + name: deployment spec: selector: matchLabels: @@ -18,13 +18,13 @@ spec: component: uptime-kuma spec: containers: - - name: uptime-kuma + - name: app image: louislam/uptime-kuma:1 ports: - containerPort: 3001 volumeMounts: - mountPath: /app/data - name: uptime-kuma-storage + name: storage livenessProbe: exec: command: @@ -37,6 +37,6 @@ spec: scheme: HTTP volumes: - - name: uptime-kuma-storage + - name: storage persistentVolumeClaim: - claimName: uptime-kuma-pvc + claimName: pvc diff --git a/kubernetes/uptime-kuma/ingressroute.yml b/kubernetes/uptime-kuma/ingressroute.yml index 66ad6fb7e..a94f16eea 100644 --- a/kubernetes/uptime-kuma/ingressroute.yml +++ b/kubernetes/uptime-kuma/ingressroute.yml @@ -20,11 +20,11 @@ metadata: proxy_set_header Upgrade $http_upgrade; proxy_cache_bypass $http_upgrade; } - name: uptime-kuma-ingress + name: ingress spec: tls: - hosts: - - monitor.cxde.link + - uk.kube.cxde.link secretName: monitor-cxde-link-tls rules: - host: monitor.cxde.link @@ -34,6 +34,6 @@ spec: pathType: Prefix backend: service: - name: uptime-kuma-uptime-kuma + name: service port: number: 3001 diff --git a/kubernetes/uptime-kuma/pvc.yml b/kubernetes/uptime-kuma/pvc.yml index c20e5d06c..eda3b8be5 100644 --- a/kubernetes/uptime-kuma/pvc.yml +++ b/kubernetes/uptime-kuma/pvc.yml @@ -1,10 +1,10 @@ apiVersion: v1 kind: PersistentVolumeClaim metadata: - name: uptime-kuma-pvc + name: pvc spec: accessModes: - ReadWriteOnce resources: requests: - storage: 4Gi \ No newline at end of file + storage: 4Gi diff --git a/kubernetes/uptime-kuma/service.yml b/kubernetes/uptime-kuma/service.yml index 67f50a370..5fa812e18 100644 --- a/kubernetes/uptime-kuma/service.yml +++ b/kubernetes/uptime-kuma/service.yml @@ -1,7 +1,7 @@ apiVersion: v1 kind: Service metadata: - name: uptime-kuma + name: service spec: selector: component: uptime-kuma From 1e7623c459bf7aa678e2faeadc7ebe3d7ee73233 Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Thu, 19 Aug 2021 21:22:16 +0800 Subject: [PATCH 6/7] Update README.md --- README.md | 7 ------- 1 file changed, 7 deletions(-) diff --git a/README.md b/README.md index 4c1f45878..025510f52 100644 --- a/README.md +++ b/README.md @@ -26,14 +26,7 @@ Interactive cli installer, supports Docker or without Docker. ```bash curl -o kuma_install.sh https://raw.githubusercontent.com/louislam/uptime-kuma/master/install.sh && sudo bash kuma_install.sh ``` -Browse to http://localhost:3001 after started. -If you want to change **port** and **volume**, or need to browse via a reserve proxy, please read wiki. - -### 💪🏻 Without Docker (Recommended for x86/x64 only) - -Required Tools: Node.js >= 14, git and pm2. -======= ### 🐳 Docker ```bash From 6fcc2253ec4221d1f32a3c12467fee9d0c410e66 Mon Sep 17 00:00:00 2001 From: Carl Sander Date: Fri, 20 Aug 2021 06:21:59 +0000 Subject: [PATCH 7/7] changed domain names to example.com --- kubernetes/uptime-kuma/ingressroute.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kubernetes/uptime-kuma/ingressroute.yml b/kubernetes/uptime-kuma/ingressroute.yml index a94f16eea..71f7027ff 100644 --- a/kubernetes/uptime-kuma/ingressroute.yml +++ b/kubernetes/uptime-kuma/ingressroute.yml @@ -24,10 +24,10 @@ metadata: spec: tls: - hosts: - - uk.kube.cxde.link - secretName: monitor-cxde-link-tls + - example.com + secretName: example-com-tls rules: - - host: monitor.cxde.link + - host: example.com http: paths: - path: /