# configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ include "apartment.fullname" . }}-apartment
  labels:
  {{- include "apartment.labels" . | nindent 4 }}
data:
  BEGINNING_CERAMIC: {{ .Values.apartment.beginningCeramic | quote }}
  PARANOIA: {{ .Values.apartment.paranoia | quote }}
  PEDAL: {{ .Values.apartment.pedal | quote }}
  RESISTANCE: {{ .Values.apartment.resistance | quote }}
  SHINY_MEDICATION: {{ .Values.apartment.shinyMedication | quote }} # deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ include "apartment.fullname" . }}-apartment
  labels:
  {{- include "apartment.labels" . | nindent 4 }}
  annotations:
    kubectl.kubernetes.io/default-container: apartment
spec:
  replicas: {{ .Values.apartment.replicas }}
  selector:
    matchLabels:
      app.kubernetes.io/instance: apartment
      app.kubernetes.io/name: trader
    {{- include "apartment.selectorLabels" . | nindent 6 }}
  template:
    metadata:
      labels:
        app.kubernetes.io/instance: apartment
        app.kubernetes.io/name: trader
      {{- include "apartment.selectorLabels" . | nindent 8 }}
      annotations:
        checksum/config: 2f16b3f2877f62ebef02ffdde64ec6f4e3293105eacf0a184b1fdf9c84b984e3
    spec:
      containers:
      - env:
        - name: KUBERNETES_CLUSTER_DOMAIN
          value: {{ quote .Values.kubernetesClusterDomain }}
        envFrom:
        - configMapRef:
            name: {{ include "apartment.fullname" . }}-apartment
        image: {{ .Values.apartment.apartment.image.repository }}:{{ .Values.apartment.apartment.image.tag
          | default .Chart.AppVersion }}
        imagePullPolicy: {{ .Values.apartment.apartment.imagePullPolicy }}
        name: apartment
        ports:
        - containerPort: 80
          name: http
          protocol: TCP
        resources: {{- toYaml .Values.apartment.apartment.resources | nindent 10 }}
        securityContext: {{- toYaml .Values.apartment.apartment.containerSecurityContext
          | nindent 10 }}
      securityContext:
        fsGroup: 999 # service.yaml
apiVersion: v1
kind: Service
metadata:
  name: {{ include "apartment.fullname" . }}-apartment
  labels:
  {{- include "apartment.labels" . | nindent 4 }}
spec:
  type: {{ .Values.apartment.type }}
  selector:
    app.kubernetes.io/instance: apartment
    app.kubernetes.io/name: trader
  {{- include "apartment.selectorLabels" . | nindent 4 }}
  ports:
	{{- .Values.apartment.ports | toYaml | nindent 2 -}}
apartment:
  apartment:
    containerSecurityContext: {}
    image:
      repository: nginx
      tag: latest
    imagePullPolicy: IfNotPresent
    resources:
      limits:
        cpu: 200m
        memory: 200Mi
      requests:
        cpu: 200m
        memory: 200Mi
  beginningCeramic: rudiment
  paranoia: radiosonde
  pedal: eatable
  ports:
  - name: http
    port: 80
    protocol: TCP
    targetPort: http
  replicas: 1
  resistance: proponent
  shinyMedication: tarragon
  type: ClusterIP
kubernetesClusterDomain: cluster.local
