8. CONFIDENTIAL INTERNAL USE2019 RED HAT TECH EXCHANGE
8
DevOps tooling in OpenShift
ImageStream
BuildConfig
DeploymentConfig
9. CONFIDENTIAL INTERNAL USE2019 RED HAT TECH EXCHANGE
9
ImageStream
An ImageStream and its associated tags
provide an abstraction for referencing
container images from within OpenShift
Container Platform
An ImageStreamTag is a named pointer to
an image in an imagestream. An image
stream tag is similar to a container image
tag.
An ImageStream trigger causes a specific
action when an ImagesStreamTag changes.
For example, trigger Deployments or
Builds on new image import
Source:
https://kubernetes.io/docs/reference/access-authn-authz/extensible-admission-controllers/#timeouts
https://docs.openshift.com/container-platform/4.2/openshift_images/image-streams-manage.html#managing-image-streams
11. CONFIDENTIAL INTERNAL USE2019 RED HAT TECH EXCHANGE
11
BuildConfig - Docker build
Source:
https://docs.openshift.com/container-platform/4.2/builds/understanding-image-builds.html#builds-strategy-docker-build_understanding-image-builds
The Docker build strategy invokes the
docker build command, and it expects a
repository with a Dockerfile and all
required artifacts in it to produce a
runnable image.
12. CONFIDENTIAL INTERNAL USE2019 RED HAT TECH EXCHANGE
12
BuildConfig - S2I build
Source:
https://docs.openshift.com/container-platform/4.2/builds/understanding-image-builds.html#build-strategy-s2i_understanding-image-builds
Source-to-Image (S2I) is a tool for building
reproducible, Docker-formatted container images. It
produces ready-to-run images by injecting application
source into a container image and assembling a new
image.
#!/bin/bash
# S2I Assemble script
ls -all /tmp/src/
cd /tmp/src/
tar zxvf node_modules.tar.gz
npm install -g serve
npm run-script build
#!/bin/bash
# S2I Run script
cp -R /tmp/src/build /tmp/build
cd /tmp/build && sed -i "s~__API_URL__~${API_URL}~g" index.html && serve -l 3000 -s
13. CONFIDENTIAL INTERNAL USE2019 RED HAT TECH EXCHANGE
13
BuildConfig - Custom build
Source:
https://docs.openshift.com/container-platform/4.2/builds/understanding-image-builds.html#build-strategy-custom-build_understanding-image-builds
The Custom build strategy allows developers to define
a specific builder image responsible for the entire
build process. Using your own builder image allows
you to customize your build process.
#!/bin/bash
echo "---> Starting custom build . . ."
SRC_DIR=$(pwd)/src
OCP_DIR=${SRC_DIR}/ocp
# Clone the source code
git clone ${SOURCE_URI} ${SRC_DIR}
cd ${OCP_DIR}
# Start build
oc start-build -F ${BUILD_CONFIG_NAME} -n ${PROJECT}
….
14. CONFIDENTIAL INTERNAL USE2019 RED HAT TECH EXCHANGE
14
BuildConfig - Pipeline build
Source:
https://docs.openshift.com/container-platform/4.2/builds/understanding-image-builds.html#builds-strategy-pipeline-build_understanding-image-builds
The Pipeline build strategy allows developers to define a
Jenkins pipeline for execution by the Jenkins pipeline
plugin. The build can be started, monitored, and managed
by OpenShift in the same way as any other build type.
// Jenkinsfile
pipeline {
agent {
node {
label 'maven'
}
}
stages {
stage("Run unit tests") {
steps {
script {
openshift.withCluster() {
openshift.withProject() {
echo "Hello from ${openshift.cluster()}'s default project: ${openshift.project()}"
}
}
}
}
}
...
15. CONFIDENTIAL INTERNAL USE2019 RED HAT TECH EXCHANGE
15
BuildConfig - Triggers
Source:
https://docs.openshift.com/container-platform/4.2/builds/triggering-builds-build-hooks.html#builds-configuration-change-triggers_triggering-builds-build-hooks
When defining a BuildConfig, you can define triggers to
control the circumstances in which the BuildConfig
should be run. The following build triggers are available:
Webhook, Image change or Configuration change
16. CONFIDENTIAL INTERNAL USE2019 RED HAT TECH EXCHANGE
16
DeploymentConfig
Source:
https://docs.openshift.com/container-platform/4.2/applications/deployments/what-deployments-are.html#deployments-and-deploymentconfigs_what-deployments-are
Building on ReplicationControllers, OpenShift Container Platform adds expanded
support for the software development and deployment lifecycle with the concept
of DeploymentConfigs. In the simplest case, a DeploymentConfig creates a new
ReplicationController and lets it start up Pods.
However, OpenShift Container Platform deployments from DeploymentConfigs
also provide the ability to transition from an existing deployment of an image to a
new one and also define hooks to be run before or after creating the
ReplicationController.
17. CONFIDENTIAL INTERNAL USE2019 RED HAT TECH EXCHANGE
17
Summary
Source:
https://docs.openshift.com/container-platform/4.2/applications/deployments/what-deployments-are.html#deployments-and-deploymentconfigs_what-deployments-are