summaryrefslogtreecommitdiffhomepage
path: root/cmd/k8s-operator/deploy/chart/templates/deployment.yaml
blob: feffd03a39cf1e149439474409d2f7bddee79de9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# Copyright (c) Tailscale Inc & contributors
# SPDX-License-Identifier: BSD-3-Clause

apiVersion: apps/v1
kind: Deployment
metadata:
  name: operator
  namespace: {{ .Release.Namespace }}
spec:
  replicas: 1
  strategy:
    type: Recreate
  selector:
    matchLabels:
      app: operator
  template:
    metadata:
      {{- with .Values.operatorConfig.podAnnotations }}
      annotations:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      labels:
        app: operator
        {{- with .Values.operatorConfig.podLabels }}
        {{- toYaml . | nindent 8 }}
        {{- end }}
    spec:
      {{- with .Values.imagePullSecrets }}
      imagePullSecrets:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      serviceAccountName: operator
      {{- with .Values.operatorConfig.podSecurityContext }}
      securityContext:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      volumes:
        {{- if .Values.oauthSecretVolume }}
        - name: oauth
          {{- toYaml .Values.oauthSecretVolume | nindent 10 }}
        {{- else if .Values.oauth.audience }}
        - name: oidc-jwt
          projected:
            defaultMode: 420
            sources:
            - serviceAccountToken:
                audience: {{ .Values.oauth.audience }}
                expirationSeconds: 3600
                path: token
        {{- else }}
        - name: oauth
          secret:
            secretName: operator-oauth
        {{- end }}
      containers:
        - name: operator
          {{- with .Values.operatorConfig.securityContext }}
          securityContext:
            {{- toYaml . | nindent 12 }}
          {{- end }}
          {{- with .Values.operatorConfig.resources }}
          resources:
            {{- toYaml . | nindent 12 }}
          {{- end }}
          {{- $operatorTag:= printf ":%s" ( .Values.operatorConfig.image.tag | default .Chart.AppVersion )}}
          image: {{ coalesce .Values.operatorConfig.image.repo .Values.operatorConfig.image.repository }}{{- if .Values.operatorConfig.image.digest -}}{{ printf "@%s" .Values.operatorConfig.image.digest}}{{- else -}}{{ printf "%s" $operatorTag }}{{- end }}
          imagePullPolicy: {{ .Values.operatorConfig.image.pullPolicy }}
          env:
            - name: OPERATOR_INITIAL_TAGS
              value: {{ join "," .Values.operatorConfig.defaultTags }}
            - name: OPERATOR_HOSTNAME
              value: {{ .Values.operatorConfig.hostname }}
            - name: OPERATOR_SECRET
              value: operator
            - name: OPERATOR_LOGGING
              value: {{ .Values.operatorConfig.logging }}
            - name: OPERATOR_NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
            - name: OPERATOR_LOGIN_SERVER
              value: {{ .Values.loginServer }}
            - name: OPERATOR_INGRESS_CLASS_NAME
              value: {{ .Values.ingressClass.name }}
            {{- if .Values.oauthSecretVolume }}
            - name: CLIENT_ID_FILE
              value: /oauth/client_id
            - name: CLIENT_SECRET_FILE
              value: /oauth/client_secret
            {{- else if .Values.oauth.audience }}
            - name: CLIENT_ID
              value: {{ .Values.oauth.clientId }}
            {{- else }}
            - name: CLIENT_ID_FILE
              value: /oauth/client_id
            - name: CLIENT_SECRET_FILE
              value: /oauth/client_secret
            {{- end }}
            {{- $proxyTag := printf ":%s" ( .Values.proxyConfig.image.tag | default .Chart.AppVersion )}}
            - name: PROXY_IMAGE
              value: {{ coalesce .Values.proxyConfig.image.repo .Values.proxyConfig.image.repository }}{{- if .Values.proxyConfig.image.digest -}}{{ printf "@%s" .Values.proxyConfig.image.digest}}{{- else -}}{{ printf "%s" $proxyTag }}{{- end }}
            - name: PROXY_TAGS
              value: {{ .Values.proxyConfig.defaultTags }}
            - name: APISERVER_PROXY
              value: "{{ .Values.apiServerProxyConfig.mode }}"
            - name: PROXY_FIREWALL_MODE
              value: {{ .Values.proxyConfig.firewallMode }}
            {{- if .Values.proxyConfig.defaultProxyClass }}
            - name: PROXY_DEFAULT_CLASS
              value: {{ .Values.proxyConfig.defaultProxyClass }}
            {{- end }}
            - name: POD_NAME
              valueFrom:
                fieldRef:
                  fieldPath: metadata.name
            - name: POD_UID
              valueFrom:
                fieldRef:
                  fieldPath: metadata.uid
            {{- with .Values.operatorConfig.extraEnv }}
            {{- toYaml . | nindent 12 }}
            {{- end }}
          volumeMounts:
            {{- if .Values.oauthSecretVolume }}
            - name: oauth
              mountPath: /oauth
              readOnly: true
            {{- else if .Values.oauth.audience }}
            - name: oidc-jwt
              mountPath: /var/run/secrets/tailscale/serviceaccount
              readOnly: true
            {{- else }}
            - name: oauth
              mountPath: /oauth
              readOnly: true
            {{- end }}
      {{- with .Values.operatorConfig.nodeSelector }}
      nodeSelector:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.operatorConfig.affinity }}
      affinity:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.operatorConfig.tolerations }}
      tolerations:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.operatorConfig.priorityClassName }}
      priorityClassName: {{ . }}
      {{- end }}