Skip to content

Commit

Permalink
Merge pull request #35 from gofireflyio/INFL-6097-truncate-resource-n…
Browse files Browse the repository at this point in the history
…ames-for-validation

support passing in release name up to 53 chars
  • Loading branch information
nirfirefly authored Jun 6, 2023
2 parents 7a75026 + 071a4d9 commit b9db0e0
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 15 deletions.
4 changes: 2 additions & 2 deletions charts/chart/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ name: firefly-k8s-collector
home: https://github.com/gofireflyio/k8s-collector
description: Firefly's Kubernetes Collector
type: application
version: 1.4.4
appVersion: "1.4.4"
version: 1.4.5
appVersion: "1.4.5"
34 changes: 33 additions & 1 deletion charts/chart/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,38 @@
{{- if .Values.existingFireFlyCredentialsSecret -}}
{{- printf "%s" .Values.existingFireFlyCredentialsSecret }}
{{- else -}}
{{- printf "%s-credentials" .Release.Name -}}
{{- printf "%s-%s" (.Release.Name | trunc ((sub 63 (len "-credentials")) | int) | trimSuffix "-") "credentials" }}
{{- end -}}
{{- end -}}

{{- define "fireFlyCollectorCrojobName"}}
{{- printf "%s-%s" (.Release.Name | trunc ((sub 52 (len "-cronjob")) | int) | trimSuffix "-") "cronjob" }}
{{- end -}}

{{- define "fireFlyCollectorContaierName"}}
{{- (.Release.Name | trunc 63 | trimSuffix "-") }}
{{- end -}}

{{- define "fireFlyArgocdContainerName"}}
{{- printf "%s-%s" (.Release.Name | trunc ((sub 53 (len "-argocd")) | int) | trimSuffix "-") "argocd" }}
{{- end -}}

{{- define "fireFlyArgoConfigMap"}}
{{- printf "%s-%s" (.Release.Name | trunc ((sub 63 (len "-argocd-config")) | int) | trimSuffix "-") "argocd-config" }}
{{- end -}}

{{- define "fireFlyCollectorConfigMap"}}
{{- printf "%s-%s" (.Release.Name | trunc ((sub 63 (len "-config")) | int) | trimSuffix "-") "config" }}
{{- end -}}

{{- define "fireFlyCollectorOffBoarderJob"}}
{{- printf "%s-%s" (.Release.Name | trunc ((sub 53 (len "-collector-off-boarder")) | int) | trimSuffix "-") "collector-off-boarder" }}
{{- end -}}

{{- define "fireFlyArgocdCredentials" -}}
{{- if .Values.argocd.secretNameOverride -}}
{{- printf "%s" .Values.argocd.secretNameOverride }}
{{- else -}}
{{- printf "%s-%s" (.Release.Name | trunc ((sub 63 (len "-argocd-credentials")) | int) | trimSuffix "-") "argocd-credentials" }}
{{- end -}}
{{- end -}}
4 changes: 2 additions & 2 deletions charts/chart/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Release.Name }}-argocd-config
name: {{ template "fireFlyArgoConfigMap" .}}
data:
"crawler.json": {{ .Values.argocd.metadata | toJson | quote }}
{{- end }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Release.Name }}-config
name: {{ template "fireFlyCollectorConfigMap" .}}
data:
{{ if .Values.apiEndpoint }}
endpoint: {{ quote .Values.apiEndpoint }}
Expand Down
12 changes: 6 additions & 6 deletions charts/chart/templates/cronjob.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ apiVersion: batch/v1beta1
{{- end }}
kind: CronJob
metadata:
name: {{ .Release.Name }}-cronjob
name: {{ template "fireFlyCollectorCrojobName" . }}
spec:
schedule: "{{ .Values.schedule }}"
concurrencyPolicy: "Forbid"
Expand All @@ -17,7 +17,7 @@ spec:
runAsNonRoot: true
serviceAccountName: {{ .Values.serviceAccount.name }}
containers:
- name: {{ .Release.Name }}
- name: {{ template "fireFlyCollectorContaierName" . }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
Expand All @@ -44,7 +44,7 @@ spec:
cpu: {{ .Values.resources.limits.cpu }}
memory: {{ .Values.resources.limits.memory }}
{{ if .Values.argocd.enabled }}
- name: {{ .Release.Name }}-argocd
- name: {{ template "fireFlyArgocdContainerName" . }}
image: "{{ .Values.argocd.image.repository }}:{{ .Values.argocd.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.argocd.image.pullPolicy }}
env:
Expand Down Expand Up @@ -72,7 +72,7 @@ spec:
value: {{ quote .Values.argocd.saveToRemoteBucket}}
envFrom:
- secretRef:
name: {{ .Values.argocd.secretNameOverride | default (printf "%s-argocd-credentials" .Release.Name) }}
name: {{ template "fireFlyArgocdCredentials" .}}
volumeMounts:
- name: argocd-config-volume
mountPath: "{{ .Values.argocd.crawlerLocalPath }}/crawler.json"
Expand All @@ -90,10 +90,10 @@ spec:
volumes:
- name: config-volume
configMap:
name: {{ .Release.Name }}-config
name: {{ template "fireFlyCollectorConfigMap" .}}
{{if .Values.argocd.enabled }}
- name: argocd-config-volume
configMap:
name: {{ .Release.Name }}-argocd-config
name: {{ template "fireFlyArgoConfigMap" .}}
{{ end }}
restartPolicy: OnFailure
4 changes: 2 additions & 2 deletions charts/chart/templates/pre-delete-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ apiVersion: batch/v1beta1
{{- end }}
kind: Job
metadata:
name: "{{ .Release.Name }}-collector-off-boarder"
name: {{ template "fireFlyCollectorOffBoarderJob" . }}
annotations:
# This is what defines this resource as a hook. Without this line, the
# job is considered part of the release.
Expand All @@ -15,7 +15,7 @@ spec:
backoffLimit: 2
template:
metadata:
name: "{{ .Release.Name }}"
name: "off-boarder"
spec:
restartPolicy: OnFailure
containers:
Expand Down
4 changes: 2 additions & 2 deletions charts/chart/templates/secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ .Values.argocd.secretNameOverride | default (printf "%s-argocd-credentials" .Release.Name) }}
name: {{ template "fireFlyArgocdCredentials" .}}
type: Opaque
data:
IACATHON_ARGOCD_TOKEN: {{ .Values.argocd.token | b64enc }}
Expand All @@ -12,7 +12,7 @@ data:
apiVersion: v1
kind: Secret
metadata:
name: {{ .Release.Name }}-credentials
name: {{ template "fireFlyCredentialsSecret" .}}
type: Opaque
data:
accessKey: {{ .Values.accessKey | b64enc }}
Expand Down

0 comments on commit b9db0e0

Please sign in to comment.