DevOps with OpenShift
Last updated
Was this helpful?
Last updated
Was this helpful?
OpenShift is a computer software product from Red Hat for container-based software deployment and management. It is a supported distribution of Kubernetes using Docker containers and DevOps tools for accelerated application development.
OpenShift Origin is the upstream community project used in OpenShift Online, OpenShift Dedicated, and OpenShift Container Platform. Built around a core of Docker container packaging and Kubernetes container cluster management, Origin is augmented by application lifecycle management functionality and DevOps tooling. Origin provides an open source application container platform. All source code for the Origin project is available under the Apache License (Version 2.0) on GitHub.
OpenShift Online is Red Hat's public cloud application development and hosting service.
Online offered version 2 of the Origin project source code, which is also available under the Apache License Version 2.0. This version supported a variety of languages, frameworks, and databases via pre-built "cartridges" running under resource-quota "gears". Developers could add other language, database, or components via the OpenShift Cartridge application programming interface. This was deprecated in favour of OpenShift 3 and will be withdrawn on 30th September 2017 for non-paying customers and 31st December 2017 for paying customers.
OpenShift 3 is built around Kubernetes. It can run any Docker-based container, but Openshift Online is limited to running containers that do not require root.
OpenShift Dedicated is Red Hat's managed private cluster offering, built around a core of application containers powered by Docker, with orchestration and management provided by Kubernetes, on a foundation of Red Hat Enterprise Linux. It's available on the Amazon Web Services (AWS) and Google Cloud Platform (GCP) marketplaces.
OpenShift Container Platform (formerly known as OpenShift Enterprise) is Red Hat's on-premises private platform as a service product, built around a core of application containers powered by Docker, with orchestration and management provided by Kubernetes, on a foundation of Red Hat Enterprise Linux.
Supports stateful applications
Volumes backed by shared storage which are mounted into running pods
iSCSI, AWS EBS, NFS etc.
Manifests that pods use to retreive and mount the volume into pod at initialization time
Access modes: REadWriteOnce, REadOnlyMany, ReadWriteMany
Rolling
Triggers
Recreate
Custom
Lifecycle hooks
Deployment Pod Resources
Comes with all necessary OpenShift plugins (OpenShift login, OpenShift sync, OpenShift pipeline, Kubernetes)
Comes with example Jenkinsfile
Customizing Jenkins:
/! Maximum size 1MB /!\
Mounting the secret as a volume
Injecting the secret as an env var
Similar to secrets, but with non-sensitive text-based configuration
ImageChange
- when uderlying image stream changes
ConfigChange
- when the config of the pod template changes
Label examples: release, environment, relationship, dmzbased, tier, node type, user type
Identifying metadata consisting of key/value pairs attached to resources
Annotation examples: example.com/skipValidation=true, example.com/MD5checksum-1234ABC, example.com/BUILDDATE=20171217
Primarily concerned with attaching non-identifying information, which is used by other clients such as tools or libraries
Source-to-Image (S2I): uses the opensource S2I tool to enable developers to reporducibly build images by layering the application's soure onto a container image
Docker: using the Dockerfile
Pipeline: uses Jenkins, developers provide Jenkinsfile containing the requisite build commands
Custom: allows the developer to provide a customized builder image to build runtime image
Git
Dockerfile
Image
Binary
contains the details of the chosen build strategy as well as the source
unless specified otherwise, the oc new-app
command will scan the supplied Git repo. If it finds a Dockerfile, the Docker build strategy will be used; otherwise source strategy will be used and an S2I builder will be configured
Components:
Builder image - installation and runtime dependencies for the app
S2I script - assemble/run/usage/save-artifacts/test/run
Process:
Start an instance of the builder image
Retreive the source artifacts from the specified repository
Place the source artifacts as well as the S2I scripts into the builder image (bundle into .tar and stream into builder image)
Execute assemble script
Commit the image and push to OCP registry
Customize the build process:
Custom S2I scripts - their own assemble/run etc. by placing scripts in .s2i/bin at the base of the source code, can also contain environment file
Custom S2I builder - write your own custom builder
Adding a New Builder Image
Building a Sample Application
Troubleshooting
Adding the --follow flag to the start-build command
oc get builds
oc logs build/test-app-3
oc set env bc/test-app BUILD_LOGLEVEL=5 S2I_DEBUG=true
Operational layers:
Operating system infrastructure operations - compute, network, storage, OS
Cluster operations - cluster managemebt OpenShift/Kubernetes
Application operations - deployments, telemetry, logging
the EFK (Elasticsearch/Fluentd/Kibana) stack aggregates logs from nodes and application pods
the Kubelet/Heapster/Cassandra and you can use Grafana to build dashboard
default behavior:
best effor isolation = no primises what resources can be allocated for your project
might get defaulted values
out of memory killed randomly
might get CPU starved (wait to schedule your workload)
hard constraints how much memory/CPU your project can consume
mechanism for specifying default project CPU and memory limits and requests
you may use project labels or annotations when creating multiproject spanning quotas
Good resource for Jenkinsfiles: