Guest User

Untitled

a guest
May 16th, 2019
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 6.84 KB | None | 0 0
  1. apiVersion: apps/v1
  2. kind: Deployment
  3. metadata:
  4.   name: hub
  5.   labels:
  6.    {{- include "jupyterhub.labels" . | nindent 4 }}
  7. spec:
  8.   replicas: 1
  9.   selector:
  10.     matchLabels:
  11.      {{- include "jupyterhub.matchLabels" . | nindent 6 }}
  12.   strategy:
  13.    {{- .Values.hub.deploymentStrategy | toYaml | trimSuffix "\n" | nindent 4 }}
  14.   template:
  15.     metadata:
  16.       labels:
  17.        {{- /* Changes here will cause the Deployment to restart the pods. */}}
  18.         {{- include "jupyterhub.matchLabels" . | nindent 8 }}
  19.         hub.jupyter.org/network-access-proxy-api: "true"
  20.         hub.jupyter.org/network-access-proxy-http: "true"
  21.         hub.jupyter.org/network-access-singleuser: "true"
  22.         {{- if .Values.hub.labels }}
  23.         {{- .Values.hub.labels | toYaml | trimSuffix "\n" | nindent 8 }}
  24.         {{- end }}
  25.       annotations:
  26.        # This lets us autorestart when the secret changes!
  27.         checksum/config-map: {{ include (print .Template.BasePath "/hub/configmap.yaml") . | sha256sum }}
  28.         checksum/secret: {{ include (print .Template.BasePath "/hub/secret.yaml") . | sha256sum }}
  29.         {{- if .Values.hub.annotations }}
  30.         {{- .Values.hub.annotations | toYaml | trimSuffix "\n" | nindent 8 }}
  31.         {{- end }}
  32.     spec:
  33.      {{- if .Values.scheduling.podPriority.enabled }}
  34.       priorityClassName: {{ .Release.Name }}-default-priority
  35.       {{- end }}
  36.       nodeSelector: {{ toJson .Values.hub.nodeSelector }}
  37.       {{- include "jupyterhub.coreAffinity" . | nindent 6 }}
  38.       volumes:
  39.         - name: config
  40.           configMap:
  41.             name: hub-config
  42.         - name: secret
  43.           secret:
  44.             secretName: hub-secret
  45.         {{- if .Values.hub.extraVolumes }}
  46.         {{- .Values.hub.extraVolumes | toYaml | trimSuffix "\n" | nindent 8 }}
  47.         {{- end }}
  48.         {{- if eq .Values.hub.db.type "sqlite-pvc" }}
  49.         - name: hub-db-dir
  50.           persistentVolumeClaim:
  51.             claimName: hub-db-dir
  52.         {{- end }}
  53.       {{- if .Values.rbac.enabled }}
  54.       serviceAccountName: hub
  55.       {{- end }}
  56.       securityContext:
  57.         runAsUser: {{ .Values.hub.uid }}
  58.         fsGroup: {{ .Values.hub.fsGid }}
  59.       {{- if .Values.hub.imagePullSecret.enabled }}
  60.       imagePullSecrets:
  61.         - name: hub-image-credentials
  62.       {{- end }}
  63.       containers:
  64.        {{- if .Values.hub.extraContainers }}
  65.         {{- .Values.hub.extraContainers | toYaml | trimSuffix "\n" | nindent 8 }}
  66.         {{- end }}
  67.         - name: hub
  68.           image: {{ .Values.hub.image.name }}:{{ .Values.hub.image.tag }}
  69.           command:
  70.            - jupyterhub
  71.             - --config
  72.             - /srv/jupyterhub_config.py
  73.             {{- if .Values.debug.enabled }}
  74.             - --debug
  75.             {{- end }}
  76.             {{- /*
  77.             We want to do automatic upgrades for sqlite-pvc by default, but
  78.             allow users to opt out of that if they want. Users using their own
  79.             db need to 'opt in' Go Templates treat nil and "" and false as
  80.             'false', making this code complex. We can probably make this a
  81.             one-liner, but doing combinations of boolean vars in go templates is
  82.             very inelegant & hard to reason about.
  83.             */}}
  84.             {{- $upgradeType := typeOf .Values.hub.db.upgrade }}
  85.             {{- if eq $upgradeType "bool" }}
  86.             {{- /* .Values.hub.db.upgrade has been explicitly set to true or false */}}
  87.             {{- if .Values.hub.db.upgrade }}
  88.             - --upgrade-db
  89.             {{- end }}
  90.             {{- else if eq $upgradeType "<nil>" }}
  91.             {{- /* .Values.hub.db.upgrade is nil */}}
  92.             {{- if eq .Values.hub.db.type "sqlite-pvc" }}
  93.             - --upgrade-db
  94.             {{- end }}
  95.             {{- end }}
  96.           volumeMounts:
  97.             - mountPath: /etc/jupyterhub/config/
  98.               name: config
  99.             - mountPath: /etc/jupyterhub/secret/
  100.               name: secret
  101.             {{- if .Values.hub.extraVolumeMounts }}
  102.             {{- .Values.hub.extraVolumeMounts | toYaml | trimSuffix "\n" | nindent 12 }}
  103.             {{- end }}
  104.             {{- if eq .Values.hub.db.type "sqlite-pvc" }}
  105.             - mountPath: /srv/jupyterhub
  106.               name: hub-db-dir
  107.               {{- if .Values.hub.db.pvc.subPath }}
  108.               subPath: {{ .Values.hub.db.pvc.subPath | quote }}
  109.               {{- end }}
  110.             {{- end }}
  111.           resources:
  112.            {{- .Values.hub.resources | toYaml | trimSuffix "\n" | nindent 12 }}
  113.           imagePullPolicy: {{ .Values.hub.imagePullPolicy }}
  114.           env:
  115.             - name: PYTHONUNBUFFERED
  116.               value: "1"
  117.             - name: HELM_RELEASE_NAME
  118.               value: {{ .Release.Name | quote }}
  119.             {{- if .Values.hub.cookieSecret }}
  120.             - name: JPY_COOKIE_SECRET
  121.               valueFrom:
  122.                 secretKeyRef:
  123.                   name: hub-secret
  124.                   key: hub.cookie-secret
  125.             {{- end }}
  126.             - name: POD_NAMESPACE
  127.               valueFrom:
  128.                 fieldRef:
  129.                   fieldPath: metadata.namespace
  130.             - name: CONFIGPROXY_AUTH_TOKEN
  131.               valueFrom:
  132.                 secretKeyRef:
  133.                   name: hub-secret
  134.                   key: proxy.token
  135.             {{- if .Values.auth.state.enabled }}
  136.             - name: JUPYTERHUB_CRYPT_KEY
  137.               valueFrom:
  138.                 secretKeyRef:
  139.                   name: hub-secret
  140.                   key: auth.state.crypto-key
  141.             {{- end }}
  142.             {{- if .Values.hub.db.password }}
  143.             {{- if eq .Values.hub.db.type "mysql" }}
  144.             - name: MYSQL_PWD
  145.               valueFrom:
  146.                 secretKeyRef:
  147.                   name: hub-secret
  148.                   key: hub.db.password
  149.             {{- else if eq .Values.hub.db.type "postgres" }}
  150.             - name: PGPASSWORD
  151.               valueFrom:
  152.                 secretKeyRef:
  153.                   name: hub-secret
  154.                   key: hub.db.password
  155.             {{- end }}
  156.             {{- end }}
  157.             {{- if .Values.hub.extraEnv }}
  158.             {{- $extraEnvType := typeOf .Values.hub.extraEnv }}
  159.             {{- /* If we have a list, embed that here directly. This allows for complex configuration from configmap, downward API, etc. */}}
  160.             {{- if eq $extraEnvType "[]interface {}" }}
  161.             {{- .Values.hub.extraEnv | toYaml | trimSuffix "\n" | nindent 12 }}
  162.             {{- else if eq $extraEnvType "map[string]interface {}" }}
  163.             {{- /* If we have a map, treat those as key-value pairs. */}}
  164.             {{- range $key, $value := .Values.hub.extraEnv }}
  165.             - name: {{ $key | quote }}
  166.               value: {{ $value | quote }}
  167.             {{- end }}
  168.             {{- end }}
  169.             {{- end }}
  170.           ports:
  171.             - containerPort: 8081
  172.               name: hub
Add Comment
Please, Sign In to add comment