diff --git a/uptime-kuma/Chart.yaml b/uptime-kuma/Chart.yaml new file mode 100644 index 0000000..50dd9a1 --- /dev/null +++ b/uptime-kuma/Chart.yaml @@ -0,0 +1,8 @@ +apiVersion: v2 +name: uptime-kuma +description: Uptime Kuma Helm chart +type: application +version: 0.1.1 +appVersion: "2.2.1" +annotations: + version-source: github-release:louislam/uptime-kuma diff --git a/uptime-kuma/templates/backup-cronjob.yaml b/uptime-kuma/templates/backup-cronjob.yaml new file mode 100644 index 0000000..9f5395f --- /dev/null +++ b/uptime-kuma/templates/backup-cronjob.yaml @@ -0,0 +1,57 @@ +{{- if .Values.backup.enabled -}} +apiVersion: batch/v1 +kind: CronJob +metadata: + name: {{ .Release.Name }}-backup +spec: + schedule: {{ .Values.backup.schedule | quote }} + jobTemplate: + spec: + template: + spec: + containers: + - name: mysql-backup + image: {{ .Values.backup.image }} + command: + - /bin/sh + - -c + - | + mysqldump -h {{ .Values.database.host }} -P {{ .Values.database.port }} -u $DB_USERNAME -p$DB_PASSWORD $DB_NAME | gzip > /backup/$DB_NAME-$(date +%Y%m%d-%H%M%S).sql.gz + find /backup -name "$DB_NAME-*.sql.gz" -mtime +{{ .Values.backup.retentionDays }} -delete + env: + - name: DB_NAME + valueFrom: + secretKeyRef: + name: {{ .Values.database.existingSecret }} + key: {{ .Values.database.secretKeys.dbName }} + - name: DB_USERNAME + valueFrom: + secretKeyRef: + name: {{ .Values.database.existingSecret }} + key: {{ .Values.database.secretKeys.dbUsername }} + - name: DB_PASSWORD + valueFrom: + secretKeyRef: + name: {{ .Values.database.existingSecret }} + key: {{ .Values.database.secretKeys.dbPassword }} + volumeMounts: + - name: backup-storage + mountPath: /backup + volumes: + - name: backup-storage + hostPath: + path: {{ .Values.backup.storagePath }} + type: DirectoryOrCreate + restartPolicy: OnFailure + {{- if .Values.backup.node }} + affinity: + nodeAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + nodeSelectorTerms: + - matchExpressions: + - key: kubernetes.io/hostname + operator: In + values: + - {{ .Values.backup.node }} + {{- end }} +{{- end }} diff --git a/uptime-kuma/templates/deployment.yaml b/uptime-kuma/templates/deployment.yaml new file mode 100644 index 0000000..9cd7378 --- /dev/null +++ b/uptime-kuma/templates/deployment.yaml @@ -0,0 +1,71 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Release.Name }} + labels: + app.kubernetes.io/name: {{ .Chart.Name }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} + app.kubernetes.io/component: monitoring + annotations: + version-source: {{ index .Chart.Annotations "version-source" }} +spec: + replicas: 1 + strategy: + type: Recreate + selector: + matchLabels: + app: {{ .Release.Name }} + template: + metadata: + labels: + app: {{ .Release.Name }} + spec: + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - containerPort: {{ .Values.port }} + name: http + env: + - name: UPTIME_KUMA_DB_TYPE + value: {{ .Values.database.type }} + - name: UPTIME_KUMA_DB_HOSTNAME + value: {{ .Values.database.host }} + - name: UPTIME_KUMA_DB_PORT + value: {{ .Values.database.port | quote }} + - name: UPTIME_KUMA_DB_NAME + valueFrom: + secretKeyRef: + name: {{ .Values.database.existingSecret }} + key: {{ .Values.database.secretKeys.dbName }} + - name: UPTIME_KUMA_DB_USERNAME + valueFrom: + secretKeyRef: + name: {{ .Values.database.existingSecret }} + key: {{ .Values.database.secretKeys.dbUsername }} + - name: UPTIME_KUMA_DB_PASSWORD + valueFrom: + secretKeyRef: + name: {{ .Values.database.existingSecret }} + key: {{ .Values.database.secretKeys.dbPassword }} + resources: + {{- toYaml .Values.resources | nindent 12 }} + volumeMounts: + - name: data + mountPath: /app/data + {{- if .Values.dockerSocket.enabled }} + - name: docker-sock + mountPath: /var/run/docker.sock + {{- end }} + volumes: + - name: data + persistentVolumeClaim: + claimName: {{ .Release.Name }}-data + {{- if .Values.dockerSocket.enabled }} + - name: docker-sock + hostPath: + path: /var/run/docker.sock + type: Socket + {{- end }} diff --git a/uptime-kuma/templates/ingress.yaml b/uptime-kuma/templates/ingress.yaml new file mode 100644 index 0000000..6a80701 --- /dev/null +++ b/uptime-kuma/templates/ingress.yaml @@ -0,0 +1,27 @@ +{{- range $name, $config := .Values.ingresses }} +--- +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ $.Release.Name }}-{{ $name }} + {{- with $config.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + rules: + - host: {{ $config.host }} + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: {{ $.Release.Name }} + port: + number: {{ $.Values.port }} + {{- with $config.tls }} + tls: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/uptime-kuma/templates/pvc.yaml b/uptime-kuma/templates/pvc.yaml new file mode 100644 index 0000000..0152748 --- /dev/null +++ b/uptime-kuma/templates/pvc.yaml @@ -0,0 +1,15 @@ +{{- if .Values.persistence.enabled }} +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: {{ .Release.Name }}-data +spec: + accessModes: + - ReadWriteOnce + {{- if .Values.persistence.storageClass }} + storageClassName: {{ .Values.persistence.storageClass }} + {{- end }} + resources: + requests: + storage: {{ .Values.persistence.size }} +{{- end }} diff --git a/uptime-kuma/templates/service.yaml b/uptime-kuma/templates/service.yaml new file mode 100644 index 0000000..4ef2e54 --- /dev/null +++ b/uptime-kuma/templates/service.yaml @@ -0,0 +1,16 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Release.Name }} + labels: + app.kubernetes.io/name: {{ .Chart.Name }} + app.kubernetes.io/instance: {{ .Release.Name }} +spec: + type: ClusterIP + selector: + app: {{ .Release.Name }} + ports: + - name: http + port: {{ .Values.port }} + targetPort: {{ .Values.port }} + protocol: TCP diff --git a/uptime-kuma/values.yaml b/uptime-kuma/values.yaml new file mode 100644 index 0000000..09fc76e --- /dev/null +++ b/uptime-kuma/values.yaml @@ -0,0 +1,49 @@ +# Default values for Uptime Kuma Helm Chart +image: + repository: louislam/uptime-kuma + pullPolicy: IfNotPresent + +port: 3001 + +database: + type: mariadb + host: mysql.mysql.svc.cluster.local + port: "3306" + existingSecret: "" + secretKeys: + dbName: db-name + dbUsername: db-username + dbPassword: db-password + +dockerSocket: + enabled: true + +resources: + requests: + cpu: "100m" + memory: "256Mi" + limits: + cpu: "500m" + memory: "512Mi" + +persistence: + enabled: true + storageClass: "" + size: 5Gi + +backup: + enabled: false + schedule: "0 3 * * *" + image: mysql:9.0 + retentionDays: 7 + storagePath: /storage/backups/mysql + # Node to run backup on (hostname) + node: "" + +ingresses: {} + # https: + # host: kuma.example.com + # annotations: {} + # tls: + # - hosts: + # - kuma.example.com