# configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ include "duckling.fullname" . }}-duckling
  labels:
  {{- include "duckling.labels" . | nindent 4 }}
data:
  DIET: {{ .Values.duckling.diet | quote }}
  FLANKER_CHICKEN_MILE: {{ .Values.duckling.flankerChickenMile | quote }}
  IMPRESS_PAINT_ONLINE: {{ .Values.duckling.impressPaintOnline | quote }} # deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ include "duckling.fullname" . }}-duckling
  labels:
  {{- include "duckling.labels" . | nindent 4 }}
  annotations:
    kubectl.kubernetes.io/default-container: duckling
spec:
  replicas: {{ .Values.duckling.replicas }}
  selector:
    matchLabels:
      app.kubernetes.io/instance: duckling
      app.kubernetes.io/name: retirement
    {{- include "duckling.selectorLabels" . | nindent 6 }}
  template:
    metadata:
      labels:
        app.kubernetes.io/instance: duckling
        app.kubernetes.io/name: retirement
      {{- include "duckling.selectorLabels" . | nindent 8 }}
      annotations:
        checksum/config: 11f96d3c3253a04b8c524a26a8a18e92e03b32a3399e6a29d123123f745f2b2f
    spec:
      containers:
      - env:
        - name: KUBERNETES_CLUSTER_DOMAIN
          value: {{ quote .Values.kubernetesClusterDomain }}
        envFrom:
        - configMapRef:
            name: {{ include "duckling.fullname" . }}-duckling
        image: {{ .Values.duckling.duckling.image.repository }}:{{ .Values.duckling.duckling.image.tag
          | default .Chart.AppVersion }}
        imagePullPolicy: {{ .Values.duckling.duckling.imagePullPolicy }}
        name: duckling
        ports:
        - containerPort: 80
          name: http
          protocol: TCP
        resources: {{- toYaml .Values.duckling.duckling.resources | nindent 10 }}
        securityContext: {{- toYaml .Values.duckling.duckling.containerSecurityContext
          | nindent 10 }}
      securityContext:
        fsGroup: 999 # service.yaml
apiVersion: v1
kind: Service
metadata:
  name: {{ include "duckling.fullname" . }}-duckling
  labels:
  {{- include "duckling.labels" . | nindent 4 }}
spec:
  type: {{ .Values.duckling.type }}
  selector:
    app.kubernetes.io/instance: duckling
    app.kubernetes.io/name: retirement
  {{- include "duckling.selectorLabels" . | nindent 4 }}
  ports:
	{{- .Values.duckling.ports | toYaml | nindent 2 -}}
duckling:
  diet: feel
  duckling:
    containerSecurityContext: {}
    image:
      repository: nginx
      tag: latest
    imagePullPolicy: IfNotPresent
    resources:
      limits:
        cpu: 200m
        memory: 200Mi
      requests:
        cpu: 200m
        memory: 200Mi
  flankerChickenMile: warren
  impressPaintOnline: icing
  ports:
  - name: http
    port: 80
    protocol: TCP
    targetPort: http
  replicas: 1
  type: ClusterIP
kubernetesClusterDomain: cluster.local
