<p>I am new to devops and openshift. I have a simple <code>.sh</code> script that connects to a download  website and checks if a new version is present if it gets <code>200</code> response it downloads the file. I need to know if it is possible to run this script using cronjob on each pod (1 in my case) centrally. If so is there any examples where cron job runs an <code>.sh</code> file (ones that I came across has only simple echo commands ran by cronjob).</p>

LOWERCASE
<blockquote>
<p>I need to know if it is possible to run this script using cronjob on each pod(1 in my case) centrally.</p>
</blockquote>
<p>No, such things are impossible without hacking, because <strong>Kubernetes pods are designed as relatively ephemeral, disposable entities</strong>.<br />
In case you want to update some binary files inside running pods, I suggest the following approach (since you did not provide any details, I will show how you can achieve your goal using the Nginx deployment example):</p>
<h4>1. Create a Kubernetes <a href="https://kubernetes.io/docs/concepts/workloads/controllers/deployment/" rel="nofollow noreferrer">deployment</a> for your app and add <a href="https://kubernetes.io/docs/concepts/workloads/pods/init-containers/" rel="nofollow noreferrer">Init containers</a> section (nginx example here):</h4>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx
        ports:
        - containerPort: 80
        volumeMounts:
        - name: workdir
          mountPath: /usr/share/nginx/html
      initContainers:
      - name: install
        image: busybox
        command:
        - wget
        - &quot;-O&quot;
        - &quot;/work-dir/index.html&quot;
        - http://time.is
        volumeMounts:
        - name: workdir
          mountPath: &quot;/work-dir&quot;
      dnsPolicy: Default
      volumes:
      - name: workdir
        emptyDir: {}
</code></pre>
<p>This <code>init container</code> downloads some html file, and main nginx container takes this file as index.html.</p>
<h4>2. Create a k8s CronJob to run a rolling update on deployment:</h4>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: batch/v1
kind: CronJob
metadata:
  name: restart-deployment
spec:
  concurrencyPolicy: Forbid
  schedule: '0/5 * * * *'
  jobTemplate:
    spec:
      backoffLimit: 2
      activeDeadlineSeconds: 10
      template:
        spec:
          serviceAccountName: restart-deployment
          restartPolicy: Never
          containers:
            - name: kubectl
              image: bitnami/kubectl
              command:
                - /bin/bash
                - -c
                - |
                  #place your new version check here, if true run:
                  kubectl rollout restart deployment/nginx-deployment
</code></pre>
<p>Place your script that checks if the new version of a binary is available in this CronJob.</p>
<h4>3. Create a ServiceAccount, Role, RoleBinding to allow the CronJob to manipulate the k8s cluster:</h4>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
kind: ServiceAccount
metadata:
  name: restart-deployment
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: restart-deployment
rules:
  - apiGroups: [&quot;apps&quot;, &quot;extensions&quot;]
    resources: [&quot;deployments&quot;]
    resourceNames: [&quot;nginx-deployment&quot;]
    verbs: [&quot;get&quot;, &quot;patch&quot;, &quot;list&quot;, &quot;watch&quot;]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: restart-deployment
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: restart-deployment
subjects:
  - kind: ServiceAccount
    name: restart-deployment
</code></pre>
<p><strong>As a result, you will have a k8s CronJob that checks something every 5 minutes, and if it's true, runs</strong></p>
<pre><code>kubectl rollout restart deployment/nginx-deployment
</code></pre>
<p>This will perform a <a href="https://kubernetes.io/docs/tutorials/kubernetes-basics/update/update-intro/" rel="nofollow noreferrer">Rolling Update</a> (&quot;RollingUpdate&quot; is the default <a href="https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#strategy" rel="nofollow noreferrer">update strategy</a> ).</p>
<h4>New pods will use the latest downloaded by init-containers files.</h4>
