# SPDX-FileCopyrightText: 2021-present Open Networking Foundation <info@opennetworking.org>
#
# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0

apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ include "aether-roc-websocket.fullname" . }}
  namespace: {{ .Release.Namespace }}
  labels:
    {{- include "aether-roc-websocket.labels" . | nindent 4 }}
spec:
  replicas: {{ .Values.replicaCount }}
  selector:
    matchLabels:
      name: {{ template "aether-roc-websocket.fullname" . }}
      app: aether
      type: ws
      resource: {{ template "aether-roc-websocket.fullname" . }}
      {{- include "aether-roc-websocket.selectorLabels" . | nindent 6 }}
  template:
    metadata:
      labels:
        name: {{ template "aether-roc-websocket.fullname" . }}
        app: aether
        type: ws
        resource: {{ template "aether-roc-websocket.fullname" . }}
        {{- include "aether-roc-websocket.selectorLabels" . | nindent 8 }}
    spec:
      serviceAccountName: aether-roc-websocket
      securityContext:
        {{- toYaml .Values.podSecurityContext | nindent 8 }}
      {{- with .Values.imagePullSecrets }}
      imagePullSecrets:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      containers:
        - name: {{ .Chart.Name }}
          image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
          imagePullPolicy: {{ .Values.image.pullPolicy }}
          env:
            - name: NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
          args: []
          ports:
            - name: http
              containerPort: {{ .Values.port }}
          startupProbe:
            tcpSocket:
              port: {{ .Values.port }}
            periodSeconds: 5
            failureThreshold: 60
          readinessProbe:
            tcpSocket:
              port: {{ .Values.port }}
            initialDelaySeconds: 10
            periodSeconds: 10
          livenessProbe:
            tcpSocket:
              port: {{ .Values.port }}
            initialDelaySeconds: 10
            periodSeconds: 10
          resources:
            {{- toYaml .Values.resources | nindent 12 }}
          securityContext: {}
      volumes:
        - name: secret
          secret:
            secretName: {{ template "aether-roc-websocket.fullname" . }}-secret
        - name: config
          configMap:
            name: {{ template "aether-roc-websocket.fullname" . }}-config
      {{- with .Values.nodeSelector }}
    nodeSelector:
      {{- toYaml . | nindent 8 }}
    {{- end }}
    {{- with .Values.affinity }}
    affinity:
      {{- toYaml . | nindent 8 }}
    {{- end }}
    {{- with .Values.tolerations }}
    tolerations:
      {{- toYaml . | nindent 8 }}
    {{- end }}
