From f6e588940b30d481030ba7109b82bd43c1c5d9ef Mon Sep 17 00:00:00 2001 From: Nikolai Rodionov Date: Mon, 18 Nov 2024 13:58:31 +0100 Subject: [PATCH] Init commit --- LICENSE | 10 ++ README.md | 1 + charts/badhouseplants/.helmignore | 23 +++++ charts/badhouseplants/Chart.yaml | 6 ++ charts/badhouseplants/templates/NOTES.txt | 22 +++++ charts/badhouseplants/templates/_helpers.tpl | 62 ++++++++++++ .../badhouseplants/templates/deployment.yaml | 72 ++++++++++++++ charts/badhouseplants/templates/hpa.yaml | 32 +++++++ charts/badhouseplants/templates/ingress.yaml | 61 ++++++++++++ .../templates/nginx-config-cm.yaml | 19 ++++ charts/badhouseplants/templates/service.yaml | 15 +++ charts/badhouseplants/values.yaml | 95 +++++++++++++++++++ 12 files changed, 418 insertions(+) create mode 100644 LICENSE create mode 100644 README.md create mode 100644 charts/badhouseplants/.helmignore create mode 100644 charts/badhouseplants/Chart.yaml create mode 100644 charts/badhouseplants/templates/NOTES.txt create mode 100644 charts/badhouseplants/templates/_helpers.tpl create mode 100644 charts/badhouseplants/templates/deployment.yaml create mode 100644 charts/badhouseplants/templates/hpa.yaml create mode 100644 charts/badhouseplants/templates/ingress.yaml create mode 100644 charts/badhouseplants/templates/nginx-config-cm.yaml create mode 100644 charts/badhouseplants/templates/service.yaml create mode 100644 charts/badhouseplants/values.yaml diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..f2cd8f5 --- /dev/null +++ b/LICENSE @@ -0,0 +1,10 @@ +MIT License + +Copyright (c) 2024 badhouseplants + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + diff --git a/README.md b/README.md new file mode 100644 index 0000000..1f02d1d --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# Badhouseplants charts diff --git a/charts/badhouseplants/.helmignore b/charts/badhouseplants/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/badhouseplants/.helmignore @@ -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/ diff --git a/charts/badhouseplants/Chart.yaml b/charts/badhouseplants/Chart.yaml new file mode 100644 index 0000000..0f546c3 --- /dev/null +++ b/charts/badhouseplants/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: badhouseplants-net +description: A Helm chart for Kubernetes +type: application +version: 0.9.0 +appVersion: "4.20.0" diff --git a/charts/badhouseplants/templates/NOTES.txt b/charts/badhouseplants/templates/NOTES.txt new file mode 100644 index 0000000..76b24e8 --- /dev/null +++ b/charts/badhouseplants/templates/NOTES.txt @@ -0,0 +1,22 @@ +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 }}{{ .path }} + {{- 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 "badhouseplants-net.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 "badhouseplants-net.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "badhouseplants-net.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 "badhouseplants-net.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT +{{- end }} diff --git a/charts/badhouseplants/templates/_helpers.tpl b/charts/badhouseplants/templates/_helpers.tpl new file mode 100644 index 0000000..864ef6f --- /dev/null +++ b/charts/badhouseplants/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "badhouseplants-net.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 "badhouseplants-net.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 "badhouseplants-net.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "badhouseplants-net.labels" -}} +helm.sh/chart: {{ include "badhouseplants-net.chart" . }} +{{ include "badhouseplants-net.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "badhouseplants-net.selectorLabels" -}} +app.kubernetes.io/name: {{ include "badhouseplants-net.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "badhouseplants-net.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "badhouseplants-net.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/charts/badhouseplants/templates/deployment.yaml b/charts/badhouseplants/templates/deployment.yaml new file mode 100644 index 0000000..92c0b12 --- /dev/null +++ b/charts/badhouseplants/templates/deployment.yaml @@ -0,0 +1,72 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "badhouseplants-net.fullname" . }} + labels: + {{- include "badhouseplants-net.labels" . | nindent 4 }} + {{- with .Values.deployAnnotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "badhouseplants-net.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "badhouseplants-net.selectorLabels" . | nindent 8 }} + spec: + initContainers: + - name: {{ .Values.hugo.container.name }} + env: + {{- range $key, $value := .Values.hugo.env}} + - name: {{ $key }} + value: {{ $value }} + {{- end}} + args: + - --baseURL + - {{ .Values.hugo.baseURL }} + {{- if .Values.hugo.buildDrafts }} + - --buildDrafts + {{- end }} + volumeMounts: + - name: {{ .Values.volumes.public.name }} + mountPath: /src/public + readOnly: false + image: "{{ .Values.hugo.image.repository}}:{{ .Values.hugo.image.tag}}" + imagePullPolicy: {{ .Values.hugo.image.pullPolicy }} + resources: + {{- toYaml .Values.hugo.container.resources | nindent 12 }} + containers: + - name: {{ .Values.nginx.container.name }} + image: "{{ .Values.nginx.image.repository}}:{{ .Values.nginx.image.tag}}" + imagePullPolicy: {{ .Values.nginx.image.pullPolicy }} + ports: + - name: http + containerPort: {{ .Values.service.port }} + protocol: TCP + resources: + {{- toYaml .Values.nginx.container.resources | nindent 12 }} + volumeMounts: + - name: {{ .Values.volumes.public.name }} + mountPath: /var/www + readOnly: true + - name: nginx-config + mountPath: /etc/nginx/conf.d + readOnly: true + volumes: + - name: {{ .Values.volumes.public.name }} + emptyDir: + sizeLimit: {{ .Values.volumes.public.sizeLimit }} + - name: nginx-config + configMap: + name: nginx-config-{{ .Release.Name }} + diff --git a/charts/badhouseplants/templates/hpa.yaml b/charts/badhouseplants/templates/hpa.yaml new file mode 100644 index 0000000..2a9e279 --- /dev/null +++ b/charts/badhouseplants/templates/hpa.yaml @@ -0,0 +1,32 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "badhouseplants.fullname" . }} + labels: + {{- include "badhouseplants.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "badhouseplants.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/charts/badhouseplants/templates/ingress.yaml b/charts/badhouseplants/templates/ingress.yaml new file mode 100644 index 0000000..4d8ee58 --- /dev/null +++ b/charts/badhouseplants/templates/ingress.yaml @@ -0,0 +1,61 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "badhouseplants-net.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} + {{- end }} +{{- end }} +{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1 +{{- else 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 "badhouseplants-net.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.ingress.className }} + {{- end }} + {{- 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: {{ .path }} + {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: {{ .pathType }} + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- else }} + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} diff --git a/charts/badhouseplants/templates/nginx-config-cm.yaml b/charts/badhouseplants/templates/nginx-config-cm.yaml new file mode 100644 index 0000000..bcaab33 --- /dev/null +++ b/charts/badhouseplants/templates/nginx-config-cm.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: nginx-config-{{ .Release.Name }} + labels: + {{- include "badhouseplants-net.labels" . | nindent 4 }} +data: + default.conf: | + server { + listen 80; + listen [::]:80; + server_name ~.; + root /var/www; + index index.html; + location / { + try_files $uri $uri/ =404; + } + } + diff --git a/charts/badhouseplants/templates/service.yaml b/charts/badhouseplants/templates/service.yaml new file mode 100644 index 0000000..f1d3c10 --- /dev/null +++ b/charts/badhouseplants/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "badhouseplants-net.fullname" . }} + labels: + {{- include "badhouseplants-net.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "badhouseplants-net.selectorLabels" . | nindent 4 }} diff --git a/charts/badhouseplants/values.yaml b/charts/badhouseplants/values.yaml new file mode 100644 index 0000000..db7aa56 --- /dev/null +++ b/charts/badhouseplants/values.yaml @@ -0,0 +1,95 @@ +replicaCount: 1 + +nginx: + container: + name: nginx + resources: {} + image: + repository: nginx + pullPolicy: Always + tag: latest + +hugo: + container: + name: badhouseplants-net + resources: {} + image: + repository: zot.badhouseplants.net/badhouseplants/badhouseplants-net + pullPolicy: Always + tag: latest + baseURL: https://badhouseplants.net/ + buildDrafts: false + env: + HUGO_PARAMS_GITBRANCH: main + +volumes: + public: + name: public-content + sizeLimit: 1Gi + +remark42: + enabled: true + settings: + url: https://remark42.badhouseplants.net + secretKey: secret + emoji: true + auth: + anonymous: false + sameSite: "none" + oauth: + google: + enabled: false + github: + enabled: false + istio: + annotations: {} + enabled: true + hosts: + - remark42.badhouseplants.net + prefix: / + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +deployAnnotations: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + port: 80 + +ingress: + enabled: true + annotations: + cert-manager.io/cluster-issuer: badhouseplants-issuer-http01 + kubernetes.io/ingress.allow-http: "false" + kubernetes.io/ingress.class: traefik + kubernetes.io/tls-acme: "true" + traefik.ingress.kubernetes.io/router.entrypoints: web,websecure + tls: + - secretName: badhouseplants.net + hosts: + - badhouseplants.net + hosts: + - host: badhouseplants.net + paths: + - path: / + pathType: Prefix + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80