diff --git a/kubernetes/README.md b/kubernetes/README.md new file mode 100644 index 0000000..e85b0c4 --- /dev/null +++ b/kubernetes/README.md @@ -0,0 +1,32 @@ +# Uptime-Kuma K8s Deployment + +⚠ Warning: K8s deployment is provided by contributors. I have no experience with K8s and I can't fix error in the future. I only test Docker and Node.js. Use at your own risk. + +## 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. +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. + +## 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. diff --git a/kubernetes/kustomization.yml b/kubernetes/kustomization.yml new file mode 100644 index 0000000..0daf10f --- /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 0000000..b97ece2 --- /dev/null +++ b/kubernetes/uptime-kuma/deployment.yml @@ -0,0 +1,45 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + component: uptime-kuma + name: deployment +spec: + selector: + matchLabels: + component: uptime-kuma + replicas: 1 + strategy: + type: Recreate + + template: + metadata: + labels: + component: uptime-kuma + spec: + containers: + - name: app + image: louislam/uptime-kuma:1 + ports: + - containerPort: 3001 + volumeMounts: + - mountPath: /app/data + name: storage + livenessProbe: + exec: + command: + - node + - extra/healthcheck.js + initialDelaySeconds: 180 + periodSeconds: 60 + timeoutSeconds: 30 + readinessProbe: + httpGet: + path: / + port: 3001 + scheme: HTTP + + volumes: + - name: storage + persistentVolumeClaim: + claimName: pvc diff --git a/kubernetes/uptime-kuma/ingressroute.yml b/kubernetes/uptime-kuma/ingressroute.yml new file mode 100644 index 0000000..71f7027 --- /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: ingress +spec: + tls: + - hosts: + - example.com + secretName: example-com-tls + rules: + - host: example.com + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: service + port: + number: 3001 diff --git a/kubernetes/uptime-kuma/kustomization.yml b/kubernetes/uptime-kuma/kustomization.yml new file mode 100644 index 0000000..638a2ab --- /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 0000000..eda3b8b --- /dev/null +++ b/kubernetes/uptime-kuma/pvc.yml @@ -0,0 +1,10 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: pvc +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 4Gi diff --git a/kubernetes/uptime-kuma/service.yml b/kubernetes/uptime-kuma/service.yml new file mode 100644 index 0000000..5fa812e --- /dev/null +++ b/kubernetes/uptime-kuma/service.yml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: Service +metadata: + name: service +spec: + selector: + component: uptime-kuma + type: ClusterIP + ports: + - name: http + port: 3001 + targetPort: 3001 + protocol: TCP