# configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ include "trailer.fullname" . }}-trailer
  labels:
  {{- include "trailer.labels" . | nindent 4 }}
data:
  BANDOLIER: {{ .Values.trailer.bandolier | quote }}
  COMMERCIAL: {{ .Values.trailer.commercial | quote }}
  DRAB: {{ .Values.trailer.drab | quote }}
  LAUGH_PENALTY_CRUSADER: {{ .Values.trailer.laughPenaltyCrusader | quote }}
  MILEPOST: {{ .Values.trailer.milepost | quote }}
  NEWSSTAND_INTERLAY_COLORFUL: {{ .Values.trailer.newsstandInterlayColorful | quote
    }}
  OCTET: {{ .Values.trailer.octet | quote }}
  PERSUADE_ENCOURAGEMENT: {{ .Values.trailer.persuadeEncouragement | quote }}
  PUDDLE: {{ .Values.trailer.puddle | quote }}
  SALUTE_SCREW_MALNUTRITION: {{ .Values.trailer.saluteScrewMalnutrition | quote }}
  SHORELINE: {{ .Values.trailer.shoreline | quote }}
  THRILL: {{ .Values.trailer.thrill | quote }} # deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ include "trailer.fullname" . }}-trailer
  labels:
  {{- include "trailer.labels" . | nindent 4 }}
  annotations:
    kubectl.kubernetes.io/default-container: trailer
spec:
  replicas: {{ .Values.trailer.replicas }}
  selector:
    matchLabels:
      app.kubernetes.io/instance: trailer
      app.kubernetes.io/name: green
    {{- include "trailer.selectorLabels" . | nindent 6 }}
  template:
    metadata:
      labels:
        app.kubernetes.io/instance: trailer
        app.kubernetes.io/name: green
      {{- include "trailer.selectorLabels" . | nindent 8 }}
      annotations:
        checksum/config: 17dc56e5138d07d1a834ffd8ba379d22814ca1cce114aece32b886a5106596c1
    spec:
      containers:
      - env:
        - name: KUBERNETES_CLUSTER_DOMAIN
          value: {{ quote .Values.kubernetesClusterDomain }}
        envFrom:
        - configMapRef:
            name: {{ include "trailer.fullname" . }}-trailer
        image: {{ .Values.trailer.trailer.image.repository }}:{{ .Values.trailer.trailer.image.tag
          | default .Chart.AppVersion }}
        imagePullPolicy: {{ .Values.trailer.trailer.imagePullPolicy }}
        name: trailer
        ports:
        - containerPort: 80
          name: http
          protocol: TCP
        resources: {{- toYaml .Values.trailer.trailer.resources | nindent 10 }}
        securityContext: {{- toYaml .Values.trailer.trailer.containerSecurityContext |
          nindent 10 }}
      securityContext:
        fsGroup: 999 # service.yaml
apiVersion: v1
kind: Service
metadata:
  name: {{ include "trailer.fullname" . }}-trailer
  labels:
  {{- include "trailer.labels" . | nindent 4 }}
spec:
  type: {{ .Values.trailer.type }}
  selector:
    app.kubernetes.io/instance: trailer
    app.kubernetes.io/name: green
  {{- include "trailer.selectorLabels" . | nindent 4 }}
  ports:
	{{- .Values.trailer.ports | toYaml | nindent 2 -}}
kubernetesClusterDomain: cluster.local
trailer:
  bandolier: refuse
  commercial: humdrum
  drab: incision
  laughPenaltyCrusader: doubt
  milepost: formation
  newsstandInterlayColorful: programme
  octet: inventor
  persuadeEncouragement: curio
  ports:
  - name: http
    port: 80
    protocol: TCP
    targetPort: http
  puddle: beginner
  replicas: 1
  saluteScrewMalnutrition: divert
  shoreline: muscle
  thrill: daikon
  trailer:
    containerSecurityContext: {}
    image:
      repository: nginx
      tag: latest
    imagePullPolicy: IfNotPresent
    resources:
      limits:
        cpu: 200m
        memory: 200Mi
      requests:
        cpu: 200m
        memory: 200Mi
  type: ClusterIP
