<p>Trying to mount config files from a hostPath to a kubernetes container. This works using minikube and VirtualBox shared folder, but I am unable to make this work on Linux.</p>

<p>I making use of AWS EKS and the following architecture <a href="https://aws.amazon.com/quickstart/architecture/amazon-eks/" rel="nofollow noreferrer">https://aws.amazon.com/quickstart/architecture/amazon-eks/</a>. I think my problem is that the files need to live on each of the EKS Node instances.</p>

<p>Here is the architecture diagram:
<a href="https://i.stack.imgur.com/Qbgoz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Qbgoz.png" alt="enter image description here"></a></p>

<p>Below is the Deployment file.</p>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: openhim-core-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      component: openhim-core
  template:
    metadata:
      labels:
        component: openhim-core
    spec:
      volumes:
        - name: core-config
          hostPath:
            path: /var/config/openhim-core
      containers:
        - name: openhim-core
          image: jembi/openhim-core:5.rc
          ports:
            - containerPort: 8080
            - containerPort: 5000
            - containerPort: 5001
          volumeMounts:
            - name: core-config
              mountPath: /usr/src/app/config
          env:
            - name: NODE_ENV
              value: development
</code></pre>

Anton Swanevelder
<p>After much pain I found that I am trying to place the configuration on the Linux Bastion host where I have access to kubectl but in fact this configuration will have to be on each of the EC2 instances in every availability zone.</p>

<p>The solution for me was to make use of a initContainer.</p>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: openhim-core-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      component: openhim-core
  template:
    metadata:
      labels:
        component: openhim-core
    spec:
      volumes:
        - name: core-config
          hostPath:
            path: /var/config/openhim-core
      containers:
        - name: openhim-core
          image: jembi/openhim-core:5
          ports:
            - containerPort: 8080
            - containerPort: 5000
            - containerPort: 5001
          volumeMounts:
            - name: core-config
              mountPath: /usr/src/app/config
          env:
            - name: NODE_ENV
              value: development
      initContainers:
        - name: install
          image: busybox
          command:
          - wget
          - "-O"
          - "/usr/src/app/config/development.json"
          - https://s3.eu-central-1.amazonaws.com/../development.json
          volumeMounts:
            - name: core-config
              mountPath: "/usr/src/app/config"      
      volumes:
        - name: core-config
          emptyDir: {}       
</code></pre>
