{{- if .Values.redis.enabled }} {{- $ns := include "sebastian.namespace" . -}} {{- $existing := (lookup "v1" "Service" $ns "redis") -}} {{- $annotations := dict -}} {{- if and $existing $existing.metadata $existing.metadata.annotations -}} {{- $annotations = $existing.metadata.annotations -}} {{- end -}} {{- $owned := and $existing (eq (get $annotations "meta.helm.sh/release-name") .Release.Name) -}} {{- if or (not $existing) $owned }} apiVersion: v1 kind: Service metadata: labels: app: redis name: redis namespace: {{ include "sebastian.namespace" . }} annotations: "helm.sh/resource-policy": keep spec: clusterIP: None ports: - port: {{ .Values.redis.service.port }} selector: app: redis {{- end }} {{- end }}