Skip to content
Snippets Groups Projects
statefulset.yaml 6.63 KiB
Newer Older
avouacr's avatar
avouacr committed
{{- $fullName := include "library-chart.fullname" . -}}
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: {{ include "library-chart.fullname" . }}
  labels:
    {{- include "library-chart.labels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
  replicas: {{ .Values.replicaCount }}
{{- end }}
  serviceName: {{ include "library-chart.fullname" . }}
  selector:
    matchLabels:
      {{- include "library-chart.selectorLabels" . | nindent 6 }}
  template:
    metadata:
      annotations:
fcomte's avatar
fcomte committed
        {{- if .Values.git.enabled }}
        checksum/git: {{ include (print $.Template.BasePath "/configmap-git.yaml") . | sha256sum }}
        {{- end }}
        {{- if .Values.s3.enabled }}
        checksum/s3: {{ include (print $.Template.BasePath "/configmap-s3.yaml") . | sha256sum }}
        {{- end }}
        {{- if .Values.vault.enabled }}
        checksum/vault: {{ include (print $.Template.BasePath "/configmap-vault.yaml") . | sha256sum }}
        {{- end }}
        {{- if .Values.proxyRepository.enabled }}
        checksum/proxyRepository: {{ include (print $.Template.BasePath "/configmap-proxy-repository.yaml") . | sha256sum }}
        {{- end }}
fcomte's avatar
fcomte committed
        {{- if not (empty (trim (include "library-chart.configMapMLFlow" .)))}}
        checksum/mlflow: {{ include (print $.Template.BasePath "/configmap-mlflow.yaml") . | sha256sum }}
        {{- end }}
        {{- if not (empty (trim (include "library-chart.configMapHive" .)))}}
        checksum/hive: {{ include (print $.Template.BasePath "/configmap-hive.yaml") . | sha256sum }}
        {{- end }}
        {{- with .Values.podAnnotations }}
avouacr's avatar
avouacr committed
        {{- toYaml . | nindent 8 }}
fcomte's avatar
fcomte committed
        {{- end }}
avouacr's avatar
avouacr committed
      labels:
        {{- include "library-chart.selectorLabels" . | nindent 8 }}
    spec:
      volumes:
        - name: home
        {{- if .Values.persistence.enabled }}
          persistentVolumeClaim:
            claimName: {{ .Values.persistence.existingClaim | default (include "library-chart.fullname" .) }}
        {{- else }}
          emptyDir: {}
        {{- end }}
        {{- if .Values.discovery.hive }}
        - name: hive-config
          configMap:
            name: {{ include "library-chart.configMapNameHive" . }}
        {{- end }}
      {{- with .Values.imagePullSecrets }}
      imagePullSecrets:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      serviceAccountName: {{ include "library-chart.serviceAccountName" . }}
      securityContext:
        {{- toYaml .Values.podSecurityContext | nindent 8 }}
      subdomain: {{ include "library-chart.fullname" . }}
      hostname: jupyter
      containers:
        - name: {{ .Chart.Name }}
          securityContext:
            {{- toYaml .Values.securityContext | nindent 12 }}
          {{- if .Values.service.image.custom.enabled }}
          image: "{{ .Values.service.image.custom.version }}"
          {{- else }}
          image: "{{ .Values.service.image.version }}"
          {{- end }}
          command: ["/bin/sh","-c"]
          args: ["{{ .Values.init.standardInitPath }} jupyter lab --no-browser --ip '0.0.0.0' --LabApp.token='$(PASSWORD)' --ContentsManager.allow_hidden=True"]
avouacr's avatar
avouacr committed
          imagePullPolicy: {{ .Values.service.image.pullPolicy }}
          env:
            - name: KUBERNETES_POD_NAME
              valueFrom:
                fieldRef:
                  fieldPath: metadata.name
            - name: IMAGE_NAME
              {{- if .Values.service.image.custom.enabled }}
              value: "{{ .Values.service.image.custom.version }}"
              {{- else }}
              value: "{{ .Values.service.image.version }}"
              {{- end }}
            - name: NB_USER
              value: {{ .Values.environment.user }}
            - name: PASSWORD
              value: {{ .Values.security.password }}
            - name: PROJECT_USER
              value: {{ .Values.environment.user }}
            - name: PROJECT_GROUP
              value: {{ .Values.environment.group }}
            - name: ROOT_PROJECT_DIRECTORY
              value: /home/{{ .Values.environment.user }}/work
            {{- if .Values.init.regionInit }}
            - name: REGION_INIT_SCRIPT
              value: {{ .Values.init.regionInit }}
            {{- end }}
avouacr's avatar
avouacr committed
            {{- if .Values.init.personalInit }}
            - name: PERSONAL_INIT_SCRIPT
              value: {{ .Values.init.personalInit }}
            {{- end }}
            {{- if .Values.init.personalInitArgs }}
            - name: PERSONAL_INIT_ARGS
              value: {{ .Values.init.personalInitArgs }}
            {{- end }}
            {{- if .Values.environment.root }}
            - name: GRANT_SUDO
              value: "yes"
            {{- end }}          
          envFrom: 
            {{- if .Values.s3.enabled }}
            - configMapRef:
                name: {{ include "library-chart.configMapNameS3" . }}
            {{- end }}
            {{- if .Values.vault.enabled }}
            - configMapRef:
                name: {{ include "library-chart.configMapNameVault" . }}
            {{- end }}
            {{- if .Values.git.enabled }}
            - configMapRef:
                name: {{ include "library-chart.configMapNameGit" . }}
            {{- end }}
            {{- if .Values.proxyRepository.enabled }}
            - configMapRef:
                name: {{ include "library-chart.configMapNameProxyRepository" . }}
            {{- end }}
avouacr's avatar
avouacr committed
            {{- if not (empty (trim (include "library-chart.configMapMLFlow" .)))}}
            - configMapRef:
                name: {{ include "library-chart.configMapNameMLFlow" . }}
            {{- end }}
          ports:
            - name: http
              containerPort: 8888
              protocol: TCP
          livenessProbe:
            httpGet:
              path: /
              port: http
          readinessProbe:
            httpGet:
              path: /
              port: http
          startupProbe:
            httpGet:
              path: /
              port: http
            {{- toYaml .Values.startupProbe | nindent 12 }}     
          resources:
            {{- toYaml .Values.resources | nindent 12 }}
          volumeMounts:
            - mountPath: /home/{{ .Values.environment.user}}/work
              name: home
            {{- if .Values.discovery.hive }}
            - name: hive-config
              mountPath: /opt/hive/conf/hive-site.xml
              subPath: hive-site.xml
avouacr's avatar
avouacr committed
      {{- with .Values.nodeSelector }}
      nodeSelector:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.affinity }}
      affinity:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.tolerations }}
      tolerations:
        {{- toYaml . | nindent 8 }}
      {{- end }}