[statping] New Chart (#36)

Co-authored-by: Devin Buhl <onedr0p@users.noreply.github.com>
This commit is contained in:
Nicholas St. Germain 2020-09-13 07:09:14 -05:00 committed by GitHub
parent 63b87146a3
commit a037936b3e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 670 additions and 0 deletions

2
.gitignore vendored
View File

@ -1,2 +1,4 @@
.env
.idea
charts/*/Chart.lock
charts/*/charts

View File

@ -0,0 +1,23 @@
# 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
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/

View File

@ -0,0 +1,22 @@
apiVersion: v2
name: statping
description: Status page for monitoring your websites and applications
type: application
version: 1.0.0
appVersion: v0.90.65
keywords:
- statping
- status
- status-page
home: https://github.com/k8s-at-home/charts/tree/master/charts/statping
sources:
- https://github.com/statping/statping
maintainers:
- name: DirtyCajunRice
email: nick@cajun.pro
icon: https://github.com/statping/statping/blob/dev/frontend/src/assets/logo.png?raw=true
dependencies:
- name: postgresql
repository: https://charts.bitnami.com/bitnami
version: 9.4.0
condition: postgres.posgresql.enabled

4
charts/statping/OWNERS Normal file
View File

@ -0,0 +1,4 @@
approvers:
- DirtyCajunRice
reviewers:
- DirtyCajunRice

37
charts/statping/README.md Normal file
View File

@ -0,0 +1,37 @@
# statping | Status page for monitoring your websites and applications
## TL;DR
```console
$ helm repo add k8s-at-home https://k8s-at-home.com/charts/
$ helm install k8s-at-home/statping
```
## Installing the Chart
To install the chart with the release name `statping`:
```console
helm install statping k8s-at-home/statping
```
## Uninstalling the Chart
To uninstall the `statping` deployment:
```console
helm uninstall statping
```
The command removes all the Kubernetes components associated with the chart and deletes the release.
## Configuration
Read through the [values.yaml](https://github.com/k8s-at-home/charts/blob/master/charts/statping/values.yaml)
file. It has several commented out suggested values.
Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example,
```console
helm install statping \
--set statping.env.TZ="America/New York" \
k8s-at-home/statping
```
Alternatively, a YAML file that specifies the values for the above parameters can be provided while installing the
chart. For example,
```console
helm install statping k8s-at-home/statping --values values.yaml
```

View File

@ -0,0 +1,21 @@
1. Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
{{- range $host := .Values.ingress.hosts }}
{{- range .paths }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ . }}
{{- end }}
{{- end }}
{{- else if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "statping.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "statping.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "statping.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "statping.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:80
{{- end }}

View File

@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "statping.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 "statping.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 "statping.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
Common labels
*/}}
{{- define "statping.labels" -}}
helm.sh/chart: {{ include "statping.chart" . }}
{{ include "statping.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}
{{/*
Selector labels
*/}}
{{- define "statping.selectorLabels" -}}
app.kubernetes.io/name: {{ include "statping.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
{{/*
Create the name of the service account to use
*/}}
{{- define "statping.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "statping.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

View File

@ -0,0 +1,166 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "statping.fullname" . }}
labels:
{{- include "statping.labels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "statping.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "statping.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "statping.serviceAccountName" . }}
{{- with .Values.podSecurityContext }}
securityContext:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: {{ .Chart.Name }}
{{- with .Values.securityContext }}
securityContext:
{{- toYaml . | nindent 12 }}
{{- end }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
{{- if .Values.statping.name }}
- name: NAME
value: {{ .Values.statping.name | quote }}
{{- end }}
{{- if .Values.statping.description }}
- name: DESCRIPTION
value: {{ .Values.statping.description | quote }}
{{- end }}
{{- if .Values.statping.domain }}
- name: DOMAIN
value: {{ .Values.statping.domain | quote }}
{{- end }}
- name: ADMIN_USER
valueFrom:
secretKeyRef:
{{- if .Values.statping.admin.existingSecret.enabled }}
name: {{ .Values.statping.admin.existingSecret.name | quote }}
key: {{ .Values.statping.admin.existingSecret.userKey | default "admin-user" }}
{{- else }}
name: {{ include "statping.fullname" . }}
key: admin-user
{{- end }}
- name: ADMIN_PASSWORD
valueFrom:
secretKeyRef:
{{- if .Values.statping.admin.existingSecret.enabled }}
name: {{ .Values.statping.admin.existingSecret.name | quote }}
key: {{ .Values.statping.admin.existingSecret.passwordKey | default "admin-password" }}
{{- else }}
name: {{ include "statping.fullname" . }}
key: admin-password
{{- end }}
- name: ADMIN_EMAIL
valueFrom:
secretKeyRef:
{{- if .Values.statping.admin.existingSecret.enabled }}
name: {{ .Values.statping.admin.existingSecret.name | quote }}
key: {{ .Values.statping.admin.existingSecret.emailKey | default "admin-email" }}
{{- else }}
name: {{ include "statping.fullname" . }}
key: admin-email
{{- end }}
{{- if and (eq .Values.postgres.type "kubedb") .Values.postgres.kubedb.enabled }}
- name: DB_CONN
value: postgres
- name: DB_HOST
value: postgres-{{ template "statping.fullname" . }}
- name: DB_DATABASE
value: postgres
- name: DB_USER
valueFrom:
secretKeyRef:
name: postgres-{{ template "statping.fullname" . }}-auth
key: POSTGRES_USER
- name: DB_PASS
valueFrom:
secretKeyRef:
name: postgres-{{ template "statping.fullname" . }}-auth
key: POSTGRES_PASSWORD
{{- end }}
{{- if and (eq .Values.postgres.type "postgresql") .Values.postgres.posgresql.enabled }}
- name: DB_CONN
value: postgres
- name: DB_HOST
value: {{ template "postgresql.fullname" . }}-postgresql
- name: DB_DATABASE
value: {{ template "postgresql.database" . }}
- name: DB_USER
value: {{ template "postgresql.username" . }}
- name: DB_PASS
valueFrom:
secretKeyRef:
name: {{ template "postgresql.secretName" . }}-postgresql
key: postgresql-password
{{- end }}
{{- with .Values.env }}
{{- toYaml . | nindent 12 }}
{{- end }}
ports:
- name: http
containerPort: 8080
protocol: TCP
livenessProbe:
httpGet:
path: /
port: http
readinessProbe:
httpGet:
path: /
port: http
volumeMounts:
- mountPath: /app
name: config
{{- if .Values.persistence.subPath }}
subPath: {{ .Values.persistence.subPath }}
{{- end }}
{{- if .Values.additionalVolumeMounts }}
{{- toYaml .Values.additionalVolumes | nindent 12 }}
{{- end }}
{{- with .Values.resources }}
resources:
{{- toYaml . | nindent 12 }}
{{- end }}
volumes:
- name: config
{{- if .Values.persistence.enabled }}
persistentVolumeClaim:
claimName: {{ if .Values.persistence.existingClaim }}{{ .Values.persistence.existingClaim }}{{- else }}{{ template "statping.fullname" . }}{{- end }}
{{- else }}
emptyDir: {}
{{- end }}
{{- if .Values.additionalVolumes }}
{{- toYaml .Values.additionalVolumes | nindent 8 }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}

View File

@ -0,0 +1,14 @@
{{- if and .Values.externalSecret.enabled (eq .Values.externalSecret.type "kubernetes-external-secrets") }}
apiVersion: kubernetes-client.io/v1
kind: ExternalSecret
metadata:
name: {{ include "statping.fullname" . }}
spec:
{{- with .Values.externalSecret.kubernetesExternalSecrets.spec }}
{{- toYaml . | nindent 2 }}
{{- end }}
data:
{{- with .Values.externalSecret.kubernetesExternalSecrets.data }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}

View File

@ -0,0 +1,28 @@
{{- if .Values.autoscaling.enabled }}
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "statping.fullname" . }}
labels:
{{- include "statping.labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "statping.fullname" . }}
minReplicas: {{ .Values.autoscaling.minReplicas }}
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
metrics:
{{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
{{- end }}
{{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
{{- end }}
{{- end }}

View File

@ -0,0 +1,41 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "statping.fullname" . -}}
{{- $svcPort := .Values.service.port -}}
{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1beta1
{{- else -}}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
name: {{ $fullName }}
labels:
{{- include "statping.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
- host: {{ .host | quote }}
http:
paths:
{{- range .paths }}
- path: {{ . }}
backend:
serviceName: {{ $fullName }}
servicePort: {{ $svcPort }}
{{- end }}
{{- end }}
{{- end }}

View File

@ -0,0 +1,13 @@
{{- if and .Values.postgres.enabled (eq .Values.postgres.type "kubedb") }}
apiVersion: kubedb.com/v1alpha1
kind: Postgres
metadata:
name: postgres-{{ template "statping.fullname" . }}
spec:
version: {{ .Values.postgres.kubedb.version }}
storageType: {{ .Values.postgres.kubedb.storageType }}
{{- with .Values.postgres.kubedb.storage }}
storage:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}

View File

@ -0,0 +1,15 @@
{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) -}}
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: {{ include "statping.fullname" . }}
spec:
accessModes:
- {{ .Values.persistence.accessMode | quote }}
resources:
requests:
storage: {{ .Values.persistence.size | quote }}
{{- if .Values.persistence.storageClass }}
storageClassName: {{ .Values.persistence.storageClass | quote }}
{{- end }}
{{- end -}}

View File

@ -0,0 +1,13 @@
{{- if not .Values.statping.admin.existingSecret.enabled }}
apiVersion: v1
kind: Secret
metadata:
name: {{ template "statping.fullname" . }}
labels:
{{- include "statping.labels" . | nindent 4 }}
type: Opaque
data:
admin-user: {{ default "admin" .Values.statping.admin.user | b64enc | quote }}
admin-password: {{ randAlphaNum 16 | b64enc | quote }}
admin-email: {{ default "info@admin.com" .Values.statping.admin.email | b64enc | quote}}
{{- end }}

View File

@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "statping.fullname" . }}
labels:
{{- include "statping.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
{{- include "statping.selectorLabels" . | nindent 4 }}

View File

@ -0,0 +1,12 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "statping.serviceAccountName" . }}
labels:
{{- include "statping.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}

View File

@ -0,0 +1,15 @@
apiVersion: v1
kind: Pod
metadata:
name: "{{ include "statping.fullname" . }}-test-connection"
labels:
{{- include "statping.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": test-success
spec:
containers:
- name: wget
image: busybox
command: ['wget']
args: ['{{ include "statping.fullname" . }}:{{ .Values.service.port }}']
restartPolicy: Never

167
charts/statping/values.yaml Normal file
View File

@ -0,0 +1,167 @@
# Default values for statping.
image:
repository: statping/statping
pullPolicy: IfNotPresent
tag: ""
global:
postgresql:
postgresqlDatabase: "postgres"
postgresqlUsername: "postgres"
statping:
name: ""
description: ""
domain: ""
admin:
user: ""
password: ""
email: ""
existingSecret:
enabled: false
name: ""
userKey: ""
passwordKey: ""
emailKey: ""
# Probes configuration
probes:
liveness:
initialDelaySeconds: 60
failureThreshold: 5
timeoutSeconds: 10
readiness:
initialDelaySeconds: 60
failureThreshold: 5
timeoutSeconds: 10
imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""
env: []
service:
type: ClusterIP
port: 8080
## Specify the nodePort value for the LoadBalancer and NodePort service types.
## ref: https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport
##
# nodePort:
## Provide any additional annotations which may be required. This can be used to
## set the LoadBalancer service type to internal only.
## ref: https://kubernetes.io/docs/concepts/services-networking/service/#internal-load-balancer
##
annotations: {}
labels: {}
additionalSpec: {}
ingress:
enabled: false
annotations: {}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
labels: {}
hosts:
- host: chart-example.local
paths:
- /
tls: []
# - secretName: chart-example-tls
# hosts:
# - chart-example.local
persistence:
enabled: true
## statping configuration data Persistent Volume Storage Class
## If defined, storageClassName: <storageClass>
## If set to "-", storageClassName: "", which disables dynamic provisioning
## If undefined (the default) or set to null, no storageClassName spec is
## set, choosing the default provisioner. (gp2 on AWS, standard on
## GKE, AWS & OpenStack)
##
# storageClass: "-"
##
## If you want to reuse an existing claim, you can pass the name of the PVC using
## the existingClaim variable
# existingClaim: your-claim
# subPath: some-subpath
accessMode: ReadWriteOnce
size: 1Gi
## Do not delete the pvc upon helm uninstall
skipuninstall: false
postgres:
type: postgresql
kubedb:
enabled: false
version: 11.1
storageType: Durable
storage:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
posgresql:
enabled: true
# See https://github.com/bitnami/charts/tree/master/bitnami/postgresql for configuration
externalSecret:
enabled: false
type: kubernetes-external-secrets
kubernetesExternalSecrets:
spec: {}
data: []
additionalVolumes: []
additionalVolumeMounts: []
serviceAccount:
# Specifies whether a service account should be created
create: true
# Annotations to add to the service account
annotations: {}
# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template
name: ""
autoscaling:
enabled: false
minReplicas: 1
maxReplicas: 3
targetCPUUtilizationPercentage: 80
# targetMemoryUtilizationPercentage: 80
podSecurityContext: {}
# fsGroup: 2000
securityContext: {}
# capabilities:
# drop:
# - ALL
# readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000
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: {}
podAnnotations: {}