<p>The goal is to orchestrate both production and local development environments using Kubernetes. The problem is that <code>hostPath</code> doesn't work with relative path values. This results in slightly differing configuration files on each developer's machine to accommodate for the different project locations (i.e. <code>"/my/absolute/path/to/the/project"</code>): </p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: some-service
  labels:
    app: app
spec:
  type: LoadBalancer
  ports:
  - port: 80
  selector:
    app: app
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: some-deploy
spec:
  selector:
    matchLabels:
      app: app
  replicas: 1
  template:
    metadata:
      labels:
        app: app
    spec:
      containers:
      - name: app
        image: nginx:1.13.12-alpine
        ports:
        - containerPort: 80
        volumeMounts:
        - name: vol_example
          mountPath: /var/www/html
      volumes:
        - name: vol_example
          hostPath:
            path: "/my/absolute/path/to/the/project"
            type: Directory
</code></pre>

<p>How can relative paths be used in Kubernetes config files? Variable replacements (such as <code>$(PWD)/project</code>) have been tried, but didn't seem to work. If config variables can work with volumes, this might help but unsure of how to achieve this.</p>

<p>As mentioned <a href="https://github.com/kubernetes/kubernetes/issues/52787" rel="noreferrer">here</a> <code>kubectl</code> will never support variable substitution. </p>

<p>You can create a <a href="https://helm.sh/" rel="noreferrer">helm</a> chart for your app (yaml). It supports yaml template variables (among various other features). So you'll be able to pass  <code>hostPath</code> parameter based on development or production. </p>
