<p>I wanted to know is it possible to have a job in Kubernetes that will run every hour, and will delete certain pods. I need this as a temporary
stop gap to fix an issue.</p>

user1555190
<p>Yes, it's possible.</p>

<p>I think the easiest way is just to call the Kubernernes API directly from a job. Considering RBAC is configured, something like this:</p>

<pre><code>apiVersion: batch/v1
kind: Job
metadata:
  name: cleanup
spec:
  serviceAccountName: service-account-that-has-access-to-api
  template:
    spec:
      containers:
      - name: cleanup
        image: image-that-has-curl
        command:
        - curl
        - -ik 
        - -X
        - DELETE
        - -H
        - "Authorization: Bearer $(cat /var/run/secrets/kubernetes.io/serviceaccount/token)"
        - https://kubernetes.default.svc.cluster.local/api/v1/namespaces/{namespace}/pods/{name}
      restartPolicy: Never
  backoffLimit: 4
</code></pre>

<p>You can also run a kubectl proxy sidecar to connect to the cluster using <code>localhost</code>. More information <a href="https://kubernetes.io/docs/tasks/access-application-cluster/access-cluster/#accessing-the-api-from-a-pod" rel="nofollow noreferrer">here</a></p>

<p>Or even running plain <code>kubectl</code> in a pod is also an option: <a href="https://stackoverflow.com/questions/42642170/kubernetes-how-to-run-kubectl-commands-inside-a-container">Kubernetes - How to run kubectl commands inside a container?</a></p>
