Launch Your First OpenShift Operator

Course

Intro Video

Photo of Treva Williams

Treva Williams

Training Architect

Length

04:00:04

Difficulty

Beginner

Course Details

OpenShift is a Kubernetes distribution certified by CNCF in 2017, for the Enterprise, but it provides so much more than container orchestration. In this course we will walk through the process of spinning up a small dev environment using MiniShift, then create our own Kubernetes Operator using the newly released OpenShift Operator framework.

Links:

https://interactive.linuxacademy.com/diagrams/LauchYourFirstOperator.html

Syllabus

Introduction

About the Course

Intro to Linux Academy

00:01:39

Lesson Description:

Greetings & welcome to my new course on deploying your first Operator using OpenShift! Follow along with the course using this Interactive Diagram.

About the Instructors

00:00:52

Lesson Description:

am an RHCSA 7 Certified Linux and OpenStack sysadmin and content author for Linux Academy. Before starting with Linux Academy, I was a virtualization administrator for 5 years managing Rackspace public cloud infrastructure. I am an OpenStack active technical contributor to the Pike release and am active in several OpenStack, RDO, and Ceph communities and groups. When not OpenStacking or Cephing, I enjoy doggos, candy, cartoons, and playing "So You Think You're a Marine Biologist" on Google.

What's Covered and What's Not Covered

00:02:04

Lesson Description:

In this course, we're going to have a quick introduction to the operator framework on OpenShift, using MiniShift, the single-node proof-of-concept platform for openshift. this course is targeted towards those already experienced with openshift administration. if openshift is new to you, check out my other courses on openshift, then come back!

OpenShift Essentials

Kubernetes, but Enterprise

What is OpenShift?

00:02:43

Lesson Description:

OpenShift Container Platform is a platform as a service (PaaS) offering from Red Hat that brings together Docker and Kubernetes, and provides an API to manage these services. Openshift has a microservices-based architecture of smaller, decoupled units that work together, running on top of a kubernetes cluster.

OpenShift, Origin, OKD, Oh My!

00:02:15

Lesson Description:

What's the difference between OpenShift, Origin, & OKD, & what does OKD stand for? I'll answer those questions in this quick video reviewing the differences between Upstream & Enterprise OpenShift.

OpenShift Up and Running

MiniShift

About MiniShift

00:01:33

Lesson Description:

What is MiniShift & what are the benefits to using it over openshift-ansible? MiniShift is a fast, lightweight, all-in-one OpenShift cluster running OKD - the upstream version of OpenShift - based on code forked from minikube - another tiny-but-powerful dev environment for learning vanilla Kubernetes. It runs OpenShift Origin/OKD in a single VM that is provisioned using the libmachine driver borrowed from Docker, & contains everything you need to familiarize yourself with OpenShift, or to develop new applications for production on the go.

Install MiniShift on Linux

00:07:45

Lesson Description:

MiniShift can be run on RPM-based or .deb systems so long as the Docker Machine KVM driver, named docker-machine-driver-kvm is installed. RPM Linux (RHEL, CentOS, Fedora, etc) Install libvirt & qemu-kvm $ sudo dnf install libvirt qemu-kvm If running as a non-root user, add $user to the libvirt (or libvirtd on Ubuntu versions older than 18.10) group $ sudo usermod -aG libvirt <username> Update your current session to apply changes: $ newgrp libvirt As root, install the Docker KVM driver under /usr/local/bin # curl -L https://github.com/dhiltgen/docker-machine-kvm/releases/download/v0.10.0/docker-machine-driver-kvm-centos7 -o /usr/local/bin/docker-machine-driver-kvm Verify that docker-machine-driver-kvm is executable: # chmod +x /usr/local/bin/docker-machine-driver-kvm .Deb Linux (Ubuntu, Debian, etc.) install libvirt & qemu-kvm (note: package may be named libvirt-bin on Ubuntu versions older than 18.10) $ sudo apt install qemu-kvm libvirt-daemon libvirt-daemon-system If running as a non-root user, add $user to the libvirt (or libvirtd on Ubuntu versions older than 18.10) group $ sudo usermod -a -G libvirt <username> Update your current session to apply changes: $ newgrp libvirt(d) As root, install the Docker KVM driver under /usr/local/bin/ Ubuntu 16.04 & higher: # curl -L https://github.com/dhiltgen/docker-machine-kvm/releases/download/v0.10.0/docker-machine-driver-kvm-ubuntu16.04 -o /usr/local/bin/docker-machine-driver-kvm Ubuntu 14.04: # curl -L https://github.com/dhiltgen/docker-machine-kvm/releases/download/v0.10.0/docker-machine-driver-kvm-ubuntu14.04 -o /usr/local/bin/docker-machine-driver-kvm Make sure that docker-machine-driver-kvm is executable # chmod +x /usr/local/bin/docker-machine-driver-kvm On both: Enable & start the libvirtd service $ sudo systemctl enable --now libvirtd

Installing MiniShift on MacOSX

00:02:45

Lesson Description:

Use Homebrew to install the docker-machine-driver-xhyve hypervisor $ brew install docker-machine-driver-xhyve Enable root access for docker-machine-driver-xhyve & add it to wheel $ sudo chown root:wheel $(brew --prefix)/opt/docker-machine-driver-xhyve/bin/docker-machine-driver-xhyve Set the SUID for the binary $ sudo chmod u+s $(brew --prefix)/opt/docker-machine-driver-xhyve/bin/docker-machine-driver-xhyve

Install MiniShift on Windows

00:04:29

Lesson Description:

Minishift can run on Windows 7/8/10 machines using either Hyper-v or VirtualBox as a hypervisor. In this video, I will guide you through installing MiniShift using Virtualbox on Windows 8.

Using MiniShift

00:09:20

Lesson Description:

Now that MiniShift is installed, we can start our first cluster with the command: minishift start. In this video I'll show you how to start a simple cluster, how to customize RAM & CPUs, & how to clean up your system once you've completed development.

The Operator Framework

OpenShift Operator Framework

What are Operators?

00:03:38

Lesson Description:

The Operator Framework, currently in Technology preview with OpenShift v3.11, is an open source project that provides developer and runtime Kubernetes tools, enabling you to accelerate the development of an Operator. The Operator Framework includes: Operator SDK a toolkit that enables developers to build operators based on their own expertise, without requiring knowledge of K8s API complexities. Operator Lifecycle Manager Oversees installation, updates, & management of the lifecycle of all of the operators (& their associated services) running across a K8s cluster. Operator Metering Enables usage reporting for operators that provide specialized services

The Operator Lifecycle Manager

00:03:42

Lesson Description:

The Operator Lifecycle Manager project is a component of the Operator Framework, an open source toolkit to manage Kubernetes native applications, called Operators, in an effective, automated, and scalable way. The OLM extends Kubernetes to provide a declarative way to install, manage, and upgrade operators and their dependencies in a cluster, & also enforces some constraints on the components it manages in order to ensure a good user experience. OLM enables users to: Define applications as a single Kubernetes resource that encapsulates requirements and metadata.Install applications automatically with dependency resolution or manually with nothing but kubectl.Upgrade applications automatically with different approval policies. It consists of the following objects: CustomResourceDefinitions: Subscription, InstallPlan, CatalogSource, ClusterServiceVersion Namespace: openshift-operator-lifecycle-manager Service Account: olm-operator-serviceaccount ClusterRole: system:controller:operator-lifecycle-manager ClusterRoleBinding: olm-operator-binding-openshift-operator-lifecycle-manager CatalogSource: rh-operators ConfigMap: rh-operators Deployments: olm-operator, catalog-operator, package-server

Install the Operator Lifecycle Manager on Minishift

00:06:17

Lesson Description:

Installing the OpenShift Operator lifecycle manager on MiniShift After launching a Minishift cluster, use the following instructions to deploy the Operator Lifecycle Manager & its components. Clone the official OLM repository: $ git clone https://github.com/operator-framework/operator-lifecycle-manager install required objects: $ oc create -f operator-lifecycle-manager/deploy/okd/manifests/0.7.2/ Verify that OLM CustomResourceDefinitions are available oc get crds Verify that the operators are currently running under the openshift-operator-lifecycle-manager namespace: oc -n openshift-operator-lifecycle-manager get deploy Verify that the CatalogSource & CatalogSource ConfigMap exist: oc -n openshift-operator-lifecycle-manager get catalogsource oc -n openshift-operator-lifecycle-manager get configmap

Launch an etcd Operator

00:06:05

Lesson Description:

Launch an etcd Operator Operators take the pressure off of systems administrators by ensuring that pods remain at a consistent count, replacing any deleted, destroyed, or damaged pods automatically. Launch an etcd operator using the template below, or by using the templates under the `content-deploy-an-operator/etcd-operator Github. create etcd subscription named etcd-alpha-subscription.yaml: apiVersion: operators.coreos.com/v1alpha1 kind: Subscription metadata: name: etcd namespace: myproject spec: channel: alpha name: etcd source: rh-operators installPlanApproval: Manual Approving the InstallPlan Modify the InstallPlan and set approved to true. $ oc edit InstallPlan Once the InstallPlan is set to true, you will see the newly provisioned ClusterServiceVersion, ClusterResourceDefinition, Role and RoleBindings, Service Accounts, and etcd-operator Deployment. oc get clusterserviceversion oc get crd oc get sa oc get roles oc get rolebindings oc get deployments Creating the Custom Resource Create the etcd-cluster.yaml Cluster manifest. apiVersion: etcd.database.coreos.com/v1beta2 kind: EtcdCluster metadata: name: example-etcd-cluster spec: size: 3 EOF Create the etcd-cluster. oc create -f etcd-cluster.yaml Confirm the cluster has been created: $ oc get etcdcluster $ oc get pods

Hands-on Labs are real live environments that put you in a real scenario to practice what you have learned without any other extra charge or account to manage.

01:30:00

Hands-on Labs are real live environments that put you in a real scenario to practice what you have learned without any other extra charge or account to manage.

01:30:00

Closing

Use Your Resources

OpenShift Commons

00:02:53

Lesson Description:

Now that you're familiar with Operators on OpenShift, join the OpenShift Commons community to interact with other 'Shifters!

Join the Community

00:01:55

Lesson Description:

Don't forget, as a Linux Academy member you have access to a robust community of fellow students & instructors available to you, as well as a #Slack channel especially for you.