From 324daad743360224308ddd3ef3e296da795dc574 Mon Sep 17 00:00:00 2001 From: Yung Wood Date: Sun, 1 Sep 2024 12:24:06 +0000 Subject: [PATCH 1/2] helm chart updates remove pod autoscaler add values schema add support for additional manifests --- .../ical-filter-proxy/templates/_helpers.tpl | 12 + .../ical-filter-proxy/templates/config.yaml | 1 + .../templates/deployment.yaml | 4 +- .../templates/extra-resources.yaml | 4 + charts/ical-filter-proxy/templates/hpa.yaml | 32 -- .../ical-filter-proxy/templates/ingress.yaml | 1 + .../ical-filter-proxy/templates/service.yaml | 1 + .../templates/serviceaccount.yaml | 1 + charts/ical-filter-proxy/values.schema.json | 407 ++++++++++++++++++ charts/ical-filter-proxy/values.yaml | 22 +- 10 files changed, 442 insertions(+), 43 deletions(-) create mode 100644 charts/ical-filter-proxy/templates/extra-resources.yaml delete mode 100644 charts/ical-filter-proxy/templates/hpa.yaml create mode 100644 charts/ical-filter-proxy/values.schema.json diff --git a/charts/ical-filter-proxy/templates/_helpers.tpl b/charts/ical-filter-proxy/templates/_helpers.tpl index 5c07908..00adfd6 100644 --- a/charts/ical-filter-proxy/templates/_helpers.tpl +++ b/charts/ical-filter-proxy/templates/_helpers.tpl @@ -60,3 +60,15 @@ Create the name of the service account to use {{- default "default" .Values.serviceAccount.name }} {{- end }} {{- end }} + +{{/* +Renders a value that contains template perhaps with scope if the scope is present. +*/}} +{{- define "tplRender" -}} +{{- $value := typeIs "string" .value | ternary .value (.value | toYaml) }} +{{- if contains "{{" $value }} + {{- tpl $value .context }} +{{- else }} + {{- $value }} +{{- end }} +{{- end -}} \ No newline at end of file diff --git a/charts/ical-filter-proxy/templates/config.yaml b/charts/ical-filter-proxy/templates/config.yaml index bac6e3a..86a9c1d 100644 --- a/charts/ical-filter-proxy/templates/config.yaml +++ b/charts/ical-filter-proxy/templates/config.yaml @@ -1,4 +1,5 @@ {{- if .Values.config.enabled -}} +--- apiVersion: v1 kind: ConfigMap metadata: diff --git a/charts/ical-filter-proxy/templates/deployment.yaml b/charts/ical-filter-proxy/templates/deployment.yaml index 46ae7c8..efb9b73 100644 --- a/charts/ical-filter-proxy/templates/deployment.yaml +++ b/charts/ical-filter-proxy/templates/deployment.yaml @@ -1,3 +1,4 @@ +--- apiVersion: apps/v1 kind: Deployment metadata: @@ -5,9 +6,8 @@ metadata: labels: {{- include "ical-filter-proxy.labels" . | nindent 4 }} spec: - {{- if not .Values.autoscaling.enabled }} replicas: {{ .Values.replicaCount }} - {{- end }} + revisionHistoryLimit: {{ .Values.revisionHistoryLimit | default "3" }} selector: matchLabels: {{- include "ical-filter-proxy.selectorLabels" . | nindent 6 }} diff --git a/charts/ical-filter-proxy/templates/extra-resources.yaml b/charts/ical-filter-proxy/templates/extra-resources.yaml new file mode 100644 index 0000000..e375e21 --- /dev/null +++ b/charts/ical-filter-proxy/templates/extra-resources.yaml @@ -0,0 +1,4 @@ +{{- range .Values.extraResources }} +--- +{{ include "tplRender" (dict "value" . "context" $) }} +{{- end }} diff --git a/charts/ical-filter-proxy/templates/hpa.yaml b/charts/ical-filter-proxy/templates/hpa.yaml deleted file mode 100644 index ee955cd..0000000 --- a/charts/ical-filter-proxy/templates/hpa.yaml +++ /dev/null @@ -1,32 +0,0 @@ -{{- if .Values.autoscaling.enabled }} -apiVersion: autoscaling/v2 -kind: HorizontalPodAutoscaler -metadata: - name: {{ include "ical-filter-proxy.fullname" . }} - labels: - {{- include "ical-filter-proxy.labels" . | nindent 4 }} -spec: - scaleTargetRef: - apiVersion: apps/v1 - kind: Deployment - name: {{ include "ical-filter-proxy.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/ical-filter-proxy/templates/ingress.yaml b/charts/ical-filter-proxy/templates/ingress.yaml index 99f59e7..61197b1 100644 --- a/charts/ical-filter-proxy/templates/ingress.yaml +++ b/charts/ical-filter-proxy/templates/ingress.yaml @@ -6,6 +6,7 @@ {{- $_ := 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 -}} diff --git a/charts/ical-filter-proxy/templates/service.yaml b/charts/ical-filter-proxy/templates/service.yaml index 0d36a9c..ac975ec 100644 --- a/charts/ical-filter-proxy/templates/service.yaml +++ b/charts/ical-filter-proxy/templates/service.yaml @@ -1,3 +1,4 @@ +--- apiVersion: v1 kind: Service metadata: diff --git a/charts/ical-filter-proxy/templates/serviceaccount.yaml b/charts/ical-filter-proxy/templates/serviceaccount.yaml index 0c954e3..5418b67 100644 --- a/charts/ical-filter-proxy/templates/serviceaccount.yaml +++ b/charts/ical-filter-proxy/templates/serviceaccount.yaml @@ -1,4 +1,5 @@ {{- if .Values.serviceAccount.create -}} +--- apiVersion: v1 kind: ServiceAccount metadata: diff --git a/charts/ical-filter-proxy/values.schema.json b/charts/ical-filter-proxy/values.schema.json new file mode 100644 index 0000000..cf2fcf2 --- /dev/null +++ b/charts/ical-filter-proxy/values.schema.json @@ -0,0 +1,407 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "affinity": { + "properties": {}, + "type": "object" + }, + "args": { + "type": "array" + }, + "config": { + "properties": { + "additionalProperties": false, + "calendars": { + "items": { + "additionalProperties": false, + "properties": { + "feed_url": { + "type": "string" + }, + "filters": { + "items": { + "additionalProperties": false, + "properties": { + "description": { + "type": "string" + }, + "match": { + "additionalProperties": false, + "properties": { + "summary": { + "additionalProperties": false, + "properties": { + "prefix": { + "type": "string" + }, + "suffix": { + "type": "string" + }, + "contains": { + "type": "string" + }, + "regex": { + "type": "string" + } + }, + "type": "object" + }, + "description": { + "additionalProperties": false, + "properties": { + "prefix": { + "type": "string" + }, + "suffix": { + "type": "string" + }, + "contains": { + "type": "string" + }, + "regex": { + "type": "string" + } + }, + "type": "object" + }, + "location": { + "additionalProperties": false, + "properties": { + "prefix": { + "type": "string" + }, + "suffix": { + "type": "string" + }, + "contains": { + "type": "string" + }, + "regex": { + "type": "string" + } + }, + "type": "object" + } + }, + "type": "object" + }, + "remove": { + "type": "boolean" + }, + "stop": { + "type": "boolean" + }, + "transform": { + "additionalProperties": false, + "properties": { + "summary": { + "additionalProperties": false, + "properties": { + "replace": { + "type": "string" + }, + "remove": { + "type": "boolean" + } + }, + "type": "object" + }, + "description": { + "additionalProperties": false, + "properties": { + "replace": { + "type": "string" + }, + "remove": { + "type": "boolean" + } + }, + "type": "object" + }, + "location": { + "additionalProperties": false, + "properties": { + "replace": { + "type": "string" + }, + "remove": { + "type": "boolean" + } + }, + "type": "object" + } + }, + "type": "object" + } + }, + "type": "object" + }, + "type": "array" + }, + "name": { + "type": "string" + }, + "token": { + "type": "string" + } + }, + "required": ["feed_url", "name"], + "type": "object" + }, + "minItems": 1, + "type": "array" + }, + "enabled": { + "type": "boolean" + }, + "insecure": { + "type": "boolean" + } + }, + "allOf": [ + { + "if": { + "properties": { + "enabled": { "const": true } + } + }, + "then": { + "required": ["calendars"] + } + }, + { + "if": { + "properties": { + "calendars": { + "type": "array", + "items": { + "not": { + "required": ["token"] + } + } + } + } + }, + "then": { + "properties": { + "insecure": { "const": true } + } + } + } + ], + "type": "object" + }, + "extraResources": { + "type": "array", + "items": { + "type": ["object", "string"] + } + }, + "fullnameOverride": { + "type": "string" + }, + "image": { + "additionalProperties": false, + "properties": { + "pullPolicy": { + "type": "string", + "enum": ["Always", "IfNotPresent", "Never"] + }, + "repository": { + "type": "string" + }, + "tag": { + "type": "string" + } + }, + "required": ["repository", "pullPolicy"], + "type": "object" + }, + "imagePullSecrets": { + "type": "array" + }, + "ingress": { + "properties": { + "annotations": { + "additionalProperties": { + "type": "string" + }, + "properties": {}, + "type": "object" + }, + "className": { + "type": "string" + }, + "enabled": { + "type": "boolean" + }, + "hosts": { + "items": { + "properties": { + "host": { + "type": "string" + }, + "paths": { + "items": { + "properties": { + "path": { + "type": "string" + }, + "pathType": { + "type": "string" + } + }, + "type": "object" + }, + "type": "array" + } + }, + "type": "object" + }, + "type": "array" + }, + "tls": { + "items": { + "properties": { + "hosts": { + "items": { + "type": "string" + }, + "type": "array" + }, + "secretName": { + "type": "string" + } + }, + "type": "object" + }, + "type": "array" + } + }, + "type": "object" + }, + "livenessProbe": { + "properties": {}, + "type": "object" + }, + "nameOverride": { + "type": "string" + }, + "nodeSelector": { + "properties": {}, + "type": "object" + }, + "podAnnotations": { + "properties": {}, + "type": "object" + }, + "podLabels": { + "properties": {}, + "type": "object" + }, + "podSecurityContext": { + "properties": {}, + "type": "object" + }, + "readinessProbe": { + "properties": {}, + "type": "object" + }, + "replicaCount": { + "type": "integer" + }, + "resources": { + "properties": { + "limits": { + "properties": {}, + "type": "object" + }, + "requests": { + "properties": {}, + "type": "object" + } + }, + "type": "object" + }, + "securityContext": { + "properties": {}, + "type": "object" + }, + "service": { + "properties": { + "port": { + "type": "integer" + }, + "type": { + "type": "string" + } + }, + "type": "object" + }, + "serviceAccount": { + "properties": { + "annotations": { + "additionalProperties": { + "type": "string" + }, + "properties": {}, + "type": "object" + }, + "automount": { + "type": "boolean" + }, + "create": { + "type": "boolean" + }, + "name": { + "type": "string" + } + }, + "type": "object" + }, + "tolerations": { + "type": "array" + }, + "volumeMounts": { + "items": { + "properties": { + "mountPath": { + "type": "string" + }, + "name": { + "type": "string" + }, + "readOnly": { + "type": "boolean" + } + }, + "type": "object" + }, + "type": "array" + }, + "volumes": { + "items": { + "properties": { + "name": { + "type": "string" + }, + "secret": { + "properties": { + "optional": { + "type": "boolean" + }, + "secretName": { + "type": "string" + } + }, + "type": "object" + } + }, + "type": "object" + }, + "type": "array" + } + }, + "required": ["image", "config", "extraResources", "livenessProbe", "readinessProbe", "replicaCount"], + "type": "object" +} diff --git a/charts/ical-filter-proxy/values.yaml b/charts/ical-filter-proxy/values.yaml index fb7c046..22da6ba 100644 --- a/charts/ical-filter-proxy/values.yaml +++ b/charts/ical-filter-proxy/values.yaml @@ -1,5 +1,3 @@ -replicaCount: 1 - image: repository: yungwood/ical-filter-proxy pullPolicy: IfNotPresent @@ -9,6 +7,8 @@ imagePullSecrets: [] nameOverride: "" fullnameOverride: "" +replicaCount: 1 + args: [] config: @@ -94,13 +94,6 @@ readinessProbe: path: /readiness port: http -autoscaling: - enabled: false - minReplicas: 1 - maxReplicas: 100 - targetCPUUtilizationPercentage: 80 - # targetMemoryUtilizationPercentage: 80 - volumes: [] # - name: foo # secret: @@ -117,3 +110,14 @@ nodeSelector: {} tolerations: [] affinity: {} + +## Add additional manifests to the chart (supports templating) +# extraResources: +# - apiVersion: v1 +# kind: ConfigMap +# metadata: +# name: '{{ template "ical-filter-proxy.fullname" . }}-extra-cm' +# data: +# key: | +# some-value +extraResources: [] \ No newline at end of file From 13aac43d09d02f6441a7166a37bc0d60977a3c69 Mon Sep 17 00:00:00 2001 From: Yung Wood Date: Sun, 1 Sep 2024 22:48:16 +0930 Subject: [PATCH 2/2] release 0.1.1 --- charts/ical-filter-proxy/Chart.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/charts/ical-filter-proxy/Chart.yaml b/charts/ical-filter-proxy/Chart.yaml index 0834935..e76868d 100644 --- a/charts/ical-filter-proxy/Chart.yaml +++ b/charts/ical-filter-proxy/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 name: ical-filter-proxy description: iCal proxy with support for user-defined filtering rules type: application -version: 0.1.0 -appVersion: "0.1.0" +version: 0.1.1 +appVersion: "0.1.1" maintainers: - name: Yung Wood