Bootstrap FreeKB - OpenShift - List deployments using the oc get deployments command
OpenShift - List deployments using the oc get deployments command

Updated:   |  OpenShift articles

An image contains the code used to create a deployment. Then, a deployment can be created from an image, which should then create a replica set (which is the number of pods that should be created), and then the pods should be created.

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.

 

If you are not familiar with the oc command, refer to OpenShift - Getting Started with the oc command.

The oc get deployments command can be used to list the deployments in the currently selected project.

~]# oc get deployments
NAME      READY   UP-TO-DATE   AVAILABLE   AGE
my-app    1/1     1            1           8d

 

Or, 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 and the oc get deploymentconfigs (or oc get dc) command would be used to list the deployments.

~]$ oc get deploymentconfigs
NAME      REVISION   DESIRED   CURRENT   TRIGGERED BY
my-app    1          1         1         config,image(my-app:latest)

 

If you have numerous deployments, the -l option can be used to only return the deployments that match the app name.

oc get deployments -l app=my-app

 

If READY is 0/0 or AVAILABLE is 0, you may need to restart the deployment.

NAME      READY   UP-TO-DATE   AVAILABLE   AGE
my-app    0/0     0            0           8d

 

The --output wide option can be used to display more information about the deployment. The oc config view or oc get apiserver commands can be used to display the API Server URL (api.openshift.example.com in this example).

~]$ oc get deployments --output wide
NAME     READY   UP-TO-DATE   AVAILABLE   AGE   CONTAINERS      IMAGES                            SELECTOR
my-app   1/1     1            1           8d    my-container    api.openshift.example.com/myapp   app=app001

 

The --output yaml or --output json options can be used to display even more information about the deployment.

oc get deployment my-app --output yaml

 

Something like this should be returned.

apiVersion: v1
kind: Deployment
metadata:
  annotations:
    deployment.kubernetes.io/revision: "1"
    openshift.io/generated-by: OpenShiftNewApp
  creationTimestamp: "2021-03-23T22:06:06Z"
  generation: 1
  name: my-app
  namespace: default
  resourceVersion: "450841867"
  uid: fff40384-0b81-4016-8ff7-6a755c3d1792
spec:
  replicas: 1
  spec:
    - image: api.openshift.example.com/myapp
      imagePullPolicy: IfNotPresent
      name: my-app
      ports:
      - containerPort: 8080
        protocol: TCP
      - containerPort: 8443
        protocol: TCP
      resources: {}
      terminationMessagePath: /dev/termination-log
      terminationMessagePolicy: File
    dnsPolicy: ClusterFirst
    restartPolicy: Always
    schedulerName: default-scheduler
    securityContext: {}
    terminationGracePeriodSeconds: 30

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter f306d2 in the box below so that we can be sure you are a human.