|
| 1 | +apiVersion: apps/v1 |
| 2 | +kind: Deployment |
| 3 | +metadata: |
| 4 | + name: {{ .Release.Name }} |
| 5 | + namespace: {{ .Release.Namespace }} |
| 6 | +spec: |
| 7 | + replicas: {{ .Values.replicaCount }} |
| 8 | + selector: |
| 9 | + matchLabels: |
| 10 | + service: {{ .Release.Name }} |
| 11 | + template: |
| 12 | + metadata: |
| 13 | + labels: |
| 14 | + service: {{ .Release.Name }} |
| 15 | + spec: |
| 16 | + serviceAccountName: {{ .Release.Name }} |
| 17 | + containers: |
| 18 | + - name: opserver |
| 19 | + image: "{{ .Values.images.containerRegistry }}/{{ .Values.images.opserver.name }}:{{ .Values.images.opserver.tag }}" |
| 20 | + resources: |
| 21 | + requests: |
| 22 | + memory: {{ .Values.requests.memory }} |
| 23 | + cpu: {{ .Values.requests.cpu }} |
| 24 | + limits: |
| 25 | + memory: {{ .Values.limits.memory }} |
| 26 | + securityContext: |
| 27 | + allowPrivilegeEscalation: false |
| 28 | + capabilities: |
| 29 | + drop: |
| 30 | + - ALL |
| 31 | + readOnlyRootFilesystem: true |
| 32 | + runAsNonRoot: true |
| 33 | + volumeMounts: |
| 34 | + - name: writable-tmp #need our own read-write enabled temp directory because aspnet spills large requests over to disk |
| 35 | + mountPath: /mnt/tmp |
| 36 | + imagePullPolicy: {{ .Values.image.pullPolicy }} |
| 37 | + ports: |
| 38 | + - containerPort: {{ .Values.kestrel.endPoints.http.containerPort }} |
| 39 | + livenessProbe: |
| 40 | + httpGet: |
| 41 | + path: /health-checks/live |
| 42 | + port: {{ .Values.kestrel.endPoints.http.containerPort }} |
| 43 | + initialDelaySeconds: 10 |
| 44 | + periodSeconds: 10 |
| 45 | + timeoutSeconds: 2 |
| 46 | + failureThreshold: 3 |
| 47 | + readinessProbe: |
| 48 | + httpGet: |
| 49 | + path: /health-checks/ready |
| 50 | + port: {{ .Values.kestrel.endPoints.http.containerPort }} |
| 51 | + initialDelaySeconds: 10 |
| 52 | + periodSeconds: 1 |
| 53 | + successThreshold: 3 |
| 54 | + volumeMounts: |
| 55 | + - name: writable-tmp |
| 56 | + mountPath: /mnt/tmp |
| 57 | + |
| 58 | + env: |
| 59 | + - name: NODE_IP |
| 60 | + valueFrom: |
| 61 | + fieldRef: |
| 62 | + fieldPath: status.hostIP |
| 63 | + |
| 64 | + - name: DOTNET_EnableDiagnostics |
| 65 | + value: "0" |
| 66 | + |
| 67 | + - name: ASPNETCORE_ENVIRONMENT |
| 68 | + value: {{ .Values.aspnetcoreEnvironment }} |
| 69 | + - name: PRODUCT |
| 70 | + value: {{ .Values.product }} |
| 71 | + |
| 72 | + - name: EXCEPTIONAL__STORE__APPLICATIONNAME |
| 73 | + value: "{{ .Release.Name }}" |
| 74 | + - name: EXCEPTIONAL__STORE__TYPE |
| 75 | + value: "{{ .Values.exceptional.store.type }}" |
| 76 | + |
| 77 | + - name: DATADOG__AGENTHOST |
| 78 | + value: "{{- if eq .Values.datadog.agentHost "127.0.0.1"}}$(NODE_IP){{- else}}{{ .Values.datadog.agentHost }}{{- end}}" |
| 79 | + - name: DATADOG__AGENTPORT |
| 80 | + value: "{{ .Values.datadog.agentPort }}" |
| 81 | + |
| 82 | + # this exact variable is required for our datadog configuration to work with tracing / APM |
| 83 | + - name: DD_AGENT_HOST |
| 84 | + value: "{{- if eq .Values.datadog.agentHost "127.0.0.1"}}$(NODE_IP){{- else}}{{ .Values.datadog.agentHost }}{{- end}}" |
| 85 | + |
| 86 | + - name: DD_RUNTIME_METRICS_ENABLED |
| 87 | + value: "true" |
| 88 | + |
| 89 | + - name: DD_SERVICE |
| 90 | + value: "opserver" |
| 91 | + |
| 92 | + - name: KESTREL__ENDPOINTS__HTTP__URL |
| 93 | + value: "http://0.0.0.0:{{ .Values.kestrel.endPoints.http.containerPort }}/" |
| 94 | + |
| 95 | + - name: TMPDIR #tell OS to use our read-write volume mount as its temp directory |
| 96 | + value: "/mnt/tmp" |
| 97 | + |
| 98 | + - name: SQL_EXCEPTIONAL_SERVERNAME |
| 99 | + valueFrom: |
| 100 | + secretKeyRef: |
| 101 | + name: {{ .Values.sqlExternalSecret.targetName }} |
| 102 | + key: exceptionalServername |
| 103 | + - name: SQL_USERNAME |
| 104 | + valueFrom: |
| 105 | + secretKeyRef: |
| 106 | + name: {{ .Values.sqlExternalSecret.targetName }} |
| 107 | + key: exceptionalUsername |
| 108 | + - name: SQL_PASSWORD |
| 109 | + valueFrom: |
| 110 | + secretKeyRef: |
| 111 | + name: {{ .Values.sqlExternalSecret.targetName }} |
| 112 | + key: exceptionalPassword |
| 113 | + |
| 114 | + {{- if hasKey .Values.opserverSettings "sql" }} |
| 115 | + - name: Modules__Sql__defaultConnectionString |
| 116 | + value: "Server=$(SQL_EXCEPTIONAL_SERVERNAME);Database=Local.Exceptions;User ID=$(SQL_USERNAME);Password=$(SQL_PASSWORD);" |
| 117 | + {{- range $i, $instance := .Values.opserverSettings.sql }} |
| 118 | + - name: Modules__Sql__instances__{{ $i }}__name |
| 119 | + value: "{{ $instance.name }}" |
| 120 | + {{- end }} |
| 121 | + {{- end }} |
| 122 | + |
| 123 | + {{- if hasKey .Values.opserverSettings "exceptions" }} |
| 124 | + {{- range $i, $instance := .Values.opserverSettings.exceptions }} |
| 125 | + - name: Modules__Exceptions__stores__{{ $i }}__connectionString |
| 126 | + value: "Server={{ $instance.serverName}};Database={{ $instance.database}};User ID=$(SQL_USERNAME);Password=$(SQL_PASSWORD);" |
| 127 | + {{- end }} |
| 128 | + {{- end }} |
| 129 | + |
| 130 | + topologySpreadConstraints: |
| 131 | + - maxSkew: 1 |
| 132 | + topologyKey: kubernetes.io/hostname |
| 133 | + whenUnsatisfiable: ScheduleAnyway |
| 134 | + labelSelector: |
| 135 | + matchLabels: |
| 136 | + service: {{ .Release.Name }} |
| 137 | + matchLabelKeys: |
| 138 | + - pod-template-hash |
| 139 | + |
| 140 | + {{- if and (hasKey .Values "nodeScheduling") (hasKey .Values.nodeScheduling "nodeSelectorLabel")}} |
| 141 | + nodeSelector: |
| 142 | + {{- range .Values.nodeScheduling.nodeSelectorLabel }} |
| 143 | + {{ .name }}: {{ .value | quote }} |
| 144 | + {{- end }} |
| 145 | + {{- end }} |
| 146 | + |
| 147 | + {{- if and (hasKey .Values "nodeScheduling") (hasKey .Values.nodeScheduling "tolerations")}} |
| 148 | + tolerations: |
| 149 | + {{- range .Values.nodeScheduling.tolerations }} |
| 150 | + - key: {{ .key }} |
| 151 | + operator: {{ .operator }} |
| 152 | + value: {{ .value | quote }} |
| 153 | + effect: {{ .effect }} |
| 154 | + {{- end }} |
| 155 | + {{- end }} |
| 156 | + |
| 157 | + restartPolicy: Always |
| 158 | + imagePullSecrets: |
| 159 | + - name: "{{ .Values.image.pullSecretName }}" |
| 160 | + volumes: |
| 161 | + - name: data-volume |
| 162 | + emptyDir: {} |
| 163 | + - name: log-volume |
| 164 | + emptyDir: {} |
| 165 | + volumes: |
| 166 | + - name: writable-tmp |
| 167 | + emptyDir: {} |
0 commit comments