From 2126be1d29b14da8231eb5c5926f81b61a76cdf4 Mon Sep 17 00:00:00 2001 From: Alex <1353716+alexstojda@users.noreply.github.com> Date: Wed, 18 Jun 2025 20:58:08 -0400 Subject: [PATCH 1/2] feat: add option to use standard helm naming conventions --- charts/pdp/templates/_helpers.tpl | 29 +++++++++++++++++++ charts/pdp/templates/deployment.yaml | 4 +++ charts/pdp/templates/logs-forwarder-cm.yaml | 4 +++ charts/pdp/templates/poddisruptionbudget.yaml | 4 +++ charts/pdp/templates/service.yaml | 4 +++ charts/pdp/values.yaml | 19 ++++++++++++ 6 files changed, 64 insertions(+) diff --git a/charts/pdp/templates/_helpers.tpl b/charts/pdp/templates/_helpers.tpl index b65ae0ce..0c42fae9 100644 --- a/charts/pdp/templates/_helpers.tpl +++ b/charts/pdp/templates/_helpers.tpl @@ -1,3 +1,28 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "..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 "..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 }} + {{/* Selector labels */}} @@ -22,8 +47,12 @@ Get the secret name for the API key {{- if .Values.pdp.existingApiKeySecret -}} {{- .Values.pdp.existingApiKeySecret.name -}} {{- else -}} +{{- if .Values.useStandardHelmNamingConventions }} +{{- include "..fullname" . }} +{{- else -}} permitio-pdp-secret {{- end -}} +{{- end -}} {{- end }} {{/* diff --git a/charts/pdp/templates/deployment.yaml b/charts/pdp/templates/deployment.yaml index 214cea11..b998f2a7 100644 --- a/charts/pdp/templates/deployment.yaml +++ b/charts/pdp/templates/deployment.yaml @@ -1,7 +1,11 @@ apiVersion: apps/v1 kind: Deployment metadata: + {{- if .Values.useStandardHelmNamingConventions }} + name: {{ include "..fullname" . }} + {{- else }} name: permitio-pdp + {{- end }} labels: {{- include "pdp.labels" . | nindent 4 }} {{- with .Values.annotations }} diff --git a/charts/pdp/templates/logs-forwarder-cm.yaml b/charts/pdp/templates/logs-forwarder-cm.yaml index 7a058653..8ce4cc8a 100644 --- a/charts/pdp/templates/logs-forwarder-cm.yaml +++ b/charts/pdp/templates/logs-forwarder-cm.yaml @@ -2,7 +2,11 @@ apiVersion: v1 kind: ConfigMap metadata: + {{- if .Values.useStandardHelmNamingConventions }} + name: {{ include "..fullname" . }}-fluentbit-config + {{- else }} name: fluentbit-config + {{- end }} {{- with .Values.labels }} labels: {{- toYaml . | nindent 4 }} diff --git a/charts/pdp/templates/poddisruptionbudget.yaml b/charts/pdp/templates/poddisruptionbudget.yaml index 1d107e46..a339c75a 100644 --- a/charts/pdp/templates/poddisruptionbudget.yaml +++ b/charts/pdp/templates/poddisruptionbudget.yaml @@ -2,7 +2,11 @@ apiVersion: policy/v1 kind: PodDisruptionBudget metadata: + {{- if .Values.useStandardHelmNamingConventions }} + name: {{ include "..fullname" . }} + {{- else }} name: permitio-pdp-pdb + {{- end }} labels: {{- include "pdp.labels" . | nindent 4 }} {{- with .Values.annotations }} diff --git a/charts/pdp/templates/service.yaml b/charts/pdp/templates/service.yaml index 3cfc33d6..3d5f3429 100644 --- a/charts/pdp/templates/service.yaml +++ b/charts/pdp/templates/service.yaml @@ -1,7 +1,11 @@ apiVersion: v1 kind: Service metadata: + {{- if .Values.useStandardHelmNamingConventions }} + name: {{ include "..fullname" . }} + {{- else }} name: permitio-pdp + {{- end }} {{- with .Values.labels }} labels: {{- toYaml . | nindent 4 }} diff --git a/charts/pdp/values.yaml b/charts/pdp/values.yaml index 49aebdf7..4ba50f3f 100644 --- a/charts/pdp/values.yaml +++ b/charts/pdp/values.yaml @@ -1,6 +1,25 @@ +# Feature flag added to preserve backward compatibility with the old naming conventions +# When useStandardHelmNamingConventions is false (default): +# - Service name: permitio-pdp +# - Secret name: permitio-pdp-secret +# - Deployment name: permitio-pdp +# - PodDisruptionBudget name: permitio-pdp-pdb +# +# When useStandardHelmNamingConventions is true: +# - Service name: {release-name}-{chart-name} (e.g., my-release-pdp) +# - Secret name: {release-name}-{chart-name} (e.g., my-release-pdp) +# - Deployment name: {release-name}-{chart-name} (e.g., my-release-pdp) +# - PodDisruptionBudget name: {release-name}-{chart-name} (e.g., my-release-pdp) +# +# The standard Helm naming convention follows the pattern {release-name}-{chart-name} +# and automatically truncates names to 63 characters to comply with Kubernetes DNS naming spec. +useStandardHelmNamingConventions: false + labels: {} annotations: {} +nameOverride: "" + pdp: pdpEnvs: [] From 28c34e0ea7d3cc2f29d0aa828520e05ab5980402 Mon Sep 17 00:00:00 2001 From: Alex <1353716+alexstojda@users.noreply.github.com> Date: Thu, 23 Oct 2025 09:28:18 -0400 Subject: [PATCH 2/2] fix: requested changes in #273 --- charts/pdp/templates/_helpers.tpl | 6 +++--- charts/pdp/templates/deployment.yaml | 4 ++-- charts/pdp/templates/logs-forwarder-cm.yaml | 2 +- charts/pdp/templates/poddisruptionbudget.yaml | 2 +- charts/pdp/templates/service.yaml | 2 +- charts/pdp/values.yaml | 5 +++-- 6 files changed, 11 insertions(+), 10 deletions(-) diff --git a/charts/pdp/templates/_helpers.tpl b/charts/pdp/templates/_helpers.tpl index 0c42fae9..17d51d47 100644 --- a/charts/pdp/templates/_helpers.tpl +++ b/charts/pdp/templates/_helpers.tpl @@ -1,7 +1,7 @@ {{/* Expand the name of the chart. */}} -{{- define "..name" -}} +{{- define "pdp.name" -}} {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} {{- end }} @@ -10,7 +10,7 @@ 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 "..fullname" -}} +{{- define "pdp.fullname" -}} {{- if .Values.fullnameOverride }} {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} {{- else }} @@ -48,7 +48,7 @@ Get the secret name for the API key {{- .Values.pdp.existingApiKeySecret.name -}} {{- else -}} {{- if .Values.useStandardHelmNamingConventions }} -{{- include "..fullname" . }} +{{- include "pdp.fullname" . }} {{- else -}} permitio-pdp-secret {{- end -}} diff --git a/charts/pdp/templates/deployment.yaml b/charts/pdp/templates/deployment.yaml index b998f2a7..6fae960d 100644 --- a/charts/pdp/templates/deployment.yaml +++ b/charts/pdp/templates/deployment.yaml @@ -2,7 +2,7 @@ apiVersion: apps/v1 kind: Deployment metadata: {{- if .Values.useStandardHelmNamingConventions }} - name: {{ include "..fullname" . }} + name: {{ include "pdp.fullname" . }} {{- else }} name: permitio-pdp {{- end }} @@ -149,7 +149,7 @@ spec: {{- if .Values.pdp.logs_forwarder.enabled }} - name: fluent-bit-config configMap: - name: fluentbit-config + name: {{ include "pdp.fullname" . }}-fluentbit-config - name: logs emptyDir: {} {{- else if .Values.openshift.enabled }} diff --git a/charts/pdp/templates/logs-forwarder-cm.yaml b/charts/pdp/templates/logs-forwarder-cm.yaml index 8ce4cc8a..3664711e 100644 --- a/charts/pdp/templates/logs-forwarder-cm.yaml +++ b/charts/pdp/templates/logs-forwarder-cm.yaml @@ -3,7 +3,7 @@ apiVersion: v1 kind: ConfigMap metadata: {{- if .Values.useStandardHelmNamingConventions }} - name: {{ include "..fullname" . }}-fluentbit-config + name: {{ include "pdp.fullname" . }}-fluentbit-config {{- else }} name: fluentbit-config {{- end }} diff --git a/charts/pdp/templates/poddisruptionbudget.yaml b/charts/pdp/templates/poddisruptionbudget.yaml index a339c75a..e1cbf4f6 100644 --- a/charts/pdp/templates/poddisruptionbudget.yaml +++ b/charts/pdp/templates/poddisruptionbudget.yaml @@ -3,7 +3,7 @@ apiVersion: policy/v1 kind: PodDisruptionBudget metadata: {{- if .Values.useStandardHelmNamingConventions }} - name: {{ include "..fullname" . }} + name: {{ include "pdp.fullname" . }} {{- else }} name: permitio-pdp-pdb {{- end }} diff --git a/charts/pdp/templates/service.yaml b/charts/pdp/templates/service.yaml index 3d5f3429..ba6b2bba 100644 --- a/charts/pdp/templates/service.yaml +++ b/charts/pdp/templates/service.yaml @@ -2,7 +2,7 @@ apiVersion: v1 kind: Service metadata: {{- if .Values.useStandardHelmNamingConventions }} - name: {{ include "..fullname" . }} + name: {{ include "pdp.fullname" . }} {{- else }} name: permitio-pdp {{- end }} diff --git a/charts/pdp/values.yaml b/charts/pdp/values.yaml index 4ba50f3f..13cf0d45 100644 --- a/charts/pdp/values.yaml +++ b/charts/pdp/values.yaml @@ -19,6 +19,7 @@ labels: {} annotations: {} nameOverride: "" +fullnameOverride: "" pdp: pdpEnvs: @@ -77,11 +78,11 @@ resources: # OpenShift configuration openshift: - enabled: false # Set to true for OpenShift deployments + enabled: false # Set to true for OpenShift deployments serviceAccount: create: true name: "permitio-pdp-sa" - sccName: "restricted-v2" # OpenShift Security Context Constraint + sccName: "restricted-v2" # OpenShift Security Context Constraint # Security context (SCC will override user/group settings automatically) securityContext: runAsNonRoot: true