Deploying container images to OpenShift

10/2/2019

I want to apply this article (Getting any Docker image running in your own OpenShift cluster) for an image from the RedHat Registry. I chose the rhel8/redis-5 image. I am not clear about the steps to be followed.

I tried oc new-app --docker-image=registry.redhat.io/rhel8/redis-5. This did not work even after copying the Docker configuration details from the RedHat Registry Service account. Is oc new-app expected to work with images stored outside of Docker Hub?

Next, I tried the OpenShift secret option.

Following the details from Registry Service account to use OpenShift secret, we have to run this command. kubectl create -f chainhead-secret.yml --namespace=NAMESPACEHERE. Is this what is called as the image pull secret? Is there a oc command equivalent?

The next step is to update Kubernetes configuration with a yaml snippet as shown below. Where should it be consumed - oc, web console, kube-whatever command, etc?

apiVersion: v1
kind: Pod
metadata:
  name: somepod
  namespace: all
  spec:
    containers:
      - name: web
        image: registry.redhat.io/REPONAME

    imagePullSecrets:
      - name: some-pull-secret
-- cogitoergosum
docker
kubernetes
openshift
redhat

2 Answers

10/2/2019

I am not familiar with OpenShift, however I find some things that might be helpful for you.

Besides of what @Arockiasmy K mentioned in previous answer, the YAML syntax is incorrect. It won't create a pod: spec must be on the same lever as kind.

apiVersion: v1
kind: Pod
metadata:
  name: somepod
  namespace: all
spec:
  containers:
  - name: web
    image: <image>

$ kubectl apply -f <pod-yaml>

Another thing, make sure that you already have namespace called "all" and remember that secret must be in the same namespaces as Pod.

Hope it will help.

-- PjoterS
Source: StackOverflow

10/2/2019

You can create the secret using kubectl as well as oc. Both works in Openshift.

oc create -f redhat-secret.yml --namespace=NAMESPACEHERE

Ensure that the hostname is registry.redhat.io. You have two ways to attach it to deployment.

  • You can mention this secret into the pod,dc configuration as imagePullSecrets.
  • You can add this secret as imagePullSecrets into default SA (in the project). oc edit sa default.
-- Arockiasmy K
Source: StackOverflow