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

support kubernetes recommended labels #298

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
6 changes: 6 additions & 0 deletions dask/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ The following table lists the configurable parameters of the Dask chart and thei
| Parameter | Description | Default |
| ------------------------ | ----------------------- | -------------- |
| `scheduler.name` | Dask scheduler name. | `"scheduler"` |
| `scheduler.component` | | `"scheduler"` |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious why these component options are configurable? What use cases do you see for changing them?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, mainly because the value 'scheduler/worker/jupyter' is too generic :-) Think of making dask a part of large system, there might be existing deployments using one of these component value already. In that case, people might prefer to change it into something like 'dask-scheduler' instead.
my $0.02

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough. I'm just on guard for config creep, especially for things that wont get used much. I haven't seen a need for this.

If you think this will come up for folks and isn't just a "what if" then I'm happy for it to go in.

| `scheduler.enabled` | Enable/disable scheduler. | `true` |
| `scheduler.image.repository` | Container image repository. | `"ghcr.io/dask/dask"` |
| `scheduler.image.tag` | Container image tag. | `"2022.6.1"` |
Expand All @@ -72,6 +73,7 @@ The following table lists the configurable parameters of the Dask chart and thei
| `scheduler.serviceAnnotations` | Scheduler service annotations. | `{}` |
| `scheduler.extraArgs` | | `[]` |
| `scheduler.resources` | Scheduler pod resources. See `values.yaml` for example values. | `{}` |
| `scheduler.annotations` | Annotations | `{}` |
| `scheduler.tolerations` | Tolerations. | `[]` |
| `scheduler.affinity` | Container affinity. | `{}` |
| `scheduler.nodeSelector` | Node Selector. | `{}` |
Expand All @@ -93,6 +95,7 @@ The following table lists the configurable parameters of the Dask chart and thei
| `webUI.ingress.hostname` | Ingress hostname. | `"dask-ui.example.com"` |
| `webUI.ingress.annotations` | | `{}` |
| `worker.name` | Dask worker name. | `"worker"` |
| `worker.component` | | `"worker"` |
| `worker.image.repository` | Container image repository. | `"ghcr.io/dask/dask"` |
| `worker.image.tag` | Container image tag. | `"2022.6.1"` |
| `worker.image.pullPolicy` | Container image pull policy. | `"IfNotPresent"` |
Expand Down Expand Up @@ -124,6 +127,7 @@ The following table lists the configurable parameters of the Dask chart and thei
| `worker.metrics.podMonitor.metricRelabelings` | MetricRelabelConfigs to apply to samples before ingestion. | `[]` |
| `additional_worker_groups` | Additional groups of workers to create. List of groups with same options as `worker`. | `[]` |
| `jupyter.name` | Jupyter name. | `"jupyter"` |
| `jupyter.component` | | `"jupyter"` |
| `jupyter.enabled` | Enable/disable the bundled Jupyter notebook. | `true` |
| `jupyter.rbac` | Create RBAC service account and role to allow Jupyter pod to scale worker pods and access logs. | `true` |
| `jupyter.image.repository` | Container image repository. | `"ghcr.io/dask/dask-notebook"` |
Expand All @@ -140,6 +144,7 @@ The following table lists the configurable parameters of the Dask chart and thei
| `jupyter.extraConfig` | | `"# Extra Jupyter config goes here\n# E.g\n# c.NotebookApp.port = 8888"` |
| `jupyter.resources` | Jupyter pod resources. See `values.yaml` for example values. | `{}` |
| `jupyter.mounts` | Worker Pod volumes and volume mounts, mounts.volumes follows kuberentes api v1 Volumes spec. mounts.volumeMounts follows kubernetesapi v1 VolumeMount spec | `{}` |
| `jupyter.annotations` | Annotations | `{}` |
| `jupyter.tolerations` | Tolerations. | `[]` |
| `jupyter.affinity` | Container affinity. | `{}` |
| `jupyter.nodeSelector` | Node Selector. | `{}` |
Expand All @@ -150,6 +155,7 @@ The following table lists the configurable parameters of the Dask chart and thei
| `jupyter.ingress.pathType` | set pathType in ingress | `"Prefix"` |
| `jupyter.ingress.hostname` | Ingress hostname. | `"dask-jupyter.example.com"` |
| `jupyter.ingress.annotations` | | `{}` |
| `label.style` | helm|kubernetes | `"helm"` |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this.


#### Jupyter Password

Expand Down
47 changes: 47 additions & 0 deletions dask/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,50 @@ Create chart name and version as used by the chart label.
{{- define "dask.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Common labels
*/}}
{{- define "dask.labels" -}}
{{- $ := index . 1 }}
{{- with index . 0 }}
{{- if eq "kubernetes" $.Values.label.style }}
helm.sh/chart: {{ include "dask.chart" $ }}
{{- else }}
chart: {{ include "dask.chart" $ }}
{{- end }}
{{- include "dask.selectorLabels" (list . $) }}
{{- if $.Chart.AppVersion }}
{{- if eq "kubernetes" $.Values.label.style }}
app.kubernetes.io/version: {{ $.Chart.AppVersion | quote }}
{{- else }}
version: {{ $.Chart.AppVersion | quote }}
{{- end }}
{{- end }}
{{- if eq "kubernetes" $.Values.label.style }}
app.kubernetes.io/part-of: {{ include "dask.fullname" $ }}
app.kubernetes.io/managed-by: {{ $.Release.Service }}
app.kubernetes.io/created-by: {{ include "dask.chart" $ }}
{{- else }}
heritage: {{ $.Release.Service }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "dask.selectorLabels" -}}
{{- $ := index . 1 }}
{{- with index . 0 }}
{{- if eq "kubernetes" $.Values.label.style }}
app.kubernetes.io/name: {{ include "dask.name" $ }}-{{ .name }}
app.kubernetes.io/instance: {{ include "dask.name" $ }}-{{ .name }}
app.kubernetes.io/component: {{ .component }}
{{- else }}
app: {{ include "dask.name" $ }}
release: {{ $.Release.Name | quote }}
component: {{ .component }}
{{- end }}
{{- end }}
{{- end }}
14 changes: 3 additions & 11 deletions dask/templates/additional-worker-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,18 @@ kind: Deployment
metadata:
name: {{ template "dask.fullname" $ }}-worker-{{ $worker.name }}
labels:
app: {{ template "dask.name" $ }}
heritage: {{ $.Release.Service | quote }}
release: {{ $.Release.Name | quote }}
chart: {{ template "dask.chart" $ }}
component: worker
{{- include "dask.labels" (list $worker $) | nindent 4 }}
spec:
replicas: {{ $worker.replicas }}
selector:
matchLabels:
app: {{ template "dask.name" $ }}
release: {{ $.Release.Name | quote }}
component: worker
{{- include "dask.selectorLabels" (list $worker $) | nindent 6 }}
strategy:
type: {{ $worker.strategy.type }}
template:
metadata:
labels:
app: {{ template "dask.name" $ }}
release: {{ $.Release.Name | quote }}
component: worker
{{- include "dask.selectorLabels" (list $worker $) | nindent 8 }}
{{- with $worker.annotations }}
annotations:
{{- . | toYaml | nindent 8 }}
Expand Down
6 changes: 1 addition & 5 deletions dask/templates/dask-jupyter-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@ kind: ConfigMap
metadata:
name: {{ template "dask.fullname" . }}-jupyter-config
labels:
app: {{ template "dask.name" . }}
heritage: {{ .Release.Service | quote }}
release: {{ .Release.Name | quote }}
chart: {{ template "dask.chart" . }}
component: jupyter
{{- include "dask.labels" (list .Values.jupyter $) | nindent 4 }}
data:
jupyter_notebook_config.py: |
c = get_config()
Expand Down
18 changes: 7 additions & 11 deletions dask/templates/dask-jupyter-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,22 @@ kind: Deployment
metadata:
name: {{ template "dask.fullname" . }}-jupyter
labels:
app: {{ template "dask.name" . }}
heritage: {{ .Release.Service | quote }}
release: {{ .Release.Name | quote }}
chart: {{ template "dask.chart" . }}
component: jupyter
{{- include "dask.labels" (list .Values.jupyter $) | nindent 4 }}
spec:
replicas: {{ .Values.jupyter.replicas }}
selector:
matchLabels:
app: {{ template "dask.name" . }}
release: {{ .Release.Name | quote }}
component: jupyter
{{- include "dask.selectorLabels" (list .Values.jupyter $) | nindent 6 }}
strategy:
type: RollingUpdate
template:
metadata:
labels:
app: {{ template "dask.name" . }}
release: {{ .Release.Name | quote }}
component: jupyter
{{- include "dask.selectorLabels" (list .Values.jupyter $) | nindent 8 }}
{{- with .Values.jupyter.annotations }}
annotations:
{{- . | toYaml | nindent 8 }}
{{- end }}
spec:
{{- with .Values.jupyter.image.pullSecrets }}
imagePullSecrets:
Expand Down
7 changes: 2 additions & 5 deletions dask/templates/dask-jupyter-ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,10 @@ kind: Ingress
metadata:
name: {{ template "dask.fullname" . }}-jupyter
labels:
app: {{ template "dask.fullname" . }}-jupyter
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
{{- include "dask.labels" (list .Values.jupyter $) | nindent 4 }}
{{- with .Values.jupyter.ingress.annotations }}
annotations:
{{ . | toYaml | indent 4 }}
{{ . | toYaml | nindent 4 }}
{{- end }}
spec:
{{- with .Values.jupyter.ingress.ingressClassName }}
Expand Down
10 changes: 2 additions & 8 deletions dask/templates/dask-jupyter-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,13 @@ kind: Service
metadata:
name: {{ template "dask.fullname" . }}-jupyter
labels:
app: {{ template "dask.name" . }}
heritage: {{ .Release.Service | quote }}
release: {{ .Release.Name | quote }}
chart: {{ template "dask.chart" . }}
component: jupyter
{{- include "dask.labels" (list .Values.jupyter $) | nindent 4 }}
spec:
ports:
- name: {{ template "dask.fullname" . }}-jupyter
port: {{ .Values.jupyter.servicePort }}
targetPort: 8888
selector:
app: {{ template "dask.name" . }}
release: {{ .Release.Name | quote }}
component: jupyter
{{- include "dask.selectorLabels" (list .Values.jupyter $) | nindent 4 }}
type: {{ .Values.jupyter.serviceType }}
{{- end }}
14 changes: 4 additions & 10 deletions dask/templates/dask-jupyter-serviceaccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ metadata:
name: dask-jupyter
namespace: {{ .Release.Namespace }}
labels:
app: {{ template "dask.name" . }}
release: {{ .Release.Name | quote }}
component: jupyter

{{- include "dask.selectorLabels" (list .Values.jupyter $) | nindent 4 }}

---

kind: Role
Expand All @@ -17,9 +15,7 @@ metadata:
name: dask-jupyter
namespace: {{ .Release.Namespace }}
labels:
app: {{ template "dask.name" . }}
release: {{ .Release.Name | quote }}
component: jupyter
{{- include "dask.selectorLabels" (list .Values.jupyter $) | nindent 4 }}
rules:
- apiGroups: ["apps"]
resources: ["deployments"]
Expand All @@ -39,9 +35,7 @@ metadata:
name: dask-jupyter
namespace: {{ .Release.Namespace }}
labels:
app: {{ template "dask.name" . }}
release: {{ .Release.Name | quote }}
component: jupyter
{{- include "dask.selectorLabels" (list .Values.jupyter $) | nindent 4 }}
subjects:
- kind: ServiceAccount
name: dask-jupyter
Expand Down
18 changes: 7 additions & 11 deletions dask/templates/dask-scheduler-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,22 @@ kind: Deployment
metadata:
name: {{ template "dask.fullname" . }}-scheduler
labels:
app: {{ template "dask.name" . }}
heritage: {{ .Release.Service | quote }}
release: {{ .Release.Name | quote }}
chart: {{ template "dask.chart" . }}
component: scheduler
{{- include "dask.labels" (list .Values.scheduler $) | nindent 4 }}
spec:
replicas: {{ .Values.scheduler.replicas }}
selector:
matchLabels:
app: {{ template "dask.name" . }}
release: {{ .Release.Name | quote }}
component: scheduler
{{- include "dask.selectorLabels" (list .Values.scheduler $) | nindent 6 }}
strategy:
type: RollingUpdate
template:
metadata:
labels:
app: {{ template "dask.name" . }}
release: {{ .Release.Name | quote }}
component: scheduler
{{- include "dask.selectorLabels" (list .Values.scheduler $) | nindent 8 }}
{{- with .Values.scheduler.annotations }}
annotations:
{{- . | toYaml | nindent 8 }}
{{- end }}
spec:
{{- with .Values.scheduler.image.pullSecrets }}
imagePullSecrets:
Expand Down
7 changes: 2 additions & 5 deletions dask/templates/dask-scheduler-ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,10 @@ kind: Ingress
metadata:
name: {{ template "dask.fullname" . }}-scheduler
labels:
app: {{ template "dask.fullname" . }}-scheduler
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
{{- include "dask.labels" (list .Values.scheduler $) | nindent 4 }}
{{- with .Values.webUI.ingress.annotations }}
annotations:
{{ . | toYaml | indent 4 }}
{{ . | toYaml | nindent 4 }}
{{- end }}
spec:
{{- with .Values.webUI.ingress.ingressClassName }}
Expand Down
10 changes: 2 additions & 8 deletions dask/templates/dask-scheduler-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@ kind: Service
metadata:
name: {{ template "dask.fullname" . }}-scheduler
labels:
app: {{ template "dask.name" . }}
heritage: {{ .Release.Service | quote }}
release: {{ .Release.Name | quote }}
chart: {{ template "dask.chart" . }}
component: scheduler
{{- include "dask.labels" (list .Values.scheduler $) | nindent 4 }}
{{- with .Values.scheduler.serviceAnnotations }}
annotations:
{{- . | toYaml | nindent 4 }}
Expand All @@ -22,9 +18,7 @@ spec:
port: {{ .Values.webUI.servicePort }}
targetPort: 8787
selector:
app: {{ template "dask.name" . }}
release: {{ .Release.Name | quote }}
component: scheduler
{{- include "dask.selectorLabels" (list .Values.scheduler $) | nindent 4 }}
type: {{ .Values.scheduler.serviceType }}
{{- with .Values.scheduler.loadBalancerIP }}
loadBalancerIP: {{ . }}
Expand Down
10 changes: 2 additions & 8 deletions dask/templates/dask-scheduler-servicemonitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ metadata:
namespace: {{ . | quote }}
{{- end }}
labels:
app: {{ template "dask.name" . }}
heritage: {{ .Release.Service | quote }}
release: {{ .Release.Name | quote }}
chart: {{ template "dask.chart" . }}
component: scheduler
{{- include "dask.labels" (list .Values.scheduler $) | nindent 4 }}
{{- with .Values.scheduler.metrics.serviceMonitor.additionalLabels }}
{{- . | toYaml | nindent 4 }}
{{- end }}
Expand Down Expand Up @@ -40,7 +36,5 @@ spec:
{{- end }}
selector:
matchLabels:
app: {{ template "dask.name" . }}
release: {{ .Release.Name | quote }}
component: scheduler
{{- include "dask.selectorLabels" (list .Values.scheduler $) | nindent 6 }}
{{- end }}
14 changes: 3 additions & 11 deletions dask/templates/dask-worker-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,18 @@ kind: Deployment
metadata:
name: {{ template "dask.fullname" . }}-worker
labels:
app: {{ template "dask.name" . }}
heritage: {{ .Release.Service | quote }}
release: {{ .Release.Name | quote }}
chart: {{ template "dask.chart" . }}
component: worker
{{- include "dask.labels" (list .Values.worker $) | nindent 4 }}
spec:
replicas: {{ .Values.worker.replicas }}
selector:
matchLabels:
app: {{ template "dask.name" . }}
release: {{ .Release.Name | quote }}
component: worker
{{- include "dask.selectorLabels" (list .Values.worker $) | nindent 6 }}
strategy:
type: {{ .Values.worker.strategy.type }}
template:
metadata:
labels:
app: {{ template "dask.name" . }}
release: {{ .Release.Name | quote }}
component: worker
{{- include "dask.selectorLabels" (list .Values.worker $) | nindent 8 }}
{{- with .Values.worker.annotations }}
annotations:
{{- . | toYaml | nindent 8 }}
Expand Down
10 changes: 2 additions & 8 deletions dask/templates/dask-worker-podmonitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ metadata:
namespace: {{ . | quote }}
{{- end }}
labels:
app: {{ template "dask.name" . }}
heritage: {{ .Release.Service | quote }}
release: {{ .Release.Name | quote }}
chart: {{ template "dask.chart" . }}
component: worker
{{- include "dask.labels" (list .Values.worker $) | nindent 4 }}
{{- with .Values.worker.metrics.podMonitor.additionalLabels }}
{{- . | toYaml | nindent 4 }}
{{- end }}
Expand Down Expand Up @@ -41,7 +37,5 @@ spec:
{{- end }}
selector:
matchLabels:
app: {{ template "dask.name" . }}
release: {{ .Release.Name | quote }}
component: worker
{{- include "dask.selectorLabels" (list .Values.worker $) | nindent 6 }}
{{- end }}
Loading