
Let's say you are using the oc new-app command to deploy an application, and the status of the pod is CrashLoopBackOff.
~]# oc get pods
NAME READY STATUS RESTARTS AGE
php-73-rhel7-b5fffcbcd-8k4gj 0/1 CrashLoopBackOff 6 7m38s
Let's say the oc get events command returns "image must not have leading or trailing whitespace". This suggests an issue with the image associated with a replica set or replication controller.
~]$ oc get events
LAST SEEN TYPE REASON OBJECT MESSAGE
13s Warning FailedCreate replicaset/php-73-rhel7-76d667fc6d Error creating: Pod "php-73-rhel7-76d667fc6d-4xn99" is invalid: spec.containers[0].image: Invalid value: " ": must not have leading or trailing whitespace
Replicas is the number of pods that should be created for the deployment.
When deploying an application using the oc new-app command, if the --as-deployment-config flag is not used, the application will be created as a deployment, not a deployment config. In this scenario, a replica set will be used to create the pods.
If the --as-deployment-config flag is used, the application will be created as a deployment config. In this scenario, a replication controller will be used to create the pods.
The oc get replicaset command can be used to list the replica sets. Notice there are two replica sets for the deployment, even if the deployment is set with 1 replica. This is normal. The initial replica set creates the second replica set.
~]$ oc get replicaset
NAME DESIRED CURRENT READY AGE
php-73-rhel7-74b8b8fd44 1 0 0 15s
php-73-rhel7-cf8fc698 1 1 0 15s
Or, if the deployment was done --as-deployment-config, the oc get replicationcontroller (or oc get rc) command can be used to list the replication controllers.
~]$ oc get rc
NAME DESIRED CURRENT READY AGE
my-app-1 1 1 1 42s
The oc describe replicaset or oc describe replicationcontroller command can be used to determine which replica set or replication controller is associated with the "image must not have leading or trailing whitespace" event.
~]$ oc describe replicaset php-73-rhel7-74b8b8fd44
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Warning FailedCreate 73s replicaset-controller Error creating: Pod "php-73-rhel7-74b8b8fd44-55sxm" is invalid: spec.containers[0].image: Invalid value: " ": must not have leading or trailing whitespace
The replica set or replication controller associated with the "image must not have leading or trailing whitespace" event will have no image. This is normal. The initial replica set or replication controller generates the second replica set or replication controller, and the second replica set or replication controller should have the same image as the deployment.
~]$ oc describe replicaset php-73-rhel7-74b8b8fd44
spec:
template:
spec:
containers:
- image: ' '
While it may be tempting to edit the initial replica set or replication controller to have the same image as the deployment, this is not how you should go about resolving this issue.
Typically, this means there is some other underlying issue. For example, this could mean that the replica set or replication controller was unable to download the image.
In this scenario, there will probably be other events that help to identify the actual issue here.
Did you find this article helpful?
If so, consider buying me a coffee over at