OpenShift Create an Application from a Docker Image: Difference between revisions
Line 40: | Line 40: | ||
2. '''Deployment Configuration''' The [[OpenShift Concepts#Deployment_Configuration|deployment configuration]] name is set to the application name and the object is associated with the application by the "app=<''app-name''> label. | 2. '''Deployment Configuration''' The [[OpenShift Concepts#Deployment_Configuration|deployment configuration]] name is set to the application name and the object is associated with the application by the "app=<''app-name''> label. | ||
apiVersion: v1 | |||
'''kind''': <font color='teal'>DeploymentConfig</font> | |||
metadata: | |||
'''name''': <font color='teal'>nexus3</font> | |||
'''labels''': | |||
'''app''': <font color='teal'>nexus3</font> | |||
spec: | |||
'''selector''': | |||
'''app''': <font color='teal'>nexus3</font> | |||
deploymentconfig: nexus3 | |||
'''strategy''': | |||
'''type''': <font color='teal'>Rolling</font> | |||
rollingParams: | |||
... | |||
activeDeadlineSeconds: 21600 | |||
'''template''': | |||
'''metadata''': | |||
'''labels''': | |||
'''app''': <font color='teal'>nexus3</font> | |||
deploymentconfig: nexus3 | |||
'''spec''': | |||
'''containers''': | |||
- '''name''': <font color='teal'>nexus3</font> | |||
'''image''': docker.io/sonatype/nexus3@sha256:1b1a581c76bf2a43112d4eea0077a73aadf234bb34a7b56f76fd5f3c1634dcaf | |||
imagePullPolicy: Always | |||
ports: | |||
- containerPort: 8081 | |||
protocol: TCP | |||
'''volumeMounts''': | |||
- '''name''': <font color='teal'>nexus3-volume-1</font> | |||
'''mountPath''': <font color='teal'>/nexus-data</font> | |||
dnsPolicy: ClusterFirst | |||
restartPolicy: Always | |||
schedulerName: default-scheduler | |||
terminationGracePeriodSeconds: 30 | |||
'''volumes''': | |||
- '''name''': <font color='teal'>nexus3-volume-1</font> | |||
emptyDir: {} | |||
test: false | |||
triggers: | |||
- type: ConfigChange | |||
- imageChangeParams: | |||
automatic: true | |||
containerNames: | |||
- nexus3 | |||
from: | |||
kind: ImageStreamTag | |||
name: nexus3:latest | |||
namespace: production-nexus | |||
type: ImageChange | |||
Revision as of 02:56, 20 January 2018
Internal
Overview
A Docker image repository URL can be provided to oc new-app to create an application based on that image.
oc new-app <docker-repository-URL>
Example:
oc new-app docker.io/sonatype/nexus3:latest
Primitives
The utility creates an image stream, a deployment configuration and a service in the current project, and associate all of them with a single application by annotating them with the "app=<application-name>" label, where the application name is inferred from - and equal to - the name of the image repository given as argument.
1. Image Stream. The image stream name is set to the application name, and the object is associated with the application by the "app=<app-name> label.
apiVersion: v1 kind: ImageStream metadata: labels: app: nexus3 name: nexus3 spec: lookupPolicy: local: false tags: name: latest from: kind: DockerImage name: docker.io/sonatype/nexus3:latest referencePolicy: type: Source
2. Deployment Configuration The deployment configuration name is set to the application name and the object is associated with the application by the "app=<app-name> label.
apiVersion: v1 kind: DeploymentConfig metadata: name: nexus3 labels: app: nexus3 spec: selector: app: nexus3 deploymentconfig: nexus3 strategy: type: Rolling rollingParams: ... activeDeadlineSeconds: 21600 template: metadata: labels: app: nexus3 deploymentconfig: nexus3 spec: containers: - name: nexus3 image: docker.io/sonatype/nexus3@sha256:1b1a581c76bf2a43112d4eea0077a73aadf234bb34a7b56f76fd5f3c1634dcaf imagePullPolicy: Always ports: - containerPort: 8081 protocol: TCP volumeMounts: - name: nexus3-volume-1 mountPath: /nexus-data dnsPolicy: ClusterFirst restartPolicy: Always schedulerName: default-scheduler terminationGracePeriodSeconds: 30 volumes: - name: nexus3-volume-1 emptyDir: {} test: false triggers: - type: ConfigChange - imageChangeParams: automatic: true containerNames: - nexus3 from: kind: ImageStreamTag name: nexus3:latest namespace: production-nexus type: ImageChange
3. Service
For more details on how to deploy a production-ready Nexus instance starting with oc new-app <nexus-image-url>, go to: