
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.
There are various ways to deploy an app.
- From GitHub (https://github.com)
- From Docker Hub (https://hub.docker.com)
- From an image
- From a build
- From a template
- From a JSON or YAML file (templates)
When deploying an application using a YAML file that has kind: Deployment, 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.
When deploying an application using a YAML file that has kind: DeploymentConfig (or using oc new-app command with the --as-deployment-config flag), the application will be created as a deployment config, not 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.
A JSON or YAML file that contains key value pairs can be used to create an object, such as a config map, deployment, a project, a pod, a route, a secret, a service, et cetera. These files are known as templates. For example, let's say you have a YAML file named deploymentconfig.yml that contains the following markup.
- use kind: Deployment to create a Deployment > Replica Set > Pods
- use kind: DeploymentConfig to create a Deployment Config > Replication Controller > Pods
apiVersion: apps.openshift.io/v1
kind: DeploymentConfig
metadata:
name: my-app
namespace: my-project
spec:
selector:
app: my-app
replicas: 3
template:
metadata:
labels:
app: my-app
spec:
containers:
- name: my-app
image: >-
image-registry.openshift-image-registry.svc:5000/openshift/my-app:latest
ports:
- containerPort: 8080
The oc apply or oc create command with the -f or --filename option can be used to create the deployment using the template JSON or YAML file.
The oc replace command can be used to replace a deployment using a new or updated template JSON or YAML file.
The oc edit command can be used to update a deployments template YAML file.
~]$ oc create --filename deploymentconfig.yml
deploymentconfig.apps/my-app created
If kind: Deployment was used, the oc get deployments command can be used to list the deployments. The DESIRED, CURRENT, UP-TO-DATE and AVAILABLE columns represent the number of replicas for the deployment.
~]# oc get deployments --namespace <some namespace>
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
hello-openshift 1 1 1 1 23s
If kind: DeploymentConfig was used, the oc get deploymentconfig (or oc get dc) command can be used to list the deployment configs.
~]$ oc get deploymentconfigs
NAME REVISION DESIRED CURRENT TRIGGERED BY
my-app 1 1 1 config,image(my-app:latest)
If kind: Deployment was used, the oc get replicaset (or oc get rs) command can be used to list the replica sets.
~]# oc get replicaset
NAME DESIRED CURRENT READY AGE
my-app-5b9879db6d 1 1 1 205d
If kind: DeploymentConfig was used, the oc get replicationcontroller (or oc get rc) command can be used to list the replication controllers.
Replicas is the number of pods that should be created for the deployment.
~]# oc get replicationcontroller
NAME DESIRED CURRENT READY AGE
my-app-5b9879db6d 1 1 1 205d
The oc get pods command can be used to determine if the pods are up and running.
~]$ oc get pods
NAME READY STATUS RESTARTS AGE
my-app-rhz7c 1/1 Running 0 23s
Did you find this article helpful?
If so, consider buying me a coffee over at