mirror of
https://github.com/logos-storage/helm-charts.git
synced 2026-01-03 21:53:06 +00:00
271 lines
11 KiB
YAML
271 lines
11 KiB
YAML
{{- range $replica_index := until (int (include "codex.statefulSetCount" .)) }}
|
|
{{- with $ }}
|
|
{{- $replica_suffix := ternary "" (print "-" (add $replica_index .Values.statefulSet.ordinalsStart)) (and (eq (int .Values.replica.count) 1) .Values.statefulSet.prettify) }}
|
|
---
|
|
apiVersion: apps/v1
|
|
kind: StatefulSet
|
|
metadata:
|
|
name: {{ print (include "codex.fullname" .) $replica_suffix }}
|
|
namespace: {{ include "codex.namespace" . }}
|
|
labels: {{ include "codex.labels" . | nindent 4 }}
|
|
annotations:
|
|
meta.helm.sh/release-name: {{ include "codex.fullname" . }}
|
|
meta.helm.sh/release-namespace: {{ include "codex.namespace" . }}
|
|
{{- with .Values.annotations }}
|
|
{{- toYaml . | nindent 4 }}
|
|
{{- end }}
|
|
spec:
|
|
replicas: {{ include "codex.replica.count" . }}
|
|
ordinals:
|
|
start: {{ .Values.statefulSet.ordinalsStart }}
|
|
selector:
|
|
matchLabels:
|
|
{{- include "codex.selectorLabels" . | nindent 6 }}
|
|
template:
|
|
metadata:
|
|
{{- with .Values.podAnnotations }}
|
|
annotations:
|
|
{{- toYaml . | nindent 8 }}
|
|
{{- end }}
|
|
labels:
|
|
{{- include "codex.labels" . | nindent 8 }}
|
|
{{- with .Values.podLabels }}
|
|
{{- toYaml . | nindent 8 }}
|
|
{{- end }}
|
|
spec:
|
|
{{- with .Values.imagePullSecrets }}
|
|
imagePullSecrets:
|
|
{{- toYaml . | nindent 8 }}
|
|
{{- end }}
|
|
serviceAccountName: {{ include "codex.serviceAccountName" . }}
|
|
securityContext:
|
|
{{- toYaml .Values.podSecurityContext | nindent 8 }}
|
|
initContainers:
|
|
{{- range .Values.initContainers }}
|
|
- {{ tpl (toYaml .) $ | nindent 10 | trim }}
|
|
{{- end }}
|
|
{{- if eq (include "codex.initEnv.enabled" .) "true" }}
|
|
- name: init-env
|
|
image: {{ print .Values.initEnv.image.repository ":" .Values.initEnv.image.tag }}
|
|
imagePullPolicy: {{ .Values.initEnv.image.pullPolicy }}
|
|
securityContext:
|
|
runAsNonRoot: false
|
|
runAsUser: 0
|
|
env:
|
|
- name: NODE_NAME
|
|
valueFrom:
|
|
fieldRef:
|
|
fieldPath: spec.nodeName
|
|
- name: ENV_PATH
|
|
value: "{{ .Values.initEnv.envPath }}"
|
|
command:
|
|
- sh
|
|
- -c
|
|
- >
|
|
NODEPORT_FILE=${ENV_PATH}/nodeport;
|
|
{{- if ne .Values.initEnv.command "" }}
|
|
{{- .Values.initEnv.command | toYaml | nindent 14 }}
|
|
{{- else }}
|
|
CODEX_NAT=$(kubectl get nodes ${NODE_NAME} -o jsonpath='{.status.addresses[?(@.type=="ExternalIP")].address}');
|
|
echo "CODEX_NAT=extip:${CODEX_NAT}" >> ${NODEPORT_FILE};
|
|
cat ${NODEPORT_FILE};
|
|
{{- end }}
|
|
volumeMounts:
|
|
- name: env-nodeport
|
|
mountPath: {{ .Values.initEnv.envPath }}
|
|
{{- end }}
|
|
|
|
containers:
|
|
- name: {{ .Chart.Name }}
|
|
securityContext:
|
|
{{- toYaml .Values.securityContext | nindent 12 }}
|
|
image: {{ print .Values.image.repository ":" (.Values.image.tag | default .Chart.AppVersion) }}
|
|
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
|
lifecycle:
|
|
{{- if .Values.lifecycle }}
|
|
{{- toYaml .Values.lifecycle | nindent 12 }}
|
|
{{- else if .Values.codex.marketplace }}
|
|
postStart:
|
|
exec:
|
|
command:
|
|
- bash
|
|
- -c
|
|
- |
|
|
sleep 10
|
|
|
|
while true; do
|
|
curl --max-time 2 http://localhost:{{ .Values.ports.api.containerPort}}/api/codex/v1/debug/info && break
|
|
sleep 10
|
|
done
|
|
|
|
availability=$(curl http://localhost:{{ .Values.ports.api.containerPort}}/api/codex/v1/sales/availability | jq -r '.[]')
|
|
|
|
if [[ -z "${availability}" ]]; then
|
|
availability=$(curl http://localhost:{{ .Values.ports.api.containerPort}}/api/codex/v1/sales/availability \
|
|
--max-time 2 \
|
|
--request POST \
|
|
--header 'Content-Type: application/json' \
|
|
--data '{
|
|
"totalSize": "{{ .Values.codex.marketplace.totalSize }}",
|
|
"duration": "{{ .Values.codex.marketplace.duration }}",
|
|
"minPricePerBytePerSecond": "{{ .Values.codex.marketplace.minPricePerBytePerSecond }}",
|
|
"totalCollateral": "{{ .Values.codex.marketplace.totalCollateral }}"
|
|
}')
|
|
echo -e "Storage availability was configured \n${availability}" >/opt/storage-availability
|
|
else
|
|
echo -e "Storage availability already configured \n${availability}" >/opt/storage-availability
|
|
fi
|
|
{{- end }}
|
|
{{- if .Values.codex.command }}
|
|
command:
|
|
{{- toYaml .Values.codex.command | nindent 12 }}
|
|
{{- end }}
|
|
{{- if .Values.codex.args }}
|
|
args:
|
|
{{- toYaml .Values.codex.args | nindent 12 }}
|
|
{{- end }}
|
|
|
|
env:
|
|
{{- if eq (include "codex.initEnv.enabled" .) "true" }}
|
|
- name: ENV_PATH
|
|
value: "{{ .Values.initEnv.envPath }}"
|
|
{{- end }}
|
|
{{- range $name, $value := .Values.codex.env }}
|
|
{{- if and (include "codex.service.nodeport.enabled" $) (eq $name "CODEX_DISC_PORT") }}
|
|
{{- $discovery_port_replica := add $.Values.service.discovery.nodePort (mul $replica_index $.Values.service.discovery.nodePortOffset) }}
|
|
- name: {{ $name }}
|
|
value: {{ $discovery_port_replica | quote }}
|
|
{{- else if and (include "codex.service.nodeport.enabled" $) (eq $name "CODEX_LISTEN_ADDRS") }}
|
|
{{- $transport_port := splitList "/" $value | last }}
|
|
{{- $transport_port_replica := add $.Values.service.transport.nodePort (mul $replica_index $.Values.service.discovery.nodePortOffset) }}
|
|
{{- $lister_addrs := $value | replace (toString $transport_port) (toString $transport_port_replica) }}
|
|
- name: {{ $name }}
|
|
value: {{ $lister_addrs | quote }}
|
|
{{- else }}
|
|
- name: {{ $name }}
|
|
value: {{ $value | quote }}
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- range .Values.codex.extraEnv }}
|
|
- {{ toYaml . | replace "replica_index" (toString (add $replica_index $.Values.statefulSet.ordinalsStart)) | replace "pod_index" (toString $.Values.statefulSet.ordinalsStart) | nindent 14 | trim }}
|
|
{{- end }}
|
|
|
|
ports:
|
|
{{- if .Values.ports.api }}
|
|
- name: {{ .Values.ports.api.name }}
|
|
containerPort: {{ .Values.ports.api.containerPort }}
|
|
protocol: TCP
|
|
{{- end }}
|
|
{{- if .Values.ports.metrics }}
|
|
- name: {{ .Values.ports.metrics.name }}
|
|
containerPort: {{ .Values.ports.metrics.containerPort }}
|
|
protocol: TCP
|
|
{{- end }}
|
|
{{- if .Values.ports.transport }}
|
|
- name: {{ .Values.ports.transport.name }}
|
|
containerPort: {{ if include "codex.service.nodeport.enabled" . }}{{- add .Values.service.transport.nodePort (mul $replica_index .Values.service.transport.nodePortOffset) -}}{{ end }}
|
|
protocol: TCP
|
|
{{- end }}
|
|
{{- if .Values.ports.discovery }}
|
|
- name: {{ .Values.ports.discovery.name }}
|
|
containerPort: {{ if include "codex.service.nodeport.enabled" . }}{{- add .Values.service.discovery.nodePort (mul $replica_index .Values.service.discovery.nodePortOffset) -}}{{ end }}
|
|
protocol: UDP
|
|
{{- end }}
|
|
{{- with .Values.extraContainerPorts }}
|
|
{{- toYaml . | nindent 12 }}
|
|
{{- end }}
|
|
|
|
{{- with .Values.startupProbe }}
|
|
startupProbe:
|
|
{{- tpl (toYaml .) $ | nindent 12 }}
|
|
{{- end }}
|
|
{{- with .Values.livenessProbe }}
|
|
livenessProbe:
|
|
{{- tpl (toYaml .) $ | nindent 12 }}
|
|
{{- end }}
|
|
{{- with .Values.readinessProbe }}
|
|
readinessProbe:
|
|
{{- tpl (toYaml .) $ | nindent 12 }}
|
|
{{- end }}
|
|
|
|
resources:
|
|
{{- toYaml .Values.resources | nindent 12 }}
|
|
|
|
volumeMounts:
|
|
{{- if eq (include "codex.initEnv.enabled" .) "true" }}
|
|
- name: env-nodeport
|
|
mountPath: {{ .Values.initEnv.envPath }}
|
|
{{- end }}
|
|
{{- if include "codex.env.ethPrivateKey.mount" . }}
|
|
- name: codex-eth-private-key
|
|
mountPath: {{ .Values.codex.env.CODEX_ETH_PRIVATE_KEY }}
|
|
subPath: codex-eth-private-key
|
|
{{- end }}
|
|
{{- if .Values.persistence.enabled }}
|
|
- name: {{ .Values.persistence.name }}
|
|
mountPath: {{ .Values.codex.env.CODEX_DATA_DIR }}
|
|
{{ else if .Values.persistence.exis}}
|
|
- name: {{ .Values.persistence.name }}
|
|
emptyDir: {}
|
|
{{- end }}
|
|
{{- with .Values.volumeMounts }}
|
|
{{- toYaml . | nindent 12 }}
|
|
{{- end }}
|
|
|
|
{{- with .Values.nodeSelector }}
|
|
nodeSelector:
|
|
{{- toYaml . | nindent 10 }}
|
|
{{- end }}
|
|
{{- with .Values.affinity }}
|
|
affinity:
|
|
{{- toYaml . | nindent 10 }}
|
|
{{- end }}
|
|
{{- with .Values.tolerations }}
|
|
tolerations:
|
|
{{- toYaml . | nindent 10 }}
|
|
{{- end }}
|
|
topologySpreadConstraints:
|
|
{{- toYaml .Values.topologySpreadConstraints | nindent 10 }}
|
|
terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }}
|
|
{{- range .Values.extraContainers }}
|
|
- {{- toYaml . | nindent 10 | trim }}
|
|
{{- end }}
|
|
|
|
volumes:
|
|
{{- if eq (include "codex.initEnv.enabled" .) "true" }}
|
|
- name: env-nodeport
|
|
emptyDir: {}
|
|
{{- end }}
|
|
{{- if eq (include "codex.env.ethPrivateKey.mount" .) "true" }}
|
|
- name: codex-eth-private-key
|
|
secret:
|
|
secretName: {{ .Values.codex.env.CODEX_ETH_PRIVATE_KEY | splitList "/" | last }}
|
|
items:
|
|
- key: {{ print "CODEX_ETH_PRIVATE_KEY" $replica_suffix "-1" }}
|
|
path: codex-eth-private-key
|
|
defaultMode: 384
|
|
{{- end }}
|
|
|
|
{{- if .Values.persistence.enabled }}
|
|
volumeClaimTemplates:
|
|
- metadata:
|
|
name: {{ .Values.persistence.name }}
|
|
annotations:
|
|
{{- toYaml .Values.persistence.annotations | nindent 10 }}
|
|
spec:
|
|
accessModes:
|
|
{{- toYaml .Values.persistence.accessModes | nindent 10 }}
|
|
resources:
|
|
requests:
|
|
storage: {{ .Values.persistence.size | quote }}
|
|
storageClassName: {{ .Values.persistence.storageClassName }}
|
|
{{- with .Values.persistence.selector }}
|
|
selector:
|
|
{{- toYaml . | nindent 10 }}
|
|
{{- end }}
|
|
persistentVolumeClaimRetentionPolicy:
|
|
whenDeleted: {{ .Values.persistence.retentionPolicy.whenDeleted }}
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- end }}
|