|
| 1 | +{{/* |
| 2 | +fluffy resource full name |
| 3 | +*/}} |
| 4 | +{{- define "fluffy.fullname" -}} |
| 5 | +{{- $name := include "lakefs.fullname" . }} |
| 6 | +{{- printf "%s-fluffy" $name | trunc 63 }} |
| 7 | +{{- end }} |
| 8 | + |
| 9 | +{{/* |
| 10 | +Common labels |
| 11 | +*/}} |
| 12 | +{{- define "fluffy.labels" -}} |
| 13 | +helm.sh/chart: {{ include "lakefs.chart" . }} |
| 14 | +{{ include "fluffy.selectorLabels" . }} |
| 15 | +{{- if .Chart.AppVersion }} |
| 16 | +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} |
| 17 | +{{- end }} |
| 18 | +app.kubernetes.io/managed-by: {{ .Release.Service }} |
| 19 | +{{- end }} |
| 20 | + |
| 21 | +{{/* |
| 22 | +Selector labels |
| 23 | +*/}} |
| 24 | +{{- define "fluffy.selectorLabels" -}} |
| 25 | +app.kubernetes.io/name: {{ include "lakefs.name" . }}-fluffy |
| 26 | +app.kubernetes.io/instance: {{ .Release.Name }} |
| 27 | +{{- end }} |
| 28 | + |
| 29 | +{{/* |
| 30 | +Create the name of the service account to use |
| 31 | +*/}} |
| 32 | +{{- define "fluffy.serviceAccountName" -}} |
| 33 | +{{- $lakeFSAcc := include "lakefs.serviceAccountName" . }} |
| 34 | +{{- default $lakeFSAcc .Values.fluffy.serviceAccountName }} |
| 35 | +{{- end }} |
| 36 | + |
| 37 | +{{/* |
| 38 | +fluffy SSO service name |
| 39 | +*/}} |
| 40 | +{{- define "fluffy.ssoServiceName" -}} |
| 41 | +{{- printf "fluffy-sso" }} |
| 42 | +{{- end }} |
| 43 | + |
| 44 | +{{/* |
| 45 | +fluffy Authorization service name |
| 46 | +*/}} |
| 47 | +{{- define "fluffy.rbacServiceName" -}} |
| 48 | +{{- printf "fluffy-rbac" }} |
| 49 | +{{- end }} |
| 50 | + |
| 51 | + |
| 52 | +{{/* |
| 53 | +Fluffy environment variables |
| 54 | +*/}} |
| 55 | + |
| 56 | +{{- define "fluffy.env" -}} |
| 57 | +env: |
| 58 | + {{- if (.Values.fluffy.sso).enabled }} |
| 59 | + {{- if and .Values.ingress.enabled (.Values.fluffy.sso.saml).enabled }} |
| 60 | + - name: FLUFFY_AUTH_SAML_ENABLED |
| 61 | + value: "true" |
| 62 | + - name: FLUFFY_AUTH_LOGOUT_REDIRECT_URL |
| 63 | + value: {{ .Values.fluffy.sso.saml.lakeFSServiceProviderIngress }} |
| 64 | + - name: FLUFFY_AUTH_POST_LOGIN_REDIRECT_URL |
| 65 | + value: {{ .Values.fluffy.sso.saml.lakeFSServiceProviderIngress }} |
| 66 | + - name: FLUFFY_AUTH_SAML_SP_ROOT_URL |
| 67 | + value: {{ .Values.fluffy.sso.saml.lakeFSServiceProviderIngress }} |
| 68 | + - name: FLUFFY_AUTH_SAML_SP_X509_KEY_PATH |
| 69 | + value: '/etc/saml_certs/rsa_saml_private.key' |
| 70 | + - name: FLUFFY_AUTH_SAML_SP_X509_CERT_PATH |
| 71 | + value: '/etc/saml_certs/rsa_saml_public.pem' |
| 72 | + {{- end }} |
| 73 | + {{- if (.Values.fluffy.sso.oidc).enabled }} |
| 74 | + - name: FLUFFY_AUTH_POST_LOGIN_REDIRECT_URL |
| 75 | + value: '/' |
| 76 | + {{- if (.Values.fluffy.sso.oidc).client_secret }} |
| 77 | + - name: FLUFFY_AUTH_OIDC_CLIENT_SECRET |
| 78 | + valueFrom: |
| 79 | + secretKeyRef: |
| 80 | + name: {{ include "fluffy.fullname" . }} |
| 81 | + key: oidc_client_secret |
| 82 | + {{- end }} |
| 83 | + {{- end }} |
| 84 | + {{- if (.Values.fluffy.sso.ldap).enabled }} |
| 85 | + - name: FLUFFY_AUTH_LDAP_BIND_PASSWORD |
| 86 | + valueFrom: |
| 87 | + secretKeyRef: |
| 88 | + name: {{ include "fluffy.fullname" . }} |
| 89 | + key: ldap_bind_password |
| 90 | + {{- end }} |
| 91 | + {{- end }} |
| 92 | + {{- if .Values.existingSecret }} |
| 93 | + - name: FLUFFY_AUTH_ENCRYPT_SECRET_KEY |
| 94 | + valueFrom: |
| 95 | + secretKeyRef: |
| 96 | + name: {{ .Values.existingSecret }} |
| 97 | + key: {{ .Values.secretKeys.authEncryptSecretKey }} |
| 98 | + {{- else if and .Values.secrets (.Values.secrets).authEncryptSecretKey }} |
| 99 | + - name: FLUFFY_AUTH_ENCRYPT_SECRET_KEY |
| 100 | + valueFrom: |
| 101 | + secretKeyRef: |
| 102 | + name: {{ include "lakefs.fullname" . }} |
| 103 | + key: auth_encrypt_secret_key |
| 104 | + {{- else }} |
| 105 | + - name: FLUFFY_AUTH_ENCRYPT_SECRET_KEY |
| 106 | + value: asdjfhjaskdhuioaweyuiorasdsjbaskcbkj |
| 107 | + {{- end }} |
| 108 | + {{- if and (.Values.fluffy.rbac).enabled }} |
| 109 | + - name: FLUFFY_AUTH_SERVE_LISTEN_ADDRESS |
| 110 | + value: {{ printf ":%s" (include "fluffy.rbac.containerPort" .) }} |
| 111 | + {{- end }} |
| 112 | + {{- if and .Values.existingSecret .Values.secretKeys.databaseConnectionString }} |
| 113 | + - name: FLUFFY_DATABASE_POSTGRES_CONNECTION_STRING |
| 114 | + valueFrom: |
| 115 | + secretKeyRef: |
| 116 | + name: {{ .Values.existingSecret }} |
| 117 | + key: {{ .Values.secretKeys.databaseConnectionString }} |
| 118 | + {{- else if and .Values.secrets (.Values.secrets).databaseConnectionString }} |
| 119 | + - name: FLUFFY_DATABASE_POSTGRES_CONNECTION_STRING |
| 120 | + valueFrom: |
| 121 | + secretKeyRef: |
| 122 | + name: {{ include "lakefs.fullname" . }} |
| 123 | + key: database_connection_string |
| 124 | + {{- else if and .Values.useDevPostgres (.Values.fluffy.rbac).enabled }} |
| 125 | + - name: FLUFFY_DATABASE_TYPE |
| 126 | + value: postgres |
| 127 | + - name: FLUFFY_DATABASE_POSTGRES_CONNECTION_STRING |
| 128 | + value: 'postgres://lakefs:lakefs@postgres-server:5432/postgres?sslmode=disable' |
| 129 | + {{- end }} |
| 130 | + {{- if .Values.fluffy.extraEnvVars }} |
| 131 | + {{- toYaml .Values.fluffy.extraEnvVars | nindent 2 }} |
| 132 | + {{- end }} |
| 133 | +{{- if .Values.fluffy.extraEnvVarsSecret }} |
| 134 | +envFrom: |
| 135 | + - secretRef: |
| 136 | + name: {{ .Values.fluffy.extraEnvVarsSecret }} |
| 137 | +{{- end }} |
| 138 | +{{- end }} |
| 139 | + |
| 140 | +{{- define "fluffy.volumes" -}} |
| 141 | +{{- if .Values.fluffy.extraVolumes }} |
| 142 | +{{ toYaml .Values.fluffy.extraVolumes }} |
| 143 | +{{- end }} |
| 144 | +{{- if not .Values.fluffy.fluffyConfig }} |
| 145 | +- name: {{ .Chart.Name }}-local-data |
| 146 | +{{- end}} |
| 147 | +{{- if (.Values.fluffy.sso.saml).enabled }} |
| 148 | +- name: secret-volume |
| 149 | + secret: |
| 150 | + secretName: saml-certificates |
| 151 | +{{- end }} |
| 152 | +{{- if .Values.fluffy.fluffyConfig }} |
| 153 | +- name: {{ include "fluffy.fullname" . }}-config |
| 154 | + configMap: |
| 155 | + name: {{ include "fluffy.fullname" . }}-config |
| 156 | + items: |
| 157 | + - key: config.yaml |
| 158 | + path: config.yaml |
| 159 | +{{- end }} |
| 160 | +{{- end }} |
| 161 | + |
| 162 | +{{- define "fluffy.ingressOverrides" -}} |
| 163 | +{{- $serviceName := include "fluffy.ssoServiceName" . -}} |
| 164 | +{{- $gitVersion := .Capabilities.KubeVersion.GitVersion -}} |
| 165 | +{{- $pathsOverrides := list "/oidc/" "/api/v1/oidc/" "/saml/" "/sso/" "/api/v1/ldap/" }} |
| 166 | +{{- range $pathsOverrides }} |
| 167 | +- path: {{ . }} |
| 168 | +{{- if semverCompare ">=1.19-0" $gitVersion }} |
| 169 | + pathType: Prefix |
| 170 | + backend: |
| 171 | + service: |
| 172 | + name: {{ $serviceName }} |
| 173 | + port: |
| 174 | + number: 80 |
| 175 | +{{- else }} |
| 176 | + backend: |
| 177 | + serviceName: {{ $serviceName }} |
| 178 | + servicePort: 80 |
| 179 | +{{- end }} |
| 180 | +{{- end }} |
| 181 | +{{- end }} |
| 182 | + |
| 183 | +{{- define "fluffy.dockerConfigJson" }} |
| 184 | +{{- $token := .Values.fluffy.image.privateRegistry.secretToken }} |
| 185 | +{{- $username := "externallakefs" }} |
| 186 | +{{- $registry := "https://index.docker.io/v1/" }} |
| 187 | +{{- printf "{\"auths\":{\"%s\":{\"username\":\"%s\",\"password\":\"%s\",\"auth\":\"%s\"}}}" $registry $username $token (printf "%s:%s" $username $token | b64enc) | b64enc }} |
| 188 | +{{- end }} |
| 189 | + |
| 190 | +{{- define "fluffy.sso.serviceType" }} |
| 191 | +{{- default "ClusterIP" (.Values.fluffy.sso.service).type }} |
| 192 | +{{- end }} |
| 193 | +{{- define "fluffy.rbac.serviceType" }} |
| 194 | +{{- default "ClusterIP" (.Values.fluffy.rbac.service).type }} |
| 195 | +{{- end }} |
| 196 | + |
| 197 | +{{- define "fluffy.sso.port" }} |
| 198 | +{{- default 80 (.Values.fluffy.sso.service).port }} |
| 199 | +{{- end }} |
| 200 | +{{- define "fluffy.rbac.port" }} |
| 201 | +{{- default 80 (.Values.fluffy.rbac.service).port }} |
| 202 | +{{- end }} |
| 203 | + |
| 204 | +{{- define "fluffy.sso.containerPort" }} |
| 205 | +{{- default 8000 (.Values.fluffy.sso.service).containerPort }} |
| 206 | +{{- end }} |
| 207 | +{{- define "fluffy.rbac.containerPort" }} |
| 208 | +{{- default 9000 (.Values.fluffy.rbac.service).containerPort }} |
| 209 | +{{- end }} |
0 commit comments