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