Files
apigateway-ocp/templates/apitraffic/apitraffic-deployment.yaml
2025-11-13 23:47:20 +08:00

229 lines
10 KiB
YAML

apiVersion: apps/v1
kind: Deployment
metadata:
name: "{{ include "gateway.fullname" . }}-apitraffic"
labels:
{{- include "gateway.labels" . | nindent 4 }}
app.kubernetes.io/component: apitraffic
spec:
{{- if not .Values.apitraffic.autoscaling.enabled }}
replicas: {{ .Values.apitraffic.replicaCount }}
{{- end }}
strategy:
{{- if eq (default .Values.global.updateStrategy.type .Values.apitraffic.updateStrategy.type) "RollingUpdate" }}
rollingUpdate:
maxSurge: {{ default .Values.global.updateStrategy.rollingUpdate.maxSurge .Values.apitraffic.updateStrategy.rollingUpdate.maxSurge }}
maxUnavailable: {{ default .Values.global.updateStrategy.rollingUpdate.maxUnavailable .Values.apitraffic.updateStrategy.rollingUpdate.maxUnavailable }}
{{- end }}
type: {{ default .Values.global.updateStrategy.type .Values.apitraffic.updateStrategy.type }}
selector:
matchLabels:
{{- include "gateway.selectorLabels" . | nindent 6 }}
app.kubernetes.io/component: apitraffic
{{- with .Values.apitraffic.podLabels }}
{{- toYaml . | nindent 6 }}
{{- end }}
template:
metadata:
{{- with .Values.apitraffic.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "gateway.selectorLabels" . | nindent 8 }}
app.kubernetes.io/component: apitraffic
{{- with .Values.apitraffic.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.global.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "gateway.apitraffic.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.apitraffic.podSecurityContext | nindent 8 }}
initContainers:
{{- if .Values.global.cassandra.enabled }}
- name: init-cassandra
image: {{ .Values.global.initContainers.image | quote }}
{{- with (first .Values.global.cassandra.hosts) }}
command: ["sh", "-c", "until nc -w 3 -v {{ .hostname }} 9042; do echo waiting for {{ .hostname }}; sleep 2; done;"]
{{- end }}
{{- with .Values.global.initContainers.resources }}
resources:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.global.initContainers.securityContext }}
securityContext:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- end }}
{{- if .Values.global.database.metrics.enabled }}
- name: init-mysql
image: {{ .Values.global.initContainers.image | quote }}
command: ["sh", "-c", "until nc -w 3 -v {{ tpl .Values.global.database.host . }} {{ .Values.global.database.port | int }}; do echo waiting for mysql; sleep 2; done;"]
{{- with .Values.global.initContainers.resources }}
resources:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.global.initContainers.securityContext }}
securityContext:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- end }}
- name: init-anm
image: {{ .Values.global.initContainers.image | quote }}
{{- if .Values.anm.hostname }}
command: ["sh", "-c", "until nc -w 3 -v {{ .Values.anm.hostname }}; do echo waiting for anm; sleep 2; done;"]
{{- else }}
command: ["sh", "-c", "until nc -w 3 -v {{ include "gateway.fullname" . }}-anm 8090; do echo waiting for anm; sleep 2; done;"]
{{- end }}
{{- with .Values.global.initContainers.resources }}
resources:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.global.initContainers.securityContext }}
securityContext:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.apitraffic.extraInitContainers }}
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.apitraffic.securityContext | nindent 12 }}
image: "{{ default .Values.global.defaultRegistry .Values.apitraffic.image.registry }}/{{ .Values.apitraffic.image.repository }}:{{ .Values.apitraffic.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.global.imagePullPolicy }}
ports:
- containerPort: {{ .Values.apitraffic.service.ports.traffic.port }}
protocol: {{ .Values.apitraffic.service.ports.traffic.protocol }}
{{- with .Values.apitraffic.livenessProbe }}
livenessProbe:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.apitraffic.readinessProbe }}
readinessProbe:
{{- toYaml . | nindent 12 }}
{{- end }}
resources:
{{- toYaml .Values.apitraffic.resources | nindent 12 }}
env:
{{- with .Values.apitraffic.extraEnvVars }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- if .Values.apitraffic.FIPS.enabled }}
- name: EMT_FIPS_MODE
value: {{ .Values.apitraffic.FIPS.enabled | quote }}
{{- end }}
{{- if .Values.apitraffic.jvmHeapSize }}
- name: EMT_HEAP_SIZE_MB
value: {{ .Values.apitraffic.jvmHeapSize | quote }}
{{- end }}
{{- if .Values.apitraffic.logs.trace.level }}
- name: EMT_TRACE_LEVEL
value: {{ .Values.apitraffic.logs.trace.level | quote }}
{{- end }}
{{- if .Values.apitraffic.logs.trace.disk }}
- name: APIGW_LOG_TRACE_TO_FILE
value: {{ .Values.apitraffic.logs.trace.disk | quote }}
{{- end }}
- name: APIGW_LOG_TRACE_JSON_TO_STDOUT
value: {{ default .Values.apitraffic.logs.trace.stdoutJSON false | quote }}
{{- if .Values.apitraffic.logs.opentraffic.output | quote}}
- name: APIGW_LOG_OPENTRAFFIC_OUTPUT
value: {{ .Values.apitraffic.logs.opentraffic.output | quote }}
{{- end }}
{{- if .Values.global.domainkeypassphrase }}
- name: DOMAIN_KEY_PASSPHRASE
valueFrom:
secretKeyRef:
name: {{ include "gateway.domainkeypassphrase.secretName" . }}
key: passphrase
{{- end }}
{{- if .Values.global.database.metrics.enabled }}
- name: METRICS_DB_URL
value: {{ tpl .Values.global.database.metrics.url . | quote }}
- name: METRICS_DB_USERNAME
valueFrom:
secretKeyRef:
name: {{ include "gateway.metrics-db.secretName" . }}
key: {{ with .Values.global.database.metrics.existingSecret.keyMapping }}{{- default "username" .username }}{{- else -}}"username"{{- end }}
- name: METRICS_DB_PASS
valueFrom:
secretKeyRef:
name: {{ include "gateway.metrics-db.secretName" . }}
key: {{ with .Values.global.database.metrics.existingSecret.keyMapping }}{{- default "password" .password }}{{- else -}}"password"{{- end }}
{{- end }}
- name: GROUP_ID
value: {{ .Values.apitraffic.groupId }}
{{- if .Values.global.domainId }}
- name: DOMAIN_ID
value: {{ .Values.global.domainId }}
{{- end }}
{{- if .Values.global.cassandra.enabled }}
{{- range .Values.global.cassandra.hosts }}
- name: {{ .variable }}
value: {{ .hostname | quote }}
{{- end }}
- name: CASS_PORT
value: {{ .Values.global.cassandra.port | quote }}
- name: CASS_KEYSPACE
value: {{ tpl .Values.global.cassandra.keyspace . | quote }}
- name: CASS_TKEYSPACE
value: {{ tpl .Values.global.cassandra.tkeyspace . | quote }}
- name: CASS_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "gateway.cassandra.secretName" . }}
key: {{ with .Values.global.cassandra.existingSecret.keyMapping }}{{- default "password" .password }}{{- else -}}"password"{{- end }}
- name: CASS_USERNAME
valueFrom:
secretKeyRef:
name: {{ include "gateway.cassandra.secretName" . }}
key: {{ with .Values.global.cassandra.existingSecret.keyMapping }}{{- default "username" .username }}{{- else -}}"username"{{- end }}
{{- end }}
{{- if .Values.apitraffic.image.generalConditions }}
- name: ACCEPT_GENERAL_CONDITIONS
value: {{ .Values.apitraffic.image.generalConditions.accept | quote }}
{{- end }}
{{- if .Values.anm.hostname }}
- name: EMT_ANM_HOSTS
value: {{ .Values.anm.hostname | quote }}
{{- else }}
- name: EMT_ANM_HOSTS
value: "{{ include "gateway.fullname" . }}-anm:8090"
{{- end }}
{{- if .Values.apitraffic.extraVolumeMounts }}
volumeMounts:
{{- if .Values.apitraffic.license }}
- name: license
mountPath: "/opt/Axway/apigateway/conf/licenses/license.lic"
subPath: "license.lic"
{{- end }}
{{- toYaml ( .Values.apitraffic.extraVolumeMounts ) | nindent 12 }}
{{- end }}
{{- if .Values.apitraffic.extraVolumes }}
volumes:
{{- if .Values.apitraffic.license }}
- name: license
configMap:
name: {{ .Release.Name }}-apitraffic-license-config
{{- end }}
{{ toYaml ( .Values.apitraffic.extraVolumes ) | indent 8 }}
{{- end }}
{{- with .Values.apitraffic.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.apitraffic.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.apitraffic.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}