Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Experiment] helm lint --strict compliance - not fully there #1681

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions jupyterhub/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@
{{ .Values.nameOverride | default .Chart.Name | trunc 63 | trimSuffix "-" }}
{{- end }}


{{- /*
jupyterhub.componentLabel:
Used by "jupyterhub.labels" and "jupyterhub.nameField".
Expand All @@ -105,8 +104,8 @@
{{- define "jupyterhub.componentLabel" -}}
{{- $file := .Template.Name | base | trimSuffix ".yaml" -}}
{{- $parent := .Template.Name | dir | base | trimPrefix "templates" -}}
{{- $component := .componentLabel | default $parent | default $file -}}
{{- $component := print (.componentPrefix | default "") $component (.componentSuffix | default "") -}}
{{- $component := .Values.componentLabel | default $parent | default $file -}}
{{- $component := print .Values.componentPrefix $component .Values.componentSuffix -}}
{{ $component }}
{{- end }}

Expand All @@ -122,7 +121,7 @@
.Values to allow for multiple deployments within a single namespace.
*/}}
{{- define "jupyterhub.nameField" -}}
{{- $name := print (.namePrefix | default "") (include "jupyterhub.componentLabel" .) (.nameSuffix | default "") -}}
{{- $name := print .Values.namePrefix (include "jupyterhub.componentLabel" .) .Values.nameSuffix -}}
{{ printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}

Expand All @@ -133,11 +132,11 @@
Provides labels: app, release, (chart and heritage).
*/}}
{{- define "jupyterhub.commonLabels" -}}
app: {{ .appLabel | default (include "jupyterhub.appLabel" .) }}
app: {{ .Values.appLabel | default (include "jupyterhub.appLabel" .) }}
release: {{ .Release.Name }}
{{- if not .matchLabels }}
{{- if not .Values.matchLabels }}
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
heritage: {{ .heritageLabel | default .Release.Service }}
heritage: {{ .Values.heritageLabel | default .Release.Service }}
{{- end }}
{{- end }}

Expand All @@ -157,7 +156,7 @@ component: {{ include "jupyterhub.componentLabel" . }}
Used to provide pod selection labels: component, app, release.
*/}}
{{- define "jupyterhub.matchLabels" -}}
{{- $_ := merge (dict "matchLabels" true) . -}}
{{- $_ := merge (dict "Values" (dict "matchLabels" true)) . -}}
{{ include "jupyterhub.labels" $_ }}
{{- end }}

Expand Down
36 changes: 6 additions & 30 deletions jupyterhub/templates/hub/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,7 @@ spec:
name: hub-config
- name: secret
secret:
{{- if .Values.hub.existingSecret }}
secretName: {{ .Values.hub.existingSecret }}
{{- else }}
secretName: hub-secret
{{- end }}
secretName: {{ .Values.hub.existingSecret | default "hub-secret" }}
{{- if .Values.hub.extraVolumes }}
{{- .Values.hub.extraVolumes | toYaml | trimSuffix "\n" | nindent 8 }}
{{- end }}
Expand Down Expand Up @@ -145,11 +141,7 @@ spec:
- name: JPY_COOKIE_SECRET
valueFrom:
secretKeyRef:
{{- if .Values.hub.existingSecret }}
name: {{ .Values.hub.existingSecret }}
{{- else }}
name: hub-secret
{{- end }}
name: {{ .Values.hub.existingSecret | default "hub-secret" }}
key: hub.cookie-secret
{{- end }}
- name: POD_NAMESPACE
Expand All @@ -159,43 +151,27 @@ spec:
- name: CONFIGPROXY_AUTH_TOKEN
valueFrom:
secretKeyRef:
{{- if .Values.hub.existingSecret }}
name: {{ .Values.hub.existingSecret }}
{{- else }}
name: hub-secret
{{- end }}
name: {{ .Values.hub.existingSecret | default "hub-secret" }}
key: proxy.token
{{- if .Values.auth.state.enabled }}
- name: JUPYTERHUB_CRYPT_KEY
valueFrom:
secretKeyRef:
{{- if .Values.hub.existingSecret }}
name: {{ .Values.hub.existingSecret }}
{{- else }}
name: hub-secret
{{- end }}
name: {{ .Values.hub.existingSecret | default "hub-secret" }}
key: auth.state.crypto-key
{{- end }}
{{- if .Values.hub.db.password }}
{{- if eq .Values.hub.db.type "mysql" }}
- name: MYSQL_PWD
valueFrom:
secretKeyRef:
{{- if .Values.hub.existingSecret }}
name: {{ .Values.hub.existingSecret }}
{{- else }}
name: hub-secret
{{- end }}
name: {{ .Values.hub.existingSecret | default "hub-secret" }}
key: hub.db.password
{{- else if eq .Values.hub.db.type "postgres" }}
- name: PGPASSWORD
valueFrom:
secretKeyRef:
{{- if .Values.hub.existingSecret }}
name: {{ .Values.hub.existingSecret }}
{{- else }}
name: hub-secret
{{- end }}
name: {{ .Values.hub.existingSecret | default "hub-secret" }}
key: hub.db.password
{{- end }}
{{- end }}
Expand Down
2 changes: 1 addition & 1 deletion jupyterhub/templates/hub/image-credentials-secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ apiVersion: v1
metadata:
name: hub-image-credentials
labels:
{{- $_ := merge (dict "componentSuffix" "-image-credentials") . }}
{{- $_ := merge (dict "Values" (dict "componentSuffix" "-image-credentials")) . }}
{{- include "jupyterhub.labels" $_ | nindent 4 }}
type: kubernetes.io/dockerconfigjson
data:
Expand Down
4 changes: 2 additions & 2 deletions jupyterhub/templates/hub/netpol.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ spec:
to:
- podSelector:
matchLabels:
{{- $_ := merge (dict "componentLabel" "proxy") . }}
{{- $_ := merge (dict "Values" (dict "componentLabel" "proxy")) . }}
{{- include "jupyterhub.matchLabels" $_ | nindent 14 }}
# hub --> singleuser-server
- ports:
- port: 8888
to:
- podSelector:
matchLabels:
{{- $_ := merge (dict "componentLabel" "singleuser-server") . }}
{{- $_ := merge (dict "Values" (dict "componentLabel" "singleuser-server")) . }}
{{- include "jupyterhub.matchLabels" $_ | nindent 14 }}

# hub -> Kubernetes internal DNS
Expand Down
4 changes: 2 additions & 2 deletions jupyterhub/templates/hub/secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ data:
{{- if .Values.hub.cookieSecret }}
hub.cookie-secret: {{ .Values.hub.cookieSecret | b64enc | quote }}
{{- end }}
{{- if .Values.hub.db.password }}
{{- with .Values.hub.db.password }}
hub.db.password: {{ .Values.hub.db.password | b64enc | quote }}
{{- end }}
{{- if .Values.auth.state.enabled }}
auth.state.crypto-key: {{ (required "Encryption key is required for auth state to be persisted!" .Values.auth.state.cryptoKey) | b64enc | quote }}
auth.state.crypto-key: {{ .Values.auth.state.cryptoKey | required "Encryption key is required for auth state to be persisted!" | b64enc | quote }}
{{- end }}
{{- $values := dict "hub" dict }}
{{- /* pluck only needed secret values, preserving values.yaml structure */ -}}
Expand Down
12 changes: 6 additions & 6 deletions jupyterhub/templates/hub/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ metadata:
{{- if not (index .Values.hub.service.annotations "prometheus.io/path") }}
prometheus.io/path: {{ .Values.hub.baseUrl }}hub/metrics
{{- end }}
{{- if .Values.hub.service.annotations }}
{{- .Values.hub.service.annotations | toYaml | nindent 4 }}
{{- with .Values.hub.service.annotations }}
{{- . | toYaml | nindent 4 }}
{{- end }}
spec:
type: {{ .Values.hub.service.type }}
{{- if .Values.hub.service.loadBalancerIP }}
loadBalancerIP: {{ .Values.hub.service.loadBalancerIP }}
{{- with .Values.hub.service.loadBalancerIP }}
loadBalancerIP: {{ . }}
{{- end }}
selector:
{{- include "jupyterhub.matchLabels" . | nindent 4 }}
ports:
- port: 8081
targetPort: http
{{- if .Values.hub.service.ports.nodePort }}
nodePort: {{ .Values.hub.service.ports.nodePort }}
{{- with .Values.hub.service.ports.nodePort }}
nodePort: {{ . }}
{{- end }}
8 changes: 4 additions & 4 deletions jupyterhub/templates/image-puller/_daemonset-helper.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ Returns an image-puller daemonset. Two daemonsets will be created like this.
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: {{ print .componentPrefix "image-puller" }}
name: {{ print .Values.componentPrefix "image-puller" }}
labels:
{{- include "jupyterhub.labels" . | nindent 4 }}
{{- if .hook }}
{{- if .Values.hook }}
hub.jupyter.org/deletable: "true"
{{- end }}
{{- if .hook }}
{{- if .Values.hook }}
annotations:
{{- /*
Allows the daemonset to be deleted when the image-awaiter job is completed.
Expand Down Expand Up @@ -51,7 +51,7 @@ spec:
{{- if or .Values.singleuser.imagePullSecret.enabled .Values.singleuser.image.pullSecrets }}
imagePullSecrets:
{{- if .Values.singleuser.imagePullSecret.enabled }}
- name: {{ if .hook -}} hook- {{- end -}} singleuser-image-credentials
- name: {{ if .Values.hook -}} hook- {{- end -}} singleuser-image-credentials
{{ else }}
{{- range .Values.singleuser.image.pullSecrets }}
- name: {{ . }}
Expand Down
4 changes: 2 additions & 2 deletions jupyterhub/templates/image-puller/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ image-awaiter job confirms the required images to be pulled, the daemonset is
deleted. Only then will the actual helm upgrade start.
*/}}
{{- if .Values.prePuller.hook.enabled }}
{{- $_ := merge (dict "hook" true "componentPrefix" "hook-") . }}
{{- $_ := merge (dict "Values" (dict "hook" true "componentPrefix" "hook-")) . }}
{{- include "jupyterhub.imagePuller.daemonset" $_ }}
{{- end }}
---
Expand All @@ -15,6 +15,6 @@ that are added in between helm upgrades, for example by manually adding a node
or by the cluster autoscaler.
*/}}
{{- if .Values.prePuller.continuous.enabled }}
{{- $_ := merge (dict "hook" false "componentPrefix" "continuous-") . }}
{{- $_ := merge (dict "Values" (dict "hook" false "componentPrefix" "continuous-")) . }}
{{ include "jupyterhub.imagePuller.daemonset" $_ }}
{{- end }}
2 changes: 1 addition & 1 deletion jupyterhub/templates/proxy/autohttps/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ metadata:
spec:
type: ClusterIP
selector:
{{- $_ := merge (dict "componentLabel" "proxy") . }}
{{- $_ := merge (dict "Values" (dict "componentLabel" "proxy")) . }}
{{- include "jupyterhub.matchLabels" $_ | nindent 4 }}
ports:
- port: 8000
Expand Down
6 changes: 1 addition & 5 deletions jupyterhub/templates/proxy/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,7 @@ spec:
- name: CONFIGPROXY_AUTH_TOKEN
valueFrom:
secretKeyRef:
{{- if .Values.hub.existingSecret }}
name: {{ .Values.hub.existingSecret }}
{{- else }}
name: hub-secret
{{- end }}
name: {{ .Values.hub.existingSecret | default "hub-secret" }}
key: proxy.token
{{- with .Values.proxy.chp.image.pullPolicy }}
imagePullPolicy: {{ . }}
Expand Down
4 changes: 2 additions & 2 deletions jupyterhub/templates/proxy/netpol.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ spec:
to:
- podSelector:
matchLabels:
{{- $_ := merge (dict "componentLabel" "hub") . }}
{{- $_ := merge (dict "Values" (dict "componentLabel" "hub")) . }}
{{- include "jupyterhub.matchLabels" $_ | nindent 14 }}

# proxy --> singleuser-server
Expand All @@ -58,7 +58,7 @@ spec:
to:
- podSelector:
matchLabels:
{{- $_ := merge (dict "componentLabel" "singleuser-server") . }}
{{- $_ := merge (dict "Values" (dict "componentLabel" "singleuser-server")) . }}
{{- include "jupyterhub.matchLabels" $_ | nindent 14 }}

# proxy -> Kubernetes internal DNS
Expand Down
4 changes: 2 additions & 2 deletions jupyterhub/templates/proxy/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ kind: Service
metadata:
name: proxy-api
labels:
{{- $_ := merge (dict "componentSuffix" "-api") . }}
{{- $_ := merge (dict "Values" (dict "componentSuffix" "-api")) . }}
{{- include "jupyterhub.labels" $_ | nindent 4 }}
spec:
selector:
Expand All @@ -22,7 +22,7 @@ kind: Service
metadata:
name: proxy-public
labels:
{{- $_ := merge (dict "componentSuffix" "-public") . }}
{{- $_ := merge (dict "Values" (dict "componentSuffix" "-public")) . }}
{{- include "jupyterhub.labels" $_ | nindent 4 }}
{{- if .Values.proxy.service.labels }}
{{- .Values.proxy.service.labels | toYaml | trimSuffix "\n" | nindent 4 }}
Expand Down
2 changes: 1 addition & 1 deletion jupyterhub/templates/scheduling/priorityclass.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ kind: PriorityClass
metadata:
name: {{ .Release.Name }}-default-priority
labels:
{{- $_ := merge (dict "componentLabel" "default-priority") . }}
{{- $_ := merge (dict "Values" (dict "componentLabel" "default-priority")) . }}
{{- include "jupyterhub.labels" $_ | nindent 4 }}
annotations:
# PriorityClasses must be added before the other resources reference them.
Expand Down
6 changes: 3 additions & 3 deletions jupyterhub/templates/scheduling/user-scheduler/rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: {{ .Release.Name }}-user-scheduler-base
labels:
{{- $_ := merge (dict "componentSuffix" "-base") . }}
{{- $_ := merge (dict "Values" (dict "componentSuffix" "-base")) . }}
{{- include "jupyterhub.labels" $_ | nindent 4 }}
subjects:
- kind: ServiceAccount
Expand All @@ -28,7 +28,7 @@ apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: {{ .Release.Name }}-user-scheduler-complementary
labels:
{{- $_ := merge (dict "componentSuffix" "-complementary") . }}
{{- $_ := merge (dict "Values" (dict "componentSuffix" "-complementary")) . }}
{{- include "jupyterhub.labels" $_ | nindent 4 }}
rules:
# Support leader elections
Expand All @@ -50,7 +50,7 @@ apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: {{ .Release.Name }}-user-scheduler-complementary
labels:
{{- $_ := merge (dict "componentSuffix" "-complementary") . }}
{{- $_ := merge (dict "Values" (dict "componentSuffix" "-complementary")) . }}
{{- include "jupyterhub.labels" $_ | nindent 4 }}
subjects:
- kind: ServiceAccount
Expand Down
4 changes: 2 additions & 2 deletions jupyterhub/templates/singleuser/image-credentials-secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ apiVersion: v1
metadata:
name: singleuser-image-credentials
labels:
{{- $_ := merge (dict "componentSuffix" "-image-credentials") . }}
{{- $_ := merge (dict "Values" (dict "componentSuffix" "-image-credentials")) . }}
{{- include "jupyterhub.labels" $_ | nindent 4 }}
type: kubernetes.io/dockerconfigjson
data:
Expand All @@ -16,7 +16,7 @@ apiVersion: v1
metadata:
name: hook-singleuser-image-credentials
labels:
{{- $_ := merge (dict "componentPrefix" "hook-" "componentSuffix" "-image-credentials") . }}
{{- $_ := merge (dict "Values" (dict "componentPrefix" "hook-" "componentSuffix" "-image-credentials")) . }}
{{- include "jupyterhub.labels" $_ | nindent 4 }}
hub.jupyter.org/deletable: "true"
annotations:
Expand Down
4 changes: 2 additions & 2 deletions jupyterhub/templates/singleuser/netpol.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ metadata:
spec:
podSelector:
matchLabels:
{{- $_ := merge (dict "componentLabel" "singleuser-server") . }}
{{- $_ := merge (dict "Values" (dict "componentLabel" "singleuser-server")) . }}
{{- include "jupyterhub.matchLabels" $_ | nindent 6 }}
policyTypes:
- Ingress
Expand All @@ -35,7 +35,7 @@ spec:
to:
- podSelector:
matchLabels:
{{- $_ := merge (dict "componentLabel" "hub") . }}
{{- $_ := merge (dict "Values" (dict "componentLabel" "hub")) . }}
{{- include "jupyterhub.matchLabels" $_ | nindent 14 }}

# singleuser-server -> Kubernetes internal DNS
Expand Down
Loading