Skip to content

πŸ™Œ OpenHands: AI-Driven Development

6.7 KB
Raw Blame
{{- $fullName := include "agent-canvas.fullname" . -}}
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: {{ $fullName }}
  namespace: {{ .Release.Namespace }}
  labels:
    {{- include "agent-canvas.labels" . | nindent 4 }}
spec:
  serviceName: {{ $fullName }}-headless
  replicas: {{ .Values.replicaCount }}
  podManagementPolicy: {{ .Values.statefulSet.podManagementPolicy }}
  {{- with .Values.statefulSet.updateStrategy }}
  updateStrategy:
    {{- toYaml . | nindent 4 }}
  {{- end }}
  {{- with .Values.statefulSet.persistentVolumeClaimRetentionPolicy }}
  persistentVolumeClaimRetentionPolicy:
    {{- toYaml . | nindent 4 }}
  {{- end }}
  selector:
    matchLabels:
      {{- include "agent-canvas.selectorLabels" . | nindent 6 }}
  template:
    metadata:
      labels:
        {{- include "agent-canvas.selectorLabels" . | nindent 8 }}
        {{- with .Values.podLabels }}
        {{- toYaml . | nindent 8 }}
        {{- end }}
      {{- with .Values.podAnnotations }}
      annotations:
        {{- toYaml . | nindent 8 }}
      {{- end }}
    spec:
      serviceAccountName: {{ include "agent-canvas.serviceAccountName" . }}
      automountServiceAccountToken: {{ .Values.serviceAccount.automountServiceAccountToken }}
      {{- with .Values.imagePullSecrets }}
      imagePullSecrets:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.podSecurityContext }}
      securityContext:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      containers:
        - name: agent-canvas
          image: {{ include "agent-canvas.image" . }}
          imagePullPolicy: {{ .Values.image.pullPolicy }}
          {{- with .Values.securityContext }}
          securityContext:
            {{- toYaml . | nindent 12 }}
          {{- end }}
          ports:
            - name: http
              containerPort: {{ .Values.config.port }}
              protocol: TCP
          env:
            - name: PORT
              value: {{ .Values.config.port | quote }}
            - name: AGENT_SERVER_PORT
              value: {{ .Values.config.agentServerPort | quote }}
            - name: AUTOMATION_PORT
              value: {{ .Values.config.automationPort | quote }}
            {{- if .Values.config.automationDbUrl }}
            - name: AUTOMATION_DB_URL
              value: {{ .Values.config.automationDbUrl | quote }}
            {{- end }}
            {{- if .Values.secrets.ohSecretKey.existingSecret }}
            - name: OH_SECRET_KEY
              valueFrom:
                secretKeyRef:
                  name: {{ .Values.secrets.ohSecretKey.existingSecret }}
                  key: {{ .Values.secrets.ohSecretKey.key }}
            {{- end }}
            {{- if .Values.secrets.sessionApiKey.existingSecret }}
            - name: OH_SESSION_API_KEYS_0
              valueFrom:
                secretKeyRef:
                  name: {{ .Values.secrets.sessionApiKey.existingSecret }}
                  key: {{ .Values.secrets.sessionApiKey.key }}
            {{- end }}
            {{- with .Values.config.extraEnv }}
            {{- toYaml . | nindent 12 }}
            {{- end }}
          {{- if .Values.probes.startup.enabled }}
          startupProbe:
            httpGet:
              path: {{ .Values.probes.startup.path }}
              port: http
            periodSeconds: {{ .Values.probes.startup.periodSeconds }}
            timeoutSeconds: {{ .Values.probes.startup.timeoutSeconds }}
            failureThreshold: {{ .Values.probes.startup.failureThreshold }}
          {{- end }}
          {{- if .Values.probes.liveness.enabled }}
          livenessProbe:
            httpGet:
              path: {{ .Values.probes.liveness.path }}
              port: http
            initialDelaySeconds: {{ .Values.probes.liveness.initialDelaySeconds }}
            periodSeconds: {{ .Values.probes.liveness.periodSeconds }}
            timeoutSeconds: {{ .Values.probes.liveness.timeoutSeconds }}
            failureThreshold: {{ .Values.probes.liveness.failureThreshold }}
          {{- end }}
          {{- if .Values.probes.readiness.enabled }}
          readinessProbe:
            httpGet:
              path: {{ .Values.probes.readiness.path }}
              port: http
            initialDelaySeconds: {{ .Values.probes.readiness.initialDelaySeconds }}
            periodSeconds: {{ .Values.probes.readiness.periodSeconds }}
            timeoutSeconds: {{ .Values.probes.readiness.timeoutSeconds }}
            failureThreshold: {{ .Values.probes.readiness.failureThreshold }}
          {{- end }}
          {{- with .Values.resources }}
          resources:
            {{- toYaml . | nindent 12 }}
          {{- end }}
          {{- if .Values.persistence.enabled }}
          volumeMounts:
            {{- range .Values.persistence.mounts }}
            - name: {{ include "agent-canvas.pvcClaimName" $ }}
              mountPath: {{ .mountPath }}
              {{- if .subPath }}
              subPath: {{ .subPath }}
              {{- end }}
            {{- end }}
          {{- end }}
      {{- with .Values.nodeSelector }}
      nodeSelector:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.tolerations }}
      tolerations:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.affinity }}
      affinity:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.topologySpreadConstraints }}
      topologySpreadConstraints:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- if and .Values.persistence.enabled .Values.persistence.existingClaim }}
      volumes:
        - name: {{ include "agent-canvas.pvcClaimName" . }}
          persistentVolumeClaim:
            claimName: {{ .Values.persistence.existingClaim }}
      {{- end }}
  {{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) }}
  volumeClaimTemplates:
    - metadata:
        name: {{ include "agent-canvas.pvcClaimName" . }}
        labels:
          {{- /* MUST use immutableLabels here, not the full label set.
                 volumeClaimTemplates is under STS.spec (not spec.template)
                 and is rejected by the apiserver on any diff, including
                 label churn from `appVersion` / chart `version` bumps. */}}
          {{- include "agent-canvas.immutableLabels" . | nindent 10 }}
        {{- with .Values.persistence.annotations }}
        annotations:
          {{- toYaml . | nindent 10 }}
        {{- end }}
      spec:
        accessModes:
          {{- toYaml .Values.persistence.accessModes | nindent 10 }}
        {{- if .Values.persistence.storageClassName }}
        storageClassName: {{ .Values.persistence.storageClassName | quote }}
        {{- end }}
        resources:
          requests:
            storage: {{ .Values.persistence.size | quote }}
  {{- end }}