-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathdeployment-server.yaml
More file actions
176 lines (172 loc) · 6.47 KB
/
Copy pathdeployment-server.yaml
File metadata and controls
176 lines (172 loc) · 6.47 KB
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
{{- if .Values.server }}
{{- if ne .Values.server.enabled false }}
{{- $nm := include "opal.serverName" . | quote }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ $nm }}
labels:
{{- include "opal.serverLabels" . | nindent 4 }}
spec:
replicas: {{ .Values.server.replicas }}
selector:
matchLabels:
{{- include "opal.serverSelectorLabels" . | nindent 6 }}
template:
metadata:
labels:
{{- include "opal.serverLabels" . | nindent 8 }}
spec:
{{- with .Values.image.server.pullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if or .Values.openshift.enabled .Values.server.securityContext }}
securityContext:
{{- if .Values.server.securityContext }}
{{- toYaml .Values.server.securityContext | nindent 8 }}
{{- else if .Values.openshift.enabled }}
{{- toYaml .Values.openshift.securityContext | nindent 8 }}
{{- end }}
{{- end }}
{{- if .Values.e2e }}
volumes:
- name: e2e
emptyDir: {}
- name: policy-repo-data
configMap:
name: policy-repo-data
defaultMode: 0755
{{- else if .Values.openshift.enabled }}
volumes:
- name: jwks-dir
emptyDir: {}
{{- end }}
{{- if .Values.e2e }}
initContainers:
- name: git-init
image: {{ include "opal.serverImage" . | quote }}
imagePullPolicy: IfNotPresent
{{- if or .Values.openshift.enabled .Values.server.containerSecurityContext }}
securityContext:
{{- if .Values.server.containerSecurityContext }}
{{- toYaml .Values.server.containerSecurityContext | nindent 12 }}
{{- else if .Values.openshift.enabled }}
{{- toYaml .Values.openshift.containerSecurityContext | nindent 12 }}
{{- end }}
{{- end }}
volumeMounts:
- mountPath: /opt/e2e
name: e2e
- mountPath: /opt/e2e/policy-repo-data
name: policy-repo-data
readOnly: true
command:
- '/bin/sh'
- '-c'
- |
set -x
set -e
git init --bare /opt/e2e/policy-repo.git
git clone /opt/e2e/policy-repo.git /opt/e2e/policy-repo-working
cp /opt/e2e/policy-repo-data/*.* /opt/e2e/policy-repo-working
cd /opt/e2e/policy-repo-working
git config user.email "opal@opal.ac"
git config user.name "Opal Bot"
git add .
git commit -am 'chore: initial'
git push
echo ">>>> HEAD: $(git rev-parse --short HEAD) <<<<"
{{- end }}
containers:
- name: opal-server
image: {{ include "opal.serverImage" . | quote }}
imagePullPolicy: {{ .Values.server.imagePullPolicy | default "IfNotPresent" | quote }}
{{- if or .Values.openshift.enabled .Values.server.containerSecurityContext }}
securityContext:
{{- if .Values.server.containerSecurityContext }}
{{- toYaml .Values.server.containerSecurityContext | nindent 12 }}
{{- else if .Values.openshift.enabled }}
{{- toYaml .Values.openshift.containerSecurityContext | nindent 12 }}
{{- end }}
{{- end }}
{{- if .Values.e2e }}
volumeMounts:
- mountPath: /opt/e2e/policy-repo-data
name: policy-repo-data
readOnly: true
- mountPath: /opt/e2e
name: e2e
{{- else if .Values.openshift.enabled }}
volumeMounts:
- mountPath: /opal/jwks_dir
name: jwks-dir
{{- end }}
ports:
- name: http
containerPort: {{ .Values.server.port }}
protocol: TCP
env:
- name: OPAL_POLICY_REPO_URL
value: {{ .Values.server.policyRepoUrl | quote }}
- name: OPAL_POLICY_REPO_POLLING_INTERVAL
value: {{ .Values.server.pollingInterval | quote }}
{{- if .Values.server.policyRepoClonePath }}
- name: OPAL_POLICY_REPO_CLONE_PATH
value: {{ .Values.server.policyRepoClonePath | quote }}
{{- end }}
{{- if .Values.server.policyRepoMainBranch }}
- name: OPAL_POLICY_REPO_MAIN_BRANCH
value: {{ .Values.server.policyRepoMainBranch | quote }}
{{- end }}
- name: UVICORN_NUM_WORKERS
value: {{ .Values.server.uvicornWorkers | quote }}
{{- if or .Values.server.dataConfigSources.external_source_url (and .Values.server.dataConfigSources.config .Values.server.dataConfigSources.config.entries) }}
- name: OPAL_DATA_CONFIG_SOURCES
value: {{ .Values.server.dataConfigSources | toRawJson | squote }}
{{- end}}
{{- if .Values.server.broadcastUri }}
- name: OPAL_BROADCAST_URI
value: {{ .Values.server.broadcastUri | quote }}
{{- else if .Values.server.broadcastPgsql }}
- name: OPAL_BROADCAST_URI
value: 'postgres://postgres:postgres@{{ include "opal.pgsqlName" . }}:5432/postgres'
{{- end }}
{{- if .Values.server.extraEnv }}
{{- range $name, $value := .Values.server.extraEnv }}
- name: {{ $name }}
value: {{ $value | quote }}
{{- end }}
{{- end }}
{{- if or .Values.server.secrets .Values.server.policyRepoSshKey }}
envFrom:
{{- range $name := .Values.server.secrets }}
- secretRef:
name: {{ $name }}
{{- end }}
{{- if .Values.server.policyRepoSshKey }}
- secretRef:
name: {{ include "opal.envSecretsName" . }}
{{- end }}
{{- end }}
readinessProbe:
httpGet:
path: /healthcheck
port: http
failureThreshold: 5
initialDelaySeconds: 5
timeoutSeconds: 10
periodSeconds: 15
livenessProbe:
httpGet:
path: /healthcheck
port: http
failureThreshold: 5
timeoutSeconds: 10
periodSeconds: 30
{{- if .Values.server.resources }}
resources:
{{- toYaml .Values.server.resources | nindent 12 }}
{{- end }}
{{- end }}
{{- end }}