apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ .Chart.Name }}
spec:
  selector:
    matchLabels:
      run: {{ .Chart.Name }}
  replicas: 1
  template:
    metadata:
      labels:
        run: {{ .Chart.Name }}
    spec:
      {{- with .Values.nodeSelector }}
      nodeSelector:
{{ toYaml . | indent 8 }}
      {{- end }}
      {{- with .Values.affinity }}
      affinity:
{{ toYaml . | indent 8 }}
      {{- end }}
      {{- with .Values.tolerations }}
      tolerations:
{{ toYaml . | indent 8 }}
      {{- end }}
      initContainers:
      - name: init-map-count
        image: busybox:1.31
        securityContext:
          privileged: true
        command: ["sysctl", "-w", "vm.max_map_count={{ .Values.initContainer.vmMaxMapCount }}"]
      containers:
      - name: {{ .Chart.Name }}
        image: {{ .Chart.Name }}:{{ .Chart.AppVersion }}
        ports:
        - containerPort: 9200
        {{- with .Values.resources }}
        resources:
{{ toYaml . | indent 10 }}
        {{- end }}
