<p>I want to use the <a href="https://hub.docker.com/r/prom/prometheus/" rel="nofollow noreferrer">Prometheus</a> image to deploy a container as part of the local deployment. Usually one has to run the container with <a href="https://prometheus.io/docs/prometheus/latest/installation/#volumes-bind-mount" rel="nofollow noreferrer">volume and bind-mount</a> to get the configuration file (<code>prometheus.yml</code>) into the container:</p>
<pre><code>docker run \
    -p 9090:9090 \
    -v /path/to/prometheus.yml:/etc/prometheus/prometheus.yml \
    prom/prometheus
</code></pre>
<p>How can I achieve this with Kubernetes when using Skaffold?</p>

thinwybk
<p>Your Kubernetes configuration will be something like this,
You can specify the port number and volume mounts. The important sections for mounting are <code>volumeMounts</code> and <code>volumes</code>.</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-prom
spec:
  selector:
    matchLabels:
      app: my-prom
  template:
    metadata:
      labels:
        app: my-prom
    spec:
      containers:
      - name: my-prom
        image: prometheus:latest
        resources:
          limits:
            memory: &quot;128Mi&quot;
            cpu: &quot;500m&quot;
        ports:
        - containerPort: 9090
        volumeMounts:
          - name: prom-config
            mountPath: /path/to/prometheus.yml
      volumes:
        - name: prom-config
          hostPath:
              path: /etc/prometheus/prometheus.yml
---
apiVersion: v1
kind: Service
metadata:
  name: my-prom
spec:
  selector:
    app: my-prom
  ports:
  - port: 9090
    targetPort: 9090
</code></pre>
<p>save the Kubernetes config file in a folder and add below config to <code>skaffold.yaml</code> with the path to K8s config file,</p>
<pre><code>deploy:
  kubectl:
    manifests:
    - k8s/*.yaml
</code></pre>
