{{- include "node.validateNodeConfigs" . -}} apiVersion: apps/v1 kind: StatefulSet metadata: name: {{ include "node.fullname" . }} labels: {{- include "node.labels" . | nindent 4 }} spec: serviceName: {{ include "node.fullname" . }} replicas: {{ .Values.replicas }} podManagementPolicy: Parallel selector: matchLabels: {{- include "node.selectorLabels" . | nindent 6 }} template: metadata: labels: {{- include "node.selectorLabels" . | nindent 8 }} {{- with .Values.podLabels }} {{- toYaml . | nindent 8 }} {{- end }} annotations: rsquad.io/config-checksum: {{ include "node.configChecksum" . }} {{- with .Values.podAnnotations }} {{- toYaml . | nindent 8 }} {{- end }} spec: {{- if .Values.serviceAccount.enabled }} serviceAccountName: {{ include "node.serviceAccountName" . }} {{- end }} {{- with .Values.imagePullSecrets }} imagePullSecrets: {{- toYaml . | nindent 8 }} {{- end }} securityContext: fsGroup: 1000 {{- with .Values.nodeSelector }} nodeSelector: {{- toYaml . | nindent 8 }} {{- end }} {{- with .Values.tolerations }} tolerations: {{- toYaml . | nindent 8 }} {{- end }} {{- with .Values.affinity }} affinity: {{- toYaml . | nindent 8 }} {{- end }} terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }} {{- if .Values.hostNetwork }} hostNetwork: true dnsPolicy: {{ .Values.dnsPolicy | default "ClusterFirstWithHostNet" }} {{- end }} initContainers: - name: init-bootstrap image: {{ .Values.initImage.repository }}:{{ .Values.initImage.tag }} imagePullPolicy: {{ .Values.initImage.pullPolicy }} command: ["/bin/sh", "-euc"] args: - | {{- .Files.Get "files/init-script.sh" | nindent 14 }} env: - name: POD_NAME valueFrom: fieldRef: fieldPath: metadata.name volumeMounts: - name: main mountPath: /main - name: global-config mountPath: /seed/global-config readOnly: true - name: logs-config mountPath: /seed/logs-config readOnly: true - name: node-configs mountPath: /seed/node-configs readOnly: true {{- if include "node.hasBasestate" . }} - name: basestate mountPath: /seed/basestate readOnly: true {{- end }} {{- if include "node.hasZerostate" . }} - name: zerostate mountPath: /seed/zerostate readOnly: true {{- end }} {{- with .Values.extraInitContainers }} {{- tpl (toYaml .) $ | nindent 8 }} {{- end }} containers: - name: ton-node {{- if .Values.debug.sleep }} image: busybox:1.36 imagePullPolicy: IfNotPresent command: ["sleep", "infinity"] {{- else }} image: {{ .Values.image.repository }}:{{ .Values.image.tag }} imagePullPolicy: {{ .Values.image.pullPolicy }} {{- if .Values.command }} command: {{- toYaml .Values.command | nindent 12 }} {{- else if and (include "node.hasZerostate" .) (include "node.hasBasestate" .) }} command: ["node", "-c", "/main", "-z", "/main/static"] {{- else }} command: ["node", "-c", "/main"] {{- end }} {{- end }} {{- if or (include "node.hasVault" .) .Values.extraEnv }} env: {{- include "node.vaultEnv" . | nindent 12 }} {{- with .Values.extraEnv }} {{- toYaml . | nindent 12 }} {{- end }} {{- end }} {{- with .Values.extraEnvFrom }} envFrom: {{- toYaml . | nindent 12 }} {{- end }} resources: {{- toYaml .Values.resources | nindent 12 }} ports: - name: adnl containerPort: {{ .Values.ports.adnl }} protocol: UDP {{- if .Values.hostPort.adnl }} hostPort: {{ .Values.ports.adnl }} {{- end }} {{- with (include "node.simplexPort" .) }} - name: simplex containerPort: {{ . }} protocol: UDP {{- if $.Values.hostPort.simplex }} hostPort: {{ . }} {{- end }} {{- end }} {{- if .Values.ports.control }} - name: control containerPort: {{ .Values.ports.control }} protocol: TCP {{- if .Values.hostPort.control }} hostPort: {{ .Values.ports.control }} {{- end }} {{- end }} {{- if .Values.ports.liteserver }} - name: liteserver containerPort: {{ .Values.ports.liteserver }} protocol: TCP {{- if .Values.hostPort.liteserver }} hostPort: {{ .Values.ports.liteserver }} {{- end }} {{- end }} {{- if .Values.ports.jsonRpc }} - name: json-rpc containerPort: {{ .Values.ports.jsonRpc }} protocol: TCP {{- if .Values.hostPort.jsonRpc }} hostPort: {{ .Values.ports.jsonRpc }} {{- end }} {{- end }} {{- if .Values.ports.metrics }} - name: metrics containerPort: {{ .Values.ports.metrics }} protocol: TCP {{- if .Values.hostPort.metrics }} hostPort: {{ .Values.ports.metrics }} {{- end }} {{- end }} {{- with .Values.probes.liveness }} livenessProbe: {{- toYaml . | nindent 12 }} {{- end }} {{- with .Values.probes.readiness }} readinessProbe: {{- toYaml . | nindent 12 }} {{- end }} {{- with .Values.probes.startup }} startupProbe: {{- toYaml . | nindent 12 }} {{- end }} {{- if .Values.debug.securityContext }} securityContext: {{- toYaml .Values.debug.securityContext | nindent 12 }} {{- end }} volumeMounts: - name: main mountPath: /main - name: db mountPath: /db {{- if .Values.storage.logs.enabled }} - name: logs mountPath: /logs {{- end }} - name: keys mountPath: /keys {{- with .Values.extraVolumeMounts }} {{- toYaml . | nindent 12 }} {{- end }} {{- with .Values.extraContainers }} {{- tpl (toYaml .) $ | nindent 8 }} {{- end }} volumes: - name: global-config configMap: name: {{ include "node.globalConfigMapName" . }} - name: logs-config configMap: name: {{ include "node.logsConfigMapName" . }} - name: node-configs secret: secretName: {{ include "node.nodeConfigsSecretName" . }} {{- if include "node.hasBasestate" . }} - name: basestate configMap: name: {{ include "node.basestateConfigMapName" . }} {{- end }} {{- if include "node.hasZerostate" . }} - name: zerostate configMap: name: {{ include "node.zerostateConfigMapName" . }} {{- end }} {{- with .Values.extraVolumes }} {{- toYaml . | nindent 8 }} {{- end }} volumeClaimTemplates: {{- $volumes := list "main" "db" "keys" -}} {{- if $.Values.storage.logs.enabled }} {{- $volumes = append $volumes "logs" -}} {{- end }} {{- range $vol := $volumes }} {{- $volConfig := index $.Values.storage $vol }} - metadata: name: {{ $vol }} {{- if or $volConfig.resourcePolicy (gt (len $volConfig.annotations) 0) }} annotations: {{- with $volConfig.annotations }} {{- toYaml . | nindent 10 }} {{- end }} {{- if $volConfig.resourcePolicy }} helm.sh/resource-policy: {{ $volConfig.resourcePolicy | quote }} {{- end }} {{- end }} spec: accessModes: ["ReadWriteOnce"] storageClassName: {{ index $.Values.storage $vol "storageClassName" }} resources: requests: storage: {{ index $.Values.storage $vol "size" }} {{- end }}