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

Updated:   |  OpenShift articles

A deployment is used to manage the pods that are created to run an application. The deployment ensures that the desired number of pod replicas are running and can handle updates to the application by rolling out new versions of the pods. The deployment creates and manages a replica set, which in turn manages the pods.

flowchart TB subgraph Project["OpenShift Project/Namespace"] Deployment[Deployment] Replica_Set[Replica Set] subgraph Pods["Pod Replicas"] Pod1[Pod 1
Container] Pod2[Pod 2
Container] Pod3[Pod 3
Container] end end Deployment -->|Creates/Manages| Replica_Set Replica_Set -->|Manages| Pod1 Replica_Set -->|Manages| Pod2 Replica_Set -->|Manages| Pod3 style Deployment fill:#90CAF9 style Replica_Set fill:#FFE082 style Pods fill:#FFCCBC

It is also noteworthy that a route provides a URL that can be used to access the application from outside the OpenShift cluster. For example, if the route is configured to use the hostname myapp.mydomain.com, then users can access the application by navigating to http://myapp.mydomain.com. The route will forward the request to the service, which will then forward the request to one of the pods that are running the application.

flowchart LR subgraph Project["OpenShift Project/Namespace"] subgraph Pods["Pod Replicas"] Pod1[Pod 1
Container] Pod2[Pod 2
Container] Pod3[Pod 3
Container] end SVC[Service] Route[Route] end USER[External User] --> Route --> SVC SVC --> Pod1 SVC --> Pod2 SVC --> Pod3 style SVC fill:#A5D6A7 style Pods fill:#FFCCBC style USER fill:#CE93D8

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 0adceb in the box below so that we can be sure you are a human.