|
| 1 | +apiVersion: apps/v1 |
| 2 | +kind: Deployment |
| 3 | +metadata: |
| 4 | + name: scalr-agent |
| 5 | + namespace: {{ .Release.Namespace | quote }} |
| 6 | + labels: |
| 7 | + {{- include "agent-job.labels" . | nindent 4 }} |
| 8 | + app.kubernetes.io/component: agent |
| 9 | +spec: |
| 10 | + replicas: {{ .Values.agent.replicaCount }} |
| 11 | + selector: |
| 12 | + matchLabels: |
| 13 | + {{- include "agent-job.selectorLabels" . | nindent 6 }} |
| 14 | + app.kubernetes.io/component: agent |
| 15 | + template: |
| 16 | + metadata: |
| 17 | + annotations: |
| 18 | + {{- with (merge (deepCopy .Values.global.podAnnotations) .Values.agent.podAnnotations) }} |
| 19 | + {{- toYaml . | nindent 8 }} |
| 20 | + {{- end }} |
| 21 | + {{- if not .Values.agent.tokenExistingSecret.name }} |
| 22 | + checksum/secrets: {{ include (print $.Template.BasePath "/secrets.yaml") . | sha256sum }} |
| 23 | + {{- end }} |
| 24 | + labels: |
| 25 | + {{- with .Values.global.podLabels }} |
| 26 | + {{- toYaml . | nindent 12 }} |
| 27 | + {{- end }} |
| 28 | + {{- with .Values.agent.podLabels }} |
| 29 | + {{- toYaml . | nindent 12 }} |
| 30 | + {{- end }} |
| 31 | + {{- include "agent-job.selectorLabels" . | nindent 8 }} |
| 32 | + app.kubernetes.io/component: agent |
| 33 | + spec: |
| 34 | + {{- with .Values.global.imagePullSecrets }} |
| 35 | + imagePullSecrets: |
| 36 | + {{- toYaml . | nindent 8 }} |
| 37 | + {{- end }} |
| 38 | + serviceAccountName: {{ include "agent-job.serviceAccountName" . }} |
| 39 | + automountServiceAccountToken: {{ .Values.serviceAccount.automountToken }} |
| 40 | + {{- $controllerPodSecurityContext := merge (deepCopy (default (dict) .Values.global.podSecurityContext)) (default (dict) .Values.agent.podSecurityContext) }} |
| 41 | + {{- if not (empty $controllerPodSecurityContext) }} |
| 42 | + securityContext: |
| 43 | + {{- toYaml $controllerPodSecurityContext | nindent 8 }} |
| 44 | + {{- end }} |
| 45 | + containers: |
| 46 | + - name: controller |
| 47 | + {{- $registry := .Values.global.imageRegistry }} |
| 48 | + {{- $image := .Values.agent.image }} |
| 49 | + {{- if $registry }} |
| 50 | + image: "{{ $registry }}/{{ $image.repository }}:{{ $image.tag | default .Chart.AppVersion }}" |
| 51 | + {{- else }} |
| 52 | + image: "{{ $image.repository }}:{{ $image.tag | default .Chart.AppVersion }}" |
| 53 | + {{- end }} |
| 54 | + imagePullPolicy: {{ $image.pullPolicy }} |
| 55 | + command: ["python", "-m", "tacoagent.cmd"] |
| 56 | + {{- with .Values.agent.controller.securityContext }} |
| 57 | + securityContext: |
| 58 | + {{- toYaml . | nindent 12 }} |
| 59 | + {{- end }} |
| 60 | + env: |
| 61 | + - name: SCALR_URL |
| 62 | + value: {{ .Values.agent.url | quote }} |
| 63 | + - name: SCALR_AGENT_TOKEN |
| 64 | + valueFrom: |
| 65 | + secretKeyRef: |
| 66 | + name: {{ .Values.agent.tokenExistingSecret.name | default (include "agent-job.fullname" .) }} |
| 67 | + key: {{ .Values.agent.tokenExistingSecret.key }} |
| 68 | + optional: false |
| 69 | + - name: SCALR_AGENT_NAME |
| 70 | + valueFrom: |
| 71 | + fieldRef: |
| 72 | + fieldPath: metadata.name |
| 73 | + - name: SCALR_AGENT_DEBUG |
| 74 | + value: {{ .Values.agent.debug | quote }} |
| 75 | + - name: SCALR_AGENT_LOG_FORMAT |
| 76 | + value: {{ .Values.agent.logFormat | quote }} |
| 77 | + - name: SCALR_AGENT_DATA_DIR |
| 78 | + value: {{ .Values.agent.dataDir | quote }} |
| 79 | + - name: SCALR_AGENT_CACHE_DIR |
| 80 | + value: {{ .Values.agent.cacheDir | quote }} |
| 81 | + - name: SCALR_AGENT_DRIVER |
| 82 | + value: "kubernetes-job" |
| 83 | + - name: SCALR_AGENT_KUBERNETES_JOB_TEMPLATE |
| 84 | + value: "scalr-agent-task" |
| 85 | + {{- $telemetry := .Values.otel -}} |
| 86 | + {{- if and $telemetry.enabled $telemetry.endpoint }} |
| 87 | + - name: SCALR_AGENT_OTLP_ENDPOINT |
| 88 | + value: {{ $telemetry.endpoint | quote }} |
| 89 | + {{- if $telemetry.metricsEnabled }} |
| 90 | + - name: SCALR_AGENT_OTLP_METRICS_ENABLED |
| 91 | + value: "true" |
| 92 | + {{- end }} |
| 93 | + {{- if $telemetry.tracesEnabled }} |
| 94 | + - name: SCALR_AGENT_OTLP_TRACES_ENABLED |
| 95 | + value: "true" |
| 96 | + {{- end }} |
| 97 | + {{- end }} |
| 98 | + {{- range $key, $value := .Values.agent.extraEnv }} |
| 99 | + - name: {{ $key }} |
| 100 | + value: {{ $value | quote }} |
| 101 | + {{- end }} |
| 102 | + {{- with .Values.agent.controller.extraEnv }} |
| 103 | + {{- toYaml . | nindent 12 }} |
| 104 | + {{- end }} |
| 105 | + {{- with .Values.agent.controller.extraEnvFrom }} |
| 106 | + envFrom: |
| 107 | + {{- toYaml . | nindent 12 }} |
| 108 | + {{- end }} |
| 109 | + resources: |
| 110 | + {{- toYaml .Values.agent.resources | nindent 12 }} |
| 111 | + volumeMounts: |
| 112 | + - name: data-dir |
| 113 | + mountPath: {{ .Values.agent.dataDir | quote }} |
| 114 | + - name: cache-dir |
| 115 | + mountPath: {{ .Values.agent.cacheDir | quote }} |
| 116 | + - name: tmp-dir |
| 117 | + mountPath: /tmp |
| 118 | + {{- with .Values.agent.nodeSelector }} |
| 119 | + nodeSelector: |
| 120 | + {{- toYaml . | nindent 8 }} |
| 121 | + {{- end }} |
| 122 | + {{- with .Values.agent.tolerations }} |
| 123 | + tolerations: |
| 124 | + {{- toYaml . | nindent 8 }} |
| 125 | + {{- end }} |
| 126 | + {{- with .Values.agent.affinity }} |
| 127 | + affinity: |
| 128 | + {{- toYaml . | nindent 8 }} |
| 129 | + {{- end }} |
| 130 | + volumes: |
| 131 | + # Note: Controllers have ephemeral data/cache volumes. They are not intended for real use, as agents |
| 132 | + # in controller mode do not perform actual workloads. |
| 133 | + - name: data-dir |
| 134 | + emptyDir: {} |
| 135 | + - name: cache-dir |
| 136 | + emptyDir: {} |
| 137 | + # Note: Default pod's /tmp may not be writable depending on securityContext settings. |
| 138 | + # It is more robust to mount a dedicated volume. |
| 139 | + - name: tmp-dir |
| 140 | + emptyDir: {} |
| 141 | + terminationGracePeriodSeconds: {{ .Values.agent.terminationGracePeriodSeconds }} |
0 commit comments