What is the difference between oc and kubectl commands?

4/9/2019

I am trying to create a cron job in openshift and having trouble doing this with oc so I am looking for alternatives.

I have already tried: "oc run cron --image={imagename} \ --dry-run=false" This created another resource. There was no parameter to create a cron job

-- rtbilli110
kubernetes
openshift

2 Answers

4/9/2019

oc stands for openshift client which is a wrapper created on top of kubectl. It is created to communicate with openshift api server. It supports all operations that are provided by kubectl and others that are specific to OpenShift like operations on templates, builds, build and development config, image stream etc

-- P Ekambaram
Source: StackOverflow

4/9/2019

There's already a good answer on how the two platforms overlap. You mentioned there was no parameter to create a cronjob. You can do that with oc through the following (resource):

oc run pi --image=perl --schedule='*/1 * * * *' \
    --restart=OnFailure --labels parent="cronjobpi" \
    --command -- perl -Mbignum=bpi -wle 'print bpi(2000)'

Or you can do it through a yaml file like the following:

apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: hello
spec:
  schedule: "*/1 * * * *"
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - name: hello
            image: busybox
            args:
            - /bin/sh
            - -c
            - date; echo Hello from the Kubernetes cluster
          restartPolicy: OnFailure

And then run:

oc create -f cronjob.yaml -n default
-- cookiedough
Source: StackOverflow