apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ .Chart.Name }}-{{ .Release.Name }}
  labels:
    app: {{ .Chart.Name }}-{{ .Release.Name }}
    app.kubernetes.io/managed-by: {{ .Release.Service }}
{{ if .Values.annotations }}
  annotations:
{{ toYaml .Values.annotations | indent 4 }}
{{ end -}}
spec:
  replicas: {{ .Values.replicas | default 2 }}
  selector:
    matchLabels:
      app: {{ .Chart.Name }}-{{ .Release.Name }}
  template:
    metadata:
      labels:
        app: {{ .Chart.Name }}-{{ .Release.Name }}
    spec:
      containers:
      - name: nginx
        image: {{ .Values.image.name }}:{{ .Values.image.tag }}
        ports:
        - containerPort: {{ .Values.port }}
{{ if .Values.env }}
        env:
        {{- range $key, $val := .Values.env }}
        - name: {{ $key | quote }}
          value: {{ $val | quote }}
        {{- end }}
{{ end }}
        resources:
{{ toYaml .Values.resources | indent 10 -}}

