From bd9e283d3b883d797bb2aea11bc164cb8ff1037a Mon Sep 17 00:00:00 2001 From: Timofei Larkin Date: Thu, 3 Jul 2025 16:53:39 +0300 Subject: [PATCH] [platform] Always set resources for managed apps This patch removes the loophole to leave resource requests and limits unspecified in managed apps. Any of cpu, memory, and ephemeral storage are now filled in from the resource preset (default or user-specified) if not explicitly specified in .Values.resources. "none" is no longer an accepted value in resourcePresets and the primary resources now always have some explicit value for proper billing and isolation. Signed-off-by: Timofei Larkin --- packages/apps/clickhouse/Chart.yaml | 2 +- .../apps/clickhouse/templates/clickhouse.yaml | 6 +-- packages/apps/ferretdb/Chart.yaml | 2 +- .../apps/ferretdb/templates/postgres.yaml | 6 +-- packages/apps/http-cache/Chart.yaml | 2 +- .../templates/haproxy/deployment.yaml | 6 +-- .../templates/nginx/deployment.yaml | 6 +-- packages/apps/kafka/Chart.yaml | 2 +- packages/apps/kafka/templates/kafka.yaml | 12 +----- .../apps/kubernetes/templates/cluster.yaml | 24 ++--------- packages/apps/mysql/Chart.yaml | 2 +- packages/apps/mysql/templates/mariadb.yaml | 6 +-- packages/apps/nats/Chart.yaml | 2 +- packages/apps/nats/templates/nats.yaml | 6 +-- packages/apps/postgres/Chart.yaml | 2 +- packages/apps/postgres/templates/db.yaml | 6 +-- packages/apps/rabbitmq/Chart.yaml | 2 +- .../apps/rabbitmq/templates/rabbitmq.yaml | 6 +-- packages/apps/redis/Chart.yaml | 2 +- .../apps/redis/templates/redisfailover.yaml | 12 +----- packages/apps/tcp-balancer/Chart.yaml | 2 +- .../tcp-balancer/templates/deployment.yaml | 6 +-- packages/apps/versions_map | 32 ++++++++++----- packages/apps/vpn/Chart.yaml | 2 +- packages/apps/vpn/templates/deployment.yaml | 6 +-- packages/library/cozy-lib/Chart.yaml | 2 +- .../cozy-lib/templates/_resourcepresets.tpl | 33 ++++++++------- .../library/cozy-lib/templates/_resources.tpl | 41 +++++++++++++++++++ 28 files changed, 110 insertions(+), 128 deletions(-) diff --git a/packages/apps/clickhouse/Chart.yaml b/packages/apps/clickhouse/Chart.yaml index 637569d7..9692c075 100644 --- a/packages/apps/clickhouse/Chart.yaml +++ b/packages/apps/clickhouse/Chart.yaml @@ -16,7 +16,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.10.1 +version: 0.11.0 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/packages/apps/clickhouse/templates/clickhouse.yaml b/packages/apps/clickhouse/templates/clickhouse.yaml index 657121d4..1acc7003 100644 --- a/packages/apps/clickhouse/templates/clickhouse.yaml +++ b/packages/apps/clickhouse/templates/clickhouse.yaml @@ -132,11 +132,7 @@ spec: containers: - name: clickhouse image: clickhouse/clickhouse-server:24.9.2.42 - {{- if .Values.resources }} - resources: {{- include "cozy-lib.resources.sanitize" (list .Values.resources $) | nindent 16 }} - {{- else if ne .Values.resourcesPreset "none" }} - resources: {{- include "cozy-lib.resources.preset" (list .Values.resourcesPreset $) | nindent 16 }} - {{- end }} + resources: {{- include "cozy-lib.resources.defaultingSanitize" (list .Values.resourcesPreset .Values.resources $) | nindent 16 }} volumeMounts: - name: data-volume-template mountPath: /var/lib/clickhouse diff --git a/packages/apps/ferretdb/Chart.yaml b/packages/apps/ferretdb/Chart.yaml index 887b16e1..cde9f1f1 100644 --- a/packages/apps/ferretdb/Chart.yaml +++ b/packages/apps/ferretdb/Chart.yaml @@ -16,7 +16,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.7.1 +version: 0.8.0 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/packages/apps/ferretdb/templates/postgres.yaml b/packages/apps/ferretdb/templates/postgres.yaml index f0ad0064..82900b8c 100644 --- a/packages/apps/ferretdb/templates/postgres.yaml +++ b/packages/apps/ferretdb/templates/postgres.yaml @@ -18,11 +18,7 @@ spec: {{- end }} minSyncReplicas: {{ .Values.quorum.minSyncReplicas }} maxSyncReplicas: {{ .Values.quorum.maxSyncReplicas }} - {{- if .Values.resources }} - resources: {{- include "cozy-lib.resources.sanitize" (list .Values.resources $) | nindent 4 }} - {{- else if ne .Values.resourcesPreset "none" }} - resources: {{- include "cozy-lib.resources.preset" (list .Values.resourcesPreset $) | nindent 4 }} - {{- end }} + resources: {{- include "cozy-lib.resources.defaultingSanitize" (list .Values.resourcesPreset .Values.resources $) | nindent 4 }} monitoring: enablePodMonitor: true diff --git a/packages/apps/http-cache/Chart.yaml b/packages/apps/http-cache/Chart.yaml index 963c1d12..8d788564 100644 --- a/packages/apps/http-cache/Chart.yaml +++ b/packages/apps/http-cache/Chart.yaml @@ -16,7 +16,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.5.2 +version: 0.6.0 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/packages/apps/http-cache/templates/haproxy/deployment.yaml b/packages/apps/http-cache/templates/haproxy/deployment.yaml index 887ba892..5ff3abf6 100644 --- a/packages/apps/http-cache/templates/haproxy/deployment.yaml +++ b/packages/apps/http-cache/templates/haproxy/deployment.yaml @@ -33,11 +33,7 @@ spec: containers: - image: haproxy:latest name: haproxy - {{- if .Values.haproxy.resources }} - resources: {{- include "cozy-lib.resources.sanitize" (list .Values.haproxy.resources $) | nindent 10 }} - {{- else if ne .Values.haproxy.resourcesPreset "none" }} - resources: {{- include "cozy-lib.resources.preset" (list .Values.haproxy.resourcesPreset $) | nindent 10 }} - {{- end }} + resources: {{- include "cozy-lib.resources.defaultingSanitize" (list .Values.haproxy.resourcesPreset .Values.haproxy.resources $) | nindent 10 }} ports: - containerPort: 8080 name: http diff --git a/packages/apps/http-cache/templates/nginx/deployment.yaml b/packages/apps/http-cache/templates/nginx/deployment.yaml index edff24f7..9ee4e69d 100644 --- a/packages/apps/http-cache/templates/nginx/deployment.yaml +++ b/packages/apps/http-cache/templates/nginx/deployment.yaml @@ -52,11 +52,7 @@ spec: shareProcessNamespace: true containers: - name: nginx - {{- if $.Values.nginx.resources }} - resources: {{- include "cozy-lib.resources.sanitize" (list $.Values.nginx.resources $) | nindent 10 }} - {{- else if ne $.Values.nginx.resourcesPreset "none" }} - resources: {{- include "cozy-lib.resources.preset" (list $.Values.nginx.resourcesPreset $) | nindent 10 }} - {{- end }} + resources: {{- include "cozy-lib.resources.defaultingSanitize" (list $.Values.nginx.resourcesPreset $.Values.nginx.resources $) | nindent 10 }} image: "{{ $.Files.Get "images/nginx-cache.tag" | trim }}" readinessProbe: httpGet: diff --git a/packages/apps/kafka/Chart.yaml b/packages/apps/kafka/Chart.yaml index 61b14916..f609f238 100644 --- a/packages/apps/kafka/Chart.yaml +++ b/packages/apps/kafka/Chart.yaml @@ -16,7 +16,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.7.1 +version: 0.8.0 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/packages/apps/kafka/templates/kafka.yaml b/packages/apps/kafka/templates/kafka.yaml index c99b4ee5..36f6d43e 100644 --- a/packages/apps/kafka/templates/kafka.yaml +++ b/packages/apps/kafka/templates/kafka.yaml @@ -8,11 +8,7 @@ metadata: spec: kafka: replicas: {{ .Values.kafka.replicas }} - {{- if .Values.kafka.resources }} - resources: {{- include "cozy-lib.resources.sanitize" (list .Values.kafka.resources $) | nindent 6 }} - {{- else if ne .Values.kafka.resourcesPreset "none" }} - resources: {{- include "cozy-lib.resources.preset" (list .Values.kafka.resourcesPreset $) | nindent 6 }} - {{- end }} + resources: {{- include "cozy-lib.resources.defaultingSanitize" (list .Values.kafka.resourcesPreset .Values.kafka.resources $) | nindent 6 }} listeners: - name: plain port: 9092 @@ -70,11 +66,7 @@ spec: key: kafka-metrics-config.yml zookeeper: replicas: {{ .Values.zookeeper.replicas }} - {{- if .Values.zookeeper.resources }} - resources: {{- include "cozy-lib.resources.sanitize" (list .Values.zookeeper.resources $) | nindent 6 }} - {{- else if ne .Values.zookeeper.resourcesPreset "none" }} - resources: {{- include "cozy-lib.resources.preset" (list .Values.zookeeper.resourcesPreset $) | nindent 6 }} - {{- end }} + resources: {{- include "cozy-lib.resources.defaultingSanitize" (list .Values.zookeeper.resourcesPreset .Values.zookeeper.resources $) | nindent 6 }} storage: type: persistent-claim {{- with .Values.zookeeper.size }} diff --git a/packages/apps/kubernetes/templates/cluster.yaml b/packages/apps/kubernetes/templates/cluster.yaml index dedbb454..7f3144a1 100644 --- a/packages/apps/kubernetes/templates/cluster.yaml +++ b/packages/apps/kubernetes/templates/cluster.yaml @@ -120,23 +120,11 @@ metadata: kamaji.clastix.io/kubeconfig-secret-key: "super-admin.svc" spec: apiServer: - {{- if .Values.controlPlane.apiServer.resources }} - resources: {{- include "cozy-lib.resources.sanitize" (list .Values.controlPlane.apiServer.resources $) | nindent 6 }} - {{- else if ne .Values.controlPlane.apiServer.resourcesPreset "none" }} - resources: {{- include "cozy-lib.resources.preset" (list .Values.controlPlane.apiServer.resourcesPreset $) | nindent 6 }} - {{- end }} + resources: {{- include "cozy-lib.resources.defaultingSanitize" (list .Values.controlPlane.apiServer.resourcesPreset .Values.controlPlane.apiServer.resources $) | nindent 6 }} controllerManager: - {{- if .Values.controlPlane.controllerManager.resources }} - resources: {{- include "cozy-lib.resources.sanitize" (list .Values.controlPlane.controllerManager.resources $) | nindent 6 }} - {{- else if ne .Values.controlPlane.controllerManager.resourcesPreset "none" }} - resources: {{- include "cozy-lib.resources.preset" (list .Values.controlPlane.controllerManager.resourcesPreset $) | nindent 6 }} - {{- end }} + resources: {{- include "cozy-lib.resources.defaultingSanitize" (list .Values.controlPlane.controllerManager.resourcesPreset .Values.controlPlane.controllerManager.resources $) | nindent 6 }} scheduler: - {{- if .Values.controlPlane.scheduler.resources }} - resources: {{- include "cozy-lib.resources.sanitize" (list .Values.controlPlane.scheduler.resources $) | nindent 6 }} - {{- else if ne .Values.controlPlane.scheduler.resourcesPreset "none" }} - resources: {{- include "cozy-lib.resources.preset" (list .Values.controlPlane.scheduler.resourcesPreset $) | nindent 6 }} - {{- end }} + resources: {{- include "cozy-lib.resources.defaultingSanitize" (list .Values.controlPlane.scheduler.resourcesPreset .Values.controlPlane.scheduler.resources $) | nindent 6 }} dataStoreName: "{{ $etcd }}" addons: coreDNS: @@ -145,11 +133,7 @@ spec: konnectivity: server: port: 8132 - {{- if .Values.controlPlane.konnectivity.server.resources }} - resources: {{- include "cozy-lib.resources.sanitize" (list .Values.controlPlane.konnectivity.server.resources $) | nindent 10 }} - {{- else if ne .Values.controlPlane.konnectivity.server.resourcesPreset "none" }} - resources: {{- include "cozy-lib.resources.preset" (list .Values.controlPlane.konnectivity.server.resourcesPreset $) | nindent 10 }} - {{- end }} + resources: {{- include "cozy-lib.resources.defaultingSanitize" (list .Values.controlPlane.konnectivity.server.resourcesPreset .Values.controlPlane.konnectivity.server.resources $) | nindent 10 }} kubelet: cgroupfs: systemd preferredAddressTypes: diff --git a/packages/apps/mysql/Chart.yaml b/packages/apps/mysql/Chart.yaml index 694e2dc3..449fb6a4 100644 --- a/packages/apps/mysql/Chart.yaml +++ b/packages/apps/mysql/Chart.yaml @@ -16,7 +16,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.8.2 +version: 0.9.0 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/packages/apps/mysql/templates/mariadb.yaml b/packages/apps/mysql/templates/mariadb.yaml index 50a1ca1c..3ba3748b 100644 --- a/packages/apps/mysql/templates/mariadb.yaml +++ b/packages/apps/mysql/templates/mariadb.yaml @@ -80,8 +80,4 @@ spec: #secondaryService: # type: LoadBalancer - {{- if .Values.resources }} - resources: {{- include "cozy-lib.resources.sanitize" (list .Values.resources $) | nindent 4 }} - {{- else if ne .Values.resourcesPreset "none" }} - resources: {{- include "cozy-lib.resources.preset" (list .Values.resourcesPreset $) | nindent 4 }} - {{- end }} + resources: {{- include "cozy-lib.resources.defaultingSanitize" (list .Values.resourcesPreset .Values.resources $) | nindent 4 }} diff --git a/packages/apps/nats/Chart.yaml b/packages/apps/nats/Chart.yaml index baf24a94..882bf345 100644 --- a/packages/apps/nats/Chart.yaml +++ b/packages/apps/nats/Chart.yaml @@ -16,7 +16,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.7.1 +version: 0.8.0 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/packages/apps/nats/templates/nats.yaml b/packages/apps/nats/templates/nats.yaml index 91ff0952..75956b56 100644 --- a/packages/apps/nats/templates/nats.yaml +++ b/packages/apps/nats/templates/nats.yaml @@ -46,11 +46,7 @@ spec: containers: - name: nats image: nats:2.10.17-alpine - {{- if .Values.resources }} - resources: {{- include "cozy-lib.resources.sanitize" (list .Values.resources $) | nindent 22 }} - {{- else if ne .Values.resourcesPreset "none" }} - resources: {{- include "cozy-lib.resources.preset" (list .Values.resourcesPreset $) | nindent 22 }} - {{- end }} + resources: {{- include "cozy-lib.resources.defaultingSanitize" (list .Values.resourcesPreset .Values.resources $) | nindent 22 }} fullnameOverride: {{ .Release.Name }} config: cluster: diff --git a/packages/apps/postgres/Chart.yaml b/packages/apps/postgres/Chart.yaml index a4945f47..f7564890 100644 --- a/packages/apps/postgres/Chart.yaml +++ b/packages/apps/postgres/Chart.yaml @@ -16,7 +16,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.15.1 +version: 0.16.0 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/packages/apps/postgres/templates/db.yaml b/packages/apps/postgres/templates/db.yaml index 3ce939e8..516077bd 100644 --- a/packages/apps/postgres/templates/db.yaml +++ b/packages/apps/postgres/templates/db.yaml @@ -42,11 +42,7 @@ spec: key: AWS_SECRET_ACCESS_KEY {{- end }} - {{- if .Values.resources }} - resources: {{- include "cozy-lib.resources.sanitize" (list .Values.resources $) | nindent 4 }} - {{- else if ne .Values.resourcesPreset "none" }} - resources: {{- include "cozy-lib.resources.preset" (list .Values.resourcesPreset $) | nindent 4 }} - {{- end }} + resources: {{- include "cozy-lib.resources.defaultingSanitize" (list .Values.resourcesPreset .Values.resources $) | nindent 4 }} enableSuperuserAccess: true {{- $configMap := lookup "v1" "ConfigMap" "cozy-system" "cozystack-scheduling" }} diff --git a/packages/apps/rabbitmq/Chart.yaml b/packages/apps/rabbitmq/Chart.yaml index 1d9d84d6..41c0ea20 100644 --- a/packages/apps/rabbitmq/Chart.yaml +++ b/packages/apps/rabbitmq/Chart.yaml @@ -16,7 +16,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.7.1 +version: 0.8.0 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/packages/apps/rabbitmq/templates/rabbitmq.yaml b/packages/apps/rabbitmq/templates/rabbitmq.yaml index 29ef473e..7708a3af 100644 --- a/packages/apps/rabbitmq/templates/rabbitmq.yaml +++ b/packages/apps/rabbitmq/templates/rabbitmq.yaml @@ -11,11 +11,7 @@ spec: service: type: LoadBalancer {{- end }} - {{- if .Values.resources }} - resources: {{- include "cozy-lib.resources.sanitize" (list .Values.resources $) | nindent 4 }} - {{- else if ne .Values.resourcesPreset "none" }} - resources: {{- include "cozy-lib.resources.preset" (list .Values.resourcesPreset $) | nindent 4 }} - {{- end }} + resources: {{- include "cozy-lib.resources.defaultingSanitize" (list .Values.resourcesPreset .Values.resources $) | nindent 4 }} override: statefulSet: spec: diff --git a/packages/apps/redis/Chart.yaml b/packages/apps/redis/Chart.yaml index c3f3e088..94294f91 100644 --- a/packages/apps/redis/Chart.yaml +++ b/packages/apps/redis/Chart.yaml @@ -16,7 +16,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.8.1 +version: 0.9.0 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/packages/apps/redis/templates/redisfailover.yaml b/packages/apps/redis/templates/redisfailover.yaml index be75c373..f6d1ae05 100644 --- a/packages/apps/redis/templates/redisfailover.yaml +++ b/packages/apps/redis/templates/redisfailover.yaml @@ -25,18 +25,10 @@ metadata: spec: sentinel: replicas: 3 - {{- if .Values.resources }} - resources: {{- include "cozy-lib.resources.sanitize" (list .Values.resources $) | nindent 6 }} - {{- else if ne .Values.resourcesPreset "none" }} - resources: {{- include "cozy-lib.resources.preset" (list .Values.resourcesPreset $) | nindent 6 }} - {{- end }} + resources: {{- include "cozy-lib.resources.defaultingSanitize" (list .Values.resourcesPreset .Values.resources $) | nindent 6 }} redis: + resources: {{- include "cozy-lib.resources.defaultingSanitize" (list .Values.resourcesPreset .Values.resources $) | nindent 6 }} replicas: {{ .Values.replicas }} - {{- if .Values.resources }} - resources: {{- include "cozy-lib.resources.sanitize" (list .Values.resources $) | nindent 6 }} - {{- else if ne .Values.resourcesPreset "none" }} - resources: {{- include "cozy-lib.resources.preset" (list .Values.resourcesPreset $) | nindent 6 }} - {{- end }} {{- with .Values.size }} storage: persistentVolumeClaim: diff --git a/packages/apps/tcp-balancer/Chart.yaml b/packages/apps/tcp-balancer/Chart.yaml index 4161bffc..5d2c65cf 100644 --- a/packages/apps/tcp-balancer/Chart.yaml +++ b/packages/apps/tcp-balancer/Chart.yaml @@ -16,7 +16,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.4.2 +version: 0.5.0 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/packages/apps/tcp-balancer/templates/deployment.yaml b/packages/apps/tcp-balancer/templates/deployment.yaml index a223bc2e..e23c3891 100644 --- a/packages/apps/tcp-balancer/templates/deployment.yaml +++ b/packages/apps/tcp-balancer/templates/deployment.yaml @@ -34,11 +34,7 @@ spec: containers: - image: haproxy:latest name: haproxy - {{- if .Values.resources }} - resources: {{- include "cozy-lib.resources.sanitize" (list .Values.resources $) | nindent 10 }} - {{- else if ne .Values.resourcesPreset "none" }} - resources: {{- include "cozy-lib.resources.preset" (list .Values.resourcesPreset $) | nindent 10 }} - {{- end }} + resources: {{- include "cozy-lib.resources.defaultingSanitize" (list .Values.resourcesPreset .Values.resources $) | nindent 10 }} ports: {{- with .Values.httpAndHttps }} - containerPort: 8080 diff --git a/packages/apps/versions_map b/packages/apps/versions_map index 1ac86c3d..6372e513 100644 --- a/packages/apps/versions_map +++ b/packages/apps/versions_map @@ -13,7 +13,8 @@ clickhouse 0.7.0 93bdf411 clickhouse 0.9.0 6130f43d clickhouse 0.9.2 632224a3 clickhouse 0.10.0 6358fd7a -clickhouse 0.10.1 HEAD +clickhouse 0.10.1 4369b031 +clickhouse 0.11.0 HEAD ferretdb 0.1.0 e9716091 ferretdb 0.1.1 91b0499a ferretdb 0.2.0 6c5cf5bf @@ -25,7 +26,8 @@ ferretdb 0.5.0 93bdf411 ferretdb 0.6.0 6130f43d ferretdb 0.6.1 632224a3 ferretdb 0.7.0 62cb694d -ferretdb 0.7.1 HEAD +ferretdb 0.7.1 4369b031 +ferretdb 0.8.0 HEAD http-cache 0.1.0 263e47be http-cache 0.2.0 53f2365e http-cache 0.3.0 6c5cf5bf @@ -33,7 +35,8 @@ http-cache 0.3.1 0f312d5c http-cache 0.4.0 93bdf411 http-cache 0.5.0 6130f43d http-cache 0.5.1 62cb694d -http-cache 0.5.2 HEAD +http-cache 0.5.2 4369b031 +http-cache 0.6.0 HEAD kafka 0.1.0 f7eaab0a kafka 0.2.0 c0685f43 kafka 0.2.1 dfbc210b @@ -48,7 +51,8 @@ kafka 0.5.0 93bdf411 kafka 0.6.0 6130f43d kafka 0.6.1 632224a3 kafka 0.7.0 6358fd7a -kafka 0.7.1 HEAD +kafka 0.7.1 4369b031 +kafka 0.8.0 HEAD kubernetes 0.24.0 62cb694d kubernetes 0.25.0 HEAD mysql 0.1.0 263e47be @@ -64,7 +68,7 @@ mysql 0.7.0 6130f43d mysql 0.7.1 632224a3 mysql 0.8.0 62cb694d mysql 0.8.1 4369b031 -mysql 0.8.2 HEAD +mysql 0.9.0 HEAD nats 0.1.0 e9716091 nats 0.2.0 6c5cf5bf nats 0.3.0 78366f19 @@ -75,7 +79,8 @@ nats 0.5.0 93bdf411 nats 0.6.0 6130f43d nats 0.6.1 632224a3 nats 0.7.0 62cb694d -nats 0.7.1 HEAD +nats 0.7.1 4369b031 +nats 0.8.0 HEAD postgres 0.1.0 263e47be postgres 0.2.0 53f2365e postgres 0.2.1 d7cfa53c @@ -95,7 +100,8 @@ postgres 0.11.0 f9f8bb2f postgres 0.12.0 6130f43d postgres 0.12.1 632224a3 postgres 0.14.0 62cb694d -postgres 0.15.1 HEAD +postgres 0.15.1 4369b031 +postgres 0.16.0 HEAD rabbitmq 0.1.0 263e47be rabbitmq 0.2.0 53f2365e rabbitmq 0.3.0 6c5cf5bf @@ -107,7 +113,8 @@ rabbitmq 0.4.4 8267072d rabbitmq 0.5.0 93bdf411 rabbitmq 0.6.0 632224a3 rabbitmq 0.7.0 62cb694d -rabbitmq 0.7.1 HEAD +rabbitmq 0.7.1 4369b031 +rabbitmq 0.8.0 HEAD redis 0.1.1 263e47be redis 0.2.0 53f2365e redis 0.3.0 6c5cf5bf @@ -118,13 +125,15 @@ redis 0.6.0 93bdf411 redis 0.7.0 6130f43d redis 0.7.1 632224a3 redis 0.8.0 62cb694d -redis 0.8.1 HEAD +redis 0.8.1 4369b031 +redis 0.9.0 HEAD tcp-balancer 0.1.0 263e47be tcp-balancer 0.2.0 53f2365e tcp-balancer 0.3.0 93bdf411 tcp-balancer 0.4.0 6130f43d tcp-balancer 0.4.1 62cb694d -tcp-balancer 0.4.2 HEAD +tcp-balancer 0.4.2 4369b031 +tcp-balancer 0.5.0 HEAD tenant 1.10.0 4369b031 tenant 1.11.0 HEAD virtual-machine 0.1.4 f2015d65 @@ -170,4 +179,5 @@ vpn 0.4.0 93bdf411 vpn 0.5.0 6130f43d vpn 0.5.1 632224a3 vpn 0.6.1 62cb694d -vpn 0.6.2 HEAD +vpn 0.6.2 4369b031 +vpn 0.7.0 HEAD diff --git a/packages/apps/vpn/Chart.yaml b/packages/apps/vpn/Chart.yaml index 6e1dbb77..2ee979e4 100644 --- a/packages/apps/vpn/Chart.yaml +++ b/packages/apps/vpn/Chart.yaml @@ -16,7 +16,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.6.2 +version: 0.7.0 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/packages/apps/vpn/templates/deployment.yaml b/packages/apps/vpn/templates/deployment.yaml index c4acb5d5..a5a66dd3 100644 --- a/packages/apps/vpn/templates/deployment.yaml +++ b/packages/apps/vpn/templates/deployment.yaml @@ -43,11 +43,7 @@ spec: containers: - name: outline-vpn image: quay.io/outline/shadowbox:stable - {{- if .Values.resources }} - resources: {{- include "cozy-lib.resources.sanitize" (list .Values.resources $) | nindent 12 }} - {{- else if ne .Values.resourcesPreset "none" }} - resources: {{- include "cozy-lib.resources.preset" (list .Values.resourcesPreset $) | nindent 12 }} - {{- end }} + resources: {{- include "cozy-lib.resources.defaultingSanitize" (list .Values.resourcesPreset .Values.resources $) | nindent 12 }} ports: - containerPort: 40000 protocol: TCP diff --git a/packages/library/cozy-lib/Chart.yaml b/packages/library/cozy-lib/Chart.yaml index f9be0259..6aa01a14 100644 --- a/packages/library/cozy-lib/Chart.yaml +++ b/packages/library/cozy-lib/Chart.yaml @@ -15,4 +15,4 @@ type: library # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.2.0 +version: 0.3.0 diff --git a/packages/library/cozy-lib/templates/_resourcepresets.tpl b/packages/library/cozy-lib/templates/_resourcepresets.tpl index e1e95547..89d55342 100644 --- a/packages/library/cozy-lib/templates/_resourcepresets.tpl +++ b/packages/library/cozy-lib/templates/_resourcepresets.tpl @@ -1,13 +1,6 @@ {{/* vim: set filetype=mustache: */}} -{{/* -Return a resource request/limit object based on a given preset. -{{ include "cozy-lib.resources.preset" "nano" -}} -*/}} -{{- define "cozy-lib.resources.preset" -}} -{{- $cpuAllocationRatio := include "cozy-lib.resources.cpuAllocationRatio" . | float64 }} -{{- $args := index . 0 }} -{{- $global := index . 1 }} +{{- define "cozy-lib.resources.unsanitizedPreset" }} {{- $baseCPU := dict "nano" (dict "cpu" "250m" ) @@ -37,11 +30,21 @@ Return a resource request/limit object based on a given preset. "2xlarge" (dict "ephemeral-storage" "2Gi" ) }} -{{- $presets := merge $baseCPU $baseMemory $baseEphemeralStorage }} -{{- if hasKey $presets $args -}} -{{- $flatDict := index $presets $args }} -{{- include "cozy-lib.resources.sanitize" (list $flatDict $global) }} -{{- else -}} -{{- printf "ERROR: Preset key '%s' invalid. Allowed values are %s" . (join "," (keys $presets)) | fail -}} -{{- end -}} +{{- $presets := merge $baseCPU $baseMemory $baseEphemeralStorage }} +{{- if not (hasKey $presets .) -}} +{{- printf "ERROR: Preset key '%s' invalid. Allowed values are %s" . (join "," (keys $presets)) | fail -}} +{{- end }} +{{- index $presets . | toYaml }} +{{- end }} + +{{/* + Return a resource request/limit object based on a given preset. + {{- include "cozy-lib.resources.preset" list ("nano" $) }} +*/}} +{{- define "cozy-lib.resources.preset" -}} +{{- $cpuAllocationRatio := include "cozy-lib.resources.cpuAllocationRatio" . | float64 }} +{{- $args := index . 0 }} +{{- $global := index . 1 }} +{{- $unsanitizedPreset := include "cozy-lib.resources.unsanitizedPreset" list ($args $global) | fromYaml }} +{{- include "cozy-lib.resources.sanitize" (list $unsanitizedPreset $global) }} {{- end -}} diff --git a/packages/library/cozy-lib/templates/_resources.tpl b/packages/library/cozy-lib/templates/_resources.tpl index 8ea1fe10..20a27fad 100644 --- a/packages/library/cozy-lib/templates/_resources.tpl +++ b/packages/library/cozy-lib/templates/_resources.tpl @@ -116,3 +116,44 @@ {{- end }} {{- $output | toYaml }} {{- end }} + +{{- /* + The defaultingSanitize helper takes a 3-element list as its argument: + {{- include "cozy-lib.resources.defaultingSanitize" list ( + .Values.resourcesPreset + .Values.resources + $ + ) }} + and returns the same result as + {{- include "cozy-lib.resources.sanitize" list ( + .Values.resources + $ + ) }}, however if cpu, memory, or ephemeral storage is not specified in + .Values.resources, it is filled from the resource presets. + + Example input (cpuAllocationRatio = 10): + ======================================== + resources: + cpu: "1" + resourcesPreset: "nano" + + Example output: + =============== + resources: + limits: + cpu: "1" # == user input + ephemeral-storage: 2Gi # == default ephemeral storage limit + memory: 128Mi # from "nano" + requests: + cpu: 100m # == 1 / 10 + ephemeral-storage: 50Mi # == default ephemeral storage request + memory: 128Mi # memory request == limit +*/}} +{{- define "cozy-lib.resources.defaultingSanitize" }} +{{- $preset := index . 0 }} +{{- $resources := index . 1 }} +{{- $global := index . 2 }} +{{- $presetMap := include "cozy-lib.resources.unsanitizedPreset" $preset | fromYaml }} +{{- $mergedMap := deepCopy $resources | mergeOverwrite $presetMap }} +{{- include "cozy-lib.resources.sanitize" (list $mergedMap $global) }} +{{- end }}