<p>I'd like to know wether I'm able to restart a pod or do a deploy using api.</p>

<p>I'm running a container in a pod it's watching out on a directory. When a change is made on a directory, I need to restart the pod, or do a deploy.</p>

<p>This is my shell script snippet:</p>

<pre><code>while inotifywait -e modify $ENV_LOCATION; do
    curl -k \
      -X DELETE \
      -H "Authorization: Bearer $TOKEN" \
      -H 'Accept: application/json' \
      -H 'Content-Type: application/json' \
      $SERVER_URL/api/v1/namespaces/$NAMESPACE/pods/$NAME
done
</code></pre>

<p>So, how could I get current pod name?</p>

<p>Any ideas?</p>

<p>Take a look at <a href="https://kubernetes.io/docs/tasks/inject-data-application/environment-variable-expose-pod-information/" rel="nofollow noreferrer">here</a>.</p>

<p>You can use metadata:</p>

<pre><code>  - name: &lt;name&gt;
    image: &lt;image&gt;
    env:
    - name: KUBERNETES_NAMESPACE
      valueFrom:
        fieldRef:
          fieldPath: metadata.namespace
    - name: POD_NAME
      valueFrom:
        fieldRef:
          fieldPath: metadata.name
</code></pre>
