diff --git a/charts/pdp/templates/_helpers.tpl b/charts/pdp/templates/_helpers.tpl index b65ae0ce..17d51d47 100644 --- a/charts/pdp/templates/_helpers.tpl +++ b/charts/pdp/templates/_helpers.tpl @@ -1,3 +1,28 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "pdp.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 "pdp.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 "pdp.fullname" . }} +{{- else -}} permitio-pdp-secret {{- end -}} +{{- end -}} {{- end }} {{/* diff --git a/charts/pdp/templates/deployment.yaml b/charts/pdp/templates/deployment.yaml index 214cea11..6fae960d 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 "pdp.fullname" . }} + {{- else }} name: permitio-pdp + {{- end }} labels: {{- include "pdp.labels" . | nindent 4 }} {{- with .Values.annotations }} @@ -145,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 7a058653..3664711e 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 "pdp.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..e1cbf4f6 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 "pdp.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..ba6b2bba 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 "pdp.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..13cf0d45 100644 --- a/charts/pdp/values.yaml +++ b/charts/pdp/values.yaml @@ -1,6 +1,26 @@ +# 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: "" +fullnameOverride: "" + pdp: pdpEnvs: [] @@ -58,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