OpenShift Deployment Operations: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
 
(22 intermediate revisions by the same user not shown)
Line 11: Line 11:
=Overview=
=Overview=


=View Deployments for Project=
=View Deployment Controllers for Project=


  oc get deploy
  oc get dc


The deployments returned by this list are backed by deployment pods, which can be retrieved with
=View the Latest Deployment for a Deployment Controller=
 
oc deploy <''deployment-controller-name''>
 
For each on-going deployment, there is a deployment pod, whose name can be inferred from the list of pods for the project:
 
oc get pods
 
==View Deployment Logs==
 
The log of the deployment can be obtained from the deployment pod:


  oc get pods
  oc get pods
NAME                READY    STATUS            RESTARTS  AGE
...
<''dc-name''>-1-deploy  1/1      Running            0          7m
then:
oc logs -f <''dc-name''>-1-deploy
The same log can be obtained from the deployment itself:
oc logs -f dc/<''dc-name''>


=View Deployment Events=
==View Deployment Events==


  oc describe dc <''deployment-configuration-name''>
  oc describe dc <''dc-name''>


=View Deployment Logs=
=Create a New Deployment=


<font color=red>
==Create a New Deployment with oc new-app==
View deployment logs for a deployment:


  oc logs -f deploy/<''deploy-object-name''>
[[oc new-app]] creates all the objects required by an application, including a deployment configuration. See: {{Internal|OpenShift Application Operations#Overview|Application Operations}}
</font>
 
==Create a New Deployment Manually==
 
Use a deployment configuration template similar to https://github.com/NovaOrdis/playground/blob/master/openshift/templates/eap7-deployment-configuration-template.yaml. Copy it locally and adjust, then:
 
  oc process -p APPLICATION_NAME=<''some-app-name''> -f ./eap7-deployment-configuration-template.yaml | oc create -f -


=Starting a Deployment=
=Starting a Deployment=
Line 36: Line 61:


This will start the number of replicas specified in <font color=red>?</font>
This will start the number of replicas specified in <font color=red>?</font>


  oc scale dc logging-es-3fs5ghyo --replicas=1
  oc scale dc logging-es-3fs5ghyo --replicas=1


{{Warn|scaling the pod instead of the deploymentconfig may modify the deployment config. Verify}}
{{Warn|scaling the pod instead of the deploymentconfig may modify the deployment config. Verify}}


=Assigning Pods to Specific Nodes=
=Assigning Pods to Specific Nodes=


{{External|https://docs.openshift.com/container-platform/3.6/dev_guide/deployments/basic_deployment_operations.html#assigning-pods-to-specific-nodes}}
{{External|https://docs.openshift.com/container-platform/3.6/dev_guide/deployments/basic_deployment_operations.html#assigning-pods-to-specific-nodes}}


==Assigning a Pod to Nodes that Match a Node Selector==
==Assigning a Pod to Nodes that Match a Node Selector==
Line 75: Line 95:
=Turn Off Auto-Deployment After Build=
=Turn Off Auto-Deployment After Build=


  [[oc set]] triggers dc/<''deployment-config-name''> --remove-all
  [[Oc_set#triggers|oc set]] triggers dc/<''deployment-config-name''> --remove-all
 
=Deleting a Deployment Configuration=
 
oc delete dc/<''dc-name''>
 
Deleting a deployment configuration will also automatically delete the [[OpenShift_Concepts#Deployment_Configurations_and_Replication Controllers|replication controllers]] generated by that deployment configuration.
 
=Scaling Down a Deployment=
 
oc scale dc/sonar --replicas 0
oc scale dc/sonar-postgresql --replicas 0

Latest revision as of 09:59, 7 December 2017

External

Internal

Overview

View Deployment Controllers for Project

oc get dc

View the Latest Deployment for a Deployment Controller

oc deploy <deployment-controller-name>

For each on-going deployment, there is a deployment pod, whose name can be inferred from the list of pods for the project:

oc get pods

View Deployment Logs

The log of the deployment can be obtained from the deployment pod:

oc get pods
NAME                 READY     STATUS             RESTARTS   AGE
...
<dc-name>-1-deploy   1/1       Running            0          7m

then:

oc logs -f <dc-name>-1-deploy 

The same log can be obtained from the deployment itself:

oc logs -f dc/<dc-name>

View Deployment Events

oc describe dc <dc-name>

Create a New Deployment

Create a New Deployment with oc new-app

oc new-app creates all the objects required by an application, including a deployment configuration. See:

Application Operations

Create a New Deployment Manually

Use a deployment configuration template similar to https://github.com/NovaOrdis/playground/blob/master/openshift/templates/eap7-deployment-configuration-template.yaml. Copy it locally and adjust, then:

oc process -p APPLICATION_NAME=<some-app-name> -f ./eap7-deployment-configuration-template.yaml | oc create -f -

Starting a Deployment

oc rollout latest dc/<deploymentconfig-name>

This will start the number of replicas specified in ?

oc scale dc logging-es-3fs5ghyo --replicas=1

scaling the pod instead of the deploymentconfig may modify the deployment config. Verify

Assigning Pods to Specific Nodes

https://docs.openshift.com/container-platform/3.6/dev_guide/deployments/basic_deployment_operations.html#assigning-pods-to-specific-nodes

Assigning a Pod to Nodes that Match a Node Selector

Edit the DeploymentConfig that defines the pod:

oc edit dc/<pod-name>

Inject the node selector specification under

spec:
  ...
  template:
    ...
    spec:
      ...
      nodeSelector:
        keyA: valueA

Restart the corresponding pod, by simply deleting it.

For more details on concepts related to pod placement, see:

Pod Placement

Turn Off Auto-Deployment After Build

oc set triggers dc/<deployment-config-name> --remove-all

Deleting a Deployment Configuration

oc delete dc/<dc-name>

Deleting a deployment configuration will also automatically delete the replication controllers generated by that deployment configuration.

Scaling Down a Deployment

oc scale dc/sonar --replicas 0
oc scale dc/sonar-postgresql --replicas 0