Skip to content

Secure, Fast, and Extensible Sandbox runtime for AI agents.

7.8 KB
Raw Blame
{{- $metrics := .Values.controller.metrics | default dict -}}
apiVersion: apps/v1
kind: Deployment
metadata:
  name: opensandbox-controller-manager
  namespace: {{ include "opensandbox.namespace" . }}
  labels:
    {{- include "opensandbox.labels" . | nindent 4 }}
    app.kubernetes.io/component: controller-manager
spec:
  replicas: {{ .Values.controller.replicaCount }}
  selector:
    matchLabels:
      {{- include "opensandbox.selectorLabels" . | nindent 6 }}
  template:
    metadata:
      annotations:
        kubectl.kubernetes.io/default-container: manager
        {{- if .Values.controller.snapshot.imageCommitterPodTemplate }}
        checksum/image-committer-pod-template: {{ include (print $.Template.BasePath "/image-committer-pod-template.yaml") . | sha256sum }}
        {{- end }}
        {{- with .Values.controller.podAnnotations }}
        {{- toYaml . | nindent 8 }}
        {{- end }}
      labels:
        {{- include "opensandbox.selectorLabels" . | nindent 8 }}
        {{- with .Values.controller.podLabels }}
        {{- toYaml . | nindent 8 }}
        {{- end }}
    spec:
      {{- with .Values.imagePullSecrets }}
      imagePullSecrets:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      serviceAccountName: {{ include "opensandbox.serviceAccountName" . }}
      {{- with .Values.controller.podSecurityContext }}
      securityContext:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.controller.priorityClassName }}
      priorityClassName: {{ . }}
      {{- end }}
      {{- with .Values.extraInitContainers }}
      initContainers:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      containers:
      - name: manager
        image: {{ include "opensandbox.controllerImage" . }}
        imagePullPolicy: {{ include "opensandbox.imagePullPolicy" . }}
        command:
        - /workspace/server
        args:
        {{- $healthPort := .Values.controller.livenessProbe.httpGet.port }}
        {{- if .Values.controller.leaderElection.enabled }}
        - --leader-elect
        {{- end }}
        - --health-probe-bind-address=:{{ $healthPort }}
        - --zap-log-level={{ .Values.controller.logLevel }}
        {{- if $metrics.enabled }}
        - --metrics-bind-address=:{{ $metrics.port | default 8080 }}
        - --metrics-secure={{ $metrics.secure | default false }}
        {{- end }}
        {{- if and .Values.controller.kubeClient (gt (int .Values.controller.kubeClient.qps) 0) }}
        - --kube-client-qps={{ .Values.controller.kubeClient.qps }}
        {{- end }}
        {{- if and .Values.controller.kubeClient (gt (int .Values.controller.kubeClient.burst) 0) }}
        - --kube-client-burst={{ .Values.controller.kubeClient.burst }}
        {{- end }}
        {{- if .Values.controller.snapshot.imageCommitterImage }}
        - --image-committer-image={{ .Values.controller.snapshot.imageCommitterImage }}
        {{- end }}
        {{- if .Values.controller.snapshot.imageCommitterPodTemplate }}
        - --image-committer-pod-template-file=/etc/opensandbox/image-committer/pod-template.yaml
        {{- end }}
        {{- if .Values.controller.snapshot.containerdSocketPath }}
        - --containerd-socket-path={{ .Values.controller.snapshot.containerdSocketPath }}
        {{- end }}
        {{- if .Values.controller.snapshot.commitJobTimeout }}
        - --commit-job-timeout={{ .Values.controller.snapshot.commitJobTimeout }}
        {{- end }}
        {{- if .Values.controller.snapshot.registry }}
        - --snapshot-registry={{ .Values.controller.snapshot.registry }}
        {{- end }}
        {{- if .Values.controller.snapshot.imageURITemplate }}
        - {{ printf "--snapshot-image-uri-template=%s" .Values.controller.snapshot.imageURITemplate | quote }}
        {{- end }}
        {{- if .Values.controller.snapshot.registryInsecure }}
        - --snapshot-registry-insecure={{ .Values.controller.snapshot.registryInsecure }}
        {{- end }}
        {{- if .Values.controller.snapshot.snapshotPushSecret }}
        - --snapshot-push-secret={{ .Values.controller.snapshot.snapshotPushSecret }}
        {{- end }}
        {{- if .Values.controller.snapshot.imageCommitterPullSecret }}
        - --image-committer-pull-secret={{ .Values.controller.snapshot.imageCommitterPullSecret }}
        {{- end }}
        {{- if .Values.controller.snapshot.resumePullSecret }}
        - --resume-pull-secret={{ .Values.controller.snapshot.resumePullSecret }}
        {{- end }}
        ports:
        - name: health
          containerPort: {{ .Values.controller.livenessProbe.httpGet.port }}
          protocol: TCP
        {{- if $metrics.enabled }}
        - name: metrics
          containerPort: {{ $metrics.port | default 8080 }}
          protocol: TCP
        {{- end }}
        {{- with .Values.controller.containerSecurityContext }}
        securityContext:
          {{- toYaml . | nindent 10 }}
        {{- end }}
        {{- if .Values.controller.livenessProbe.enabled }}
        livenessProbe:
          httpGet:
            path: {{ .Values.controller.livenessProbe.httpGet.path }}
            port: {{ .Values.controller.livenessProbe.httpGet.port }}
          initialDelaySeconds: {{ .Values.controller.livenessProbe.initialDelaySeconds }}
          periodSeconds: {{ .Values.controller.livenessProbe.periodSeconds }}
          timeoutSeconds: {{ .Values.controller.livenessProbe.timeoutSeconds }}
          successThreshold: {{ .Values.controller.livenessProbe.successThreshold }}
          failureThreshold: {{ .Values.controller.livenessProbe.failureThreshold }}
        {{- end }}
        {{- if .Values.controller.readinessProbe.enabled }}
        readinessProbe:
          httpGet:
            path: {{ .Values.controller.readinessProbe.httpGet.path }}
            port: {{ .Values.controller.readinessProbe.httpGet.port }}
          initialDelaySeconds: {{ .Values.controller.readinessProbe.initialDelaySeconds }}
          periodSeconds: {{ .Values.controller.readinessProbe.periodSeconds }}
          timeoutSeconds: {{ .Values.controller.readinessProbe.timeoutSeconds }}
          successThreshold: {{ .Values.controller.readinessProbe.successThreshold }}
          failureThreshold: {{ .Values.controller.readinessProbe.failureThreshold }}
        {{- end }}
        resources:
          {{- toYaml .Values.controller.resources | nindent 10 }}
        env:
        - name: POD_NAMESPACE
          valueFrom:
            fieldRef:
              fieldPath: metadata.namespace
        {{- if .Values.extraEnv }}
        {{- toYaml .Values.extraEnv | nindent 8 }}
        {{- end }}
        {{- if or .Values.controller.snapshot.imageCommitterPodTemplate .Values.extraVolumeMounts }}
        volumeMounts:
        {{- if .Values.controller.snapshot.imageCommitterPodTemplate }}
        - name: image-committer-pod-template
          mountPath: /etc/opensandbox/image-committer
          readOnly: true
        {{- end }}
        {{- with .Values.extraVolumeMounts }}
        {{- toYaml . | nindent 8 }}
        {{- end }}
        {{- end }}
      {{- with .Values.extraContainers }}
      {{- toYaml . | nindent 6 }}
      {{- end }}
      {{- if or .Values.controller.snapshot.imageCommitterPodTemplate .Values.extraVolumes }}
      volumes:
      {{- if .Values.controller.snapshot.imageCommitterPodTemplate }}
      - name: image-committer-pod-template
        configMap:
          name: {{ include "opensandbox.imageCommitterPodTemplateName" . }}
      {{- end }}
      {{- with .Values.extraVolumes }}
      {{- toYaml . | nindent 6 }}
      {{- end }}
      {{- end }}
      {{- with .Values.controller.nodeSelector }}
      nodeSelector:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.controller.affinity }}
      affinity:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.controller.tolerations }}
      tolerations:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      terminationGracePeriodSeconds: 10