![Page 1: WRITING YOUR FIRST ANSIBLE OPERATOR FOR OPENSHIFT · Manage application objects 01001 etcd data 01001 etcd data @KeithResar A GIFT OF THE _DEMO_ TO YOU ... RUN yum -y install MySQL-python](https://reader030.vdocuments.us/reader030/viewer/2022040306/5ec7e348a70344178f308a33/html5/thumbnails/1.jpg)
@KeithResar
WRITING YOUR FIRST_ANSIBLE OPERATOR_
FOR OPENSHIFT
![Page 2: WRITING YOUR FIRST ANSIBLE OPERATOR FOR OPENSHIFT · Manage application objects 01001 etcd data 01001 etcd data @KeithResar A GIFT OF THE _DEMO_ TO YOU ... RUN yum -y install MySQL-python](https://reader030.vdocuments.us/reader030/viewer/2022040306/5ec7e348a70344178f308a33/html5/thumbnails/2.jpg)
![Page 3: WRITING YOUR FIRST ANSIBLE OPERATOR FOR OPENSHIFT · Manage application objects 01001 etcd data 01001 etcd data @KeithResar A GIFT OF THE _DEMO_ TO YOU ... RUN yum -y install MySQL-python](https://reader030.vdocuments.us/reader030/viewer/2022040306/5ec7e348a70344178f308a33/html5/thumbnails/3.jpg)
@KeithResar
Operators are _application aware Kubernetes objects._
Active throughout the application’s lifecycle, they manage instantiation, ongoing state, and destruction.
![Page 4: WRITING YOUR FIRST ANSIBLE OPERATOR FOR OPENSHIFT · Manage application objects 01001 etcd data 01001 etcd data @KeithResar A GIFT OF THE _DEMO_ TO YOU ... RUN yum -y install MySQL-python](https://reader030.vdocuments.us/reader030/viewer/2022040306/5ec7e348a70344178f308a33/html5/thumbnails/4.jpg)
![Page 5: WRITING YOUR FIRST ANSIBLE OPERATOR FOR OPENSHIFT · Manage application objects 01001 etcd data 01001 etcd data @KeithResar A GIFT OF THE _DEMO_ TO YOU ... RUN yum -y install MySQL-python](https://reader030.vdocuments.us/reader030/viewer/2022040306/5ec7e348a70344178f308a33/html5/thumbnails/5.jpg)
@KeithResar
FROM VISION TO _PROBLEM_
![Page 6: WRITING YOUR FIRST ANSIBLE OPERATOR FOR OPENSHIFT · Manage application objects 01001 etcd data 01001 etcd data @KeithResar A GIFT OF THE _DEMO_ TO YOU ... RUN yum -y install MySQL-python](https://reader030.vdocuments.us/reader030/viewer/2022040306/5ec7e348a70344178f308a33/html5/thumbnails/6.jpg)
@KeithResar
_problem:_ _turnkey management of stateless application_
_solution:_ _kubernetes (we just saw this)_ _S2I, Helm_
![Page 7: WRITING YOUR FIRST ANSIBLE OPERATOR FOR OPENSHIFT · Manage application objects 01001 etcd data 01001 etcd data @KeithResar A GIFT OF THE _DEMO_ TO YOU ... RUN yum -y install MySQL-python](https://reader030.vdocuments.us/reader030/viewer/2022040306/5ec7e348a70344178f308a33/html5/thumbnails/7.jpg)
@KeithResar
![Page 8: WRITING YOUR FIRST ANSIBLE OPERATOR FOR OPENSHIFT · Manage application objects 01001 etcd data 01001 etcd data @KeithResar A GIFT OF THE _DEMO_ TO YOU ... RUN yum -y install MySQL-python](https://reader030.vdocuments.us/reader030/viewer/2022040306/5ec7e348a70344178f308a33/html5/thumbnails/8.jpg)
@KeithResar
_build image from_ _source_
![Page 9: WRITING YOUR FIRST ANSIBLE OPERATOR FOR OPENSHIFT · Manage application objects 01001 etcd data 01001 etcd data @KeithResar A GIFT OF THE _DEMO_ TO YOU ... RUN yum -y install MySQL-python](https://reader030.vdocuments.us/reader030/viewer/2022040306/5ec7e348a70344178f308a33/html5/thumbnails/9.jpg)
@KeithResar
_intra-cluster traffic_ _management_
![Page 10: WRITING YOUR FIRST ANSIBLE OPERATOR FOR OPENSHIFT · Manage application objects 01001 etcd data 01001 etcd data @KeithResar A GIFT OF THE _DEMO_ TO YOU ... RUN yum -y install MySQL-python](https://reader030.vdocuments.us/reader030/viewer/2022040306/5ec7e348a70344178f308a33/html5/thumbnails/10.jpg)
@KeithResar
_application runtime__configuration_
![Page 11: WRITING YOUR FIRST ANSIBLE OPERATOR FOR OPENSHIFT · Manage application objects 01001 etcd data 01001 etcd data @KeithResar A GIFT OF THE _DEMO_ TO YOU ... RUN yum -y install MySQL-python](https://reader030.vdocuments.us/reader030/viewer/2022040306/5ec7e348a70344178f308a33/html5/thumbnails/11.jpg)
@KeithResar
_external traffic_
![Page 12: WRITING YOUR FIRST ANSIBLE OPERATOR FOR OPENSHIFT · Manage application objects 01001 etcd data 01001 etcd data @KeithResar A GIFT OF THE _DEMO_ TO YOU ... RUN yum -y install MySQL-python](https://reader030.vdocuments.us/reader030/viewer/2022040306/5ec7e348a70344178f308a33/html5/thumbnails/12.jpg)
@KeithResar
![Page 13: WRITING YOUR FIRST ANSIBLE OPERATOR FOR OPENSHIFT · Manage application objects 01001 etcd data 01001 etcd data @KeithResar A GIFT OF THE _DEMO_ TO YOU ... RUN yum -y install MySQL-python](https://reader030.vdocuments.us/reader030/viewer/2022040306/5ec7e348a70344178f308a33/html5/thumbnails/13.jpg)
![Page 14: WRITING YOUR FIRST ANSIBLE OPERATOR FOR OPENSHIFT · Manage application objects 01001 etcd data 01001 etcd data @KeithResar A GIFT OF THE _DEMO_ TO YOU ... RUN yum -y install MySQL-python](https://reader030.vdocuments.us/reader030/viewer/2022040306/5ec7e348a70344178f308a33/html5/thumbnails/14.jpg)
@KeithResar
_problem:_ _I’m a vendor or I create stateful apps,_kubernetes doesn’t know anything about me_
![Page 15: WRITING YOUR FIRST ANSIBLE OPERATOR FOR OPENSHIFT · Manage application objects 01001 etcd data 01001 etcd data @KeithResar A GIFT OF THE _DEMO_ TO YOU ... RUN yum -y install MySQL-python](https://reader030.vdocuments.us/reader030/viewer/2022040306/5ec7e348a70344178f308a33/html5/thumbnails/15.jpg)
@KeithResar
etcd is a _distributed key value store_ that provides a reliable way to store data across a cluster of machines.
Stand-in for
your app
![Page 16: WRITING YOUR FIRST ANSIBLE OPERATOR FOR OPENSHIFT · Manage application objects 01001 etcd data 01001 etcd data @KeithResar A GIFT OF THE _DEMO_ TO YOU ... RUN yum -y install MySQL-python](https://reader030.vdocuments.us/reader030/viewer/2022040306/5ec7e348a70344178f308a33/html5/thumbnails/16.jpg)
@KeithResar
Create and Destroy • Resize • FailoverRolling upgrade • Backup and Restore
Stand-in for
your app
![Page 17: WRITING YOUR FIRST ANSIBLE OPERATOR FOR OPENSHIFT · Manage application objects 01001 etcd data 01001 etcd data @KeithResar A GIFT OF THE _DEMO_ TO YOU ... RUN yum -y install MySQL-python](https://reader030.vdocuments.us/reader030/viewer/2022040306/5ec7e348a70344178f308a33/html5/thumbnails/17.jpg)
@KeithResar
_problem:_ _I’m a vendor or I create stateful apps,_kubernetes doesn’t know anything about me_
_solution:_ _create custom resource definitions (CRD)_
![Page 18: WRITING YOUR FIRST ANSIBLE OPERATOR FOR OPENSHIFT · Manage application objects 01001 etcd data 01001 etcd data @KeithResar A GIFT OF THE _DEMO_ TO YOU ... RUN yum -y install MySQL-python](https://reader030.vdocuments.us/reader030/viewer/2022040306/5ec7e348a70344178f308a33/html5/thumbnails/18.jpg)
@KeithResar
---apiVersion: v1kind: Servicemetadata: name: simpleappspec: ports: - name: 8080-tcp port: 8080 protocol: TCP targetPort: 8080 selector: deploymentconfig: simpleapp sessionAffinity: None type: ClusterIP
defining a _service_ resource
service resources are a built in object type.
![Page 19: WRITING YOUR FIRST ANSIBLE OPERATOR FOR OPENSHIFT · Manage application objects 01001 etcd data 01001 etcd data @KeithResar A GIFT OF THE _DEMO_ TO YOU ... RUN yum -y install MySQL-python](https://reader030.vdocuments.us/reader030/viewer/2022040306/5ec7e348a70344178f308a33/html5/thumbnails/19.jpg)
@KeithResar
---apiVersion: etcd.database.coreos.com/v1beta2kind: EtcdClustermetadata: name: example-etcd-clusterspec: size: 3 version: "3.2.13"
defining an _EtcdCluster_ resource
Our custom resource looks pretty similar.
![Page 20: WRITING YOUR FIRST ANSIBLE OPERATOR FOR OPENSHIFT · Manage application objects 01001 etcd data 01001 etcd data @KeithResar A GIFT OF THE _DEMO_ TO YOU ... RUN yum -y install MySQL-python](https://reader030.vdocuments.us/reader030/viewer/2022040306/5ec7e348a70344178f308a33/html5/thumbnails/20.jpg)
@KeithResar
_problem:_ _golang isn’t going to fly_
_solution:_ _skip go, succeed with helm charts or ansible_
![Page 21: WRITING YOUR FIRST ANSIBLE OPERATOR FOR OPENSHIFT · Manage application objects 01001 etcd data 01001 etcd data @KeithResar A GIFT OF THE _DEMO_ TO YOU ... RUN yum -y install MySQL-python](https://reader030.vdocuments.us/reader030/viewer/2022040306/5ec7e348a70344178f308a33/html5/thumbnails/21.jpg)
![Page 22: WRITING YOUR FIRST ANSIBLE OPERATOR FOR OPENSHIFT · Manage application objects 01001 etcd data 01001 etcd data @KeithResar A GIFT OF THE _DEMO_ TO YOU ... RUN yum -y install MySQL-python](https://reader030.vdocuments.us/reader030/viewer/2022040306/5ec7e348a70344178f308a33/html5/thumbnails/22.jpg)
@KeithResar
EVERY PROBLEM BRINGS A _SOLUTION_
![Page 23: WRITING YOUR FIRST ANSIBLE OPERATOR FOR OPENSHIFT · Manage application objects 01001 etcd data 01001 etcd data @KeithResar A GIFT OF THE _DEMO_ TO YOU ... RUN yum -y install MySQL-python](https://reader030.vdocuments.us/reader030/viewer/2022040306/5ec7e348a70344178f308a33/html5/thumbnails/23.jpg)
@KeithResar
DS AS
API Server Cluster Workload
Compare desired state with actual stateReconcile process converges to desired state
![Page 24: WRITING YOUR FIRST ANSIBLE OPERATOR FOR OPENSHIFT · Manage application objects 01001 etcd data 01001 etcd data @KeithResar A GIFT OF THE _DEMO_ TO YOU ... RUN yum -y install MySQL-python](https://reader030.vdocuments.us/reader030/viewer/2022040306/5ec7e348a70344178f308a33/html5/thumbnails/24.jpg)
@KeithResar
DS AS
API Server010100010101001010101011010110010101001
010100010101001010101011010110010101001
Cluster Workload010100010101001010101011010110010101001
1x simpleapp 2x simpleapp
010100010101001010101011010110010101001
![Page 25: WRITING YOUR FIRST ANSIBLE OPERATOR FOR OPENSHIFT · Manage application objects 01001 etcd data 01001 etcd data @KeithResar A GIFT OF THE _DEMO_ TO YOU ... RUN yum -y install MySQL-python](https://reader030.vdocuments.us/reader030/viewer/2022040306/5ec7e348a70344178f308a33/html5/thumbnails/25.jpg)
@KeithResar
DS AS
API Server Cluster Workload
Native K8s objects like...PodsServicesRoutesetc.
![Page 26: WRITING YOUR FIRST ANSIBLE OPERATOR FOR OPENSHIFT · Manage application objects 01001 etcd data 01001 etcd data @KeithResar A GIFT OF THE _DEMO_ TO YOU ... RUN yum -y install MySQL-python](https://reader030.vdocuments.us/reader030/viewer/2022040306/5ec7e348a70344178f308a33/html5/thumbnails/26.jpg)
@KeithResar
ASDS_* operator_
watch reconcile
action___________________________________________________________________
![Page 27: WRITING YOUR FIRST ANSIBLE OPERATOR FOR OPENSHIFT · Manage application objects 01001 etcd data 01001 etcd data @KeithResar A GIFT OF THE _DEMO_ TO YOU ... RUN yum -y install MySQL-python](https://reader030.vdocuments.us/reader030/viewer/2022040306/5ec7e348a70344178f308a33/html5/thumbnails/27.jpg)
@KeithResar
ASDS_Ansible operator_
watch reconcile
ansible-runner___________________________________________________________________
Ansible playbook or roleThis is the only component you need to worry about!
![Page 28: WRITING YOUR FIRST ANSIBLE OPERATOR FOR OPENSHIFT · Manage application objects 01001 etcd data 01001 etcd data @KeithResar A GIFT OF THE _DEMO_ TO YOU ... RUN yum -y install MySQL-python](https://reader030.vdocuments.us/reader030/viewer/2022040306/5ec7e348a70344178f308a33/html5/thumbnails/28.jpg)
@KeithResar
kubernetes layer
application layer
![Page 29: WRITING YOUR FIRST ANSIBLE OPERATOR FOR OPENSHIFT · Manage application objects 01001 etcd data 01001 etcd data @KeithResar A GIFT OF THE _DEMO_ TO YOU ... RUN yum -y install MySQL-python](https://reader030.vdocuments.us/reader030/viewer/2022040306/5ec7e348a70344178f308a33/html5/thumbnails/29.jpg)
@KeithResar
kubernetes layer
ETCDpod
ETCDpodPhase I
Manage native K8s objects
application layer
![Page 30: WRITING YOUR FIRST ANSIBLE OPERATOR FOR OPENSHIFT · Manage application objects 01001 etcd data 01001 etcd data @KeithResar A GIFT OF THE _DEMO_ TO YOU ... RUN yum -y install MySQL-python](https://reader030.vdocuments.us/reader030/viewer/2022040306/5ec7e348a70344178f308a33/html5/thumbnails/30.jpg)
@KeithResar
![Page 31: WRITING YOUR FIRST ANSIBLE OPERATOR FOR OPENSHIFT · Manage application objects 01001 etcd data 01001 etcd data @KeithResar A GIFT OF THE _DEMO_ TO YOU ... RUN yum -y install MySQL-python](https://reader030.vdocuments.us/reader030/viewer/2022040306/5ec7e348a70344178f308a33/html5/thumbnails/31.jpg)
@KeithResar
![Page 32: WRITING YOUR FIRST ANSIBLE OPERATOR FOR OPENSHIFT · Manage application objects 01001 etcd data 01001 etcd data @KeithResar A GIFT OF THE _DEMO_ TO YOU ... RUN yum -y install MySQL-python](https://reader030.vdocuments.us/reader030/viewer/2022040306/5ec7e348a70344178f308a33/html5/thumbnails/32.jpg)
@KeithResar
![Page 33: WRITING YOUR FIRST ANSIBLE OPERATOR FOR OPENSHIFT · Manage application objects 01001 etcd data 01001 etcd data @KeithResar A GIFT OF THE _DEMO_ TO YOU ... RUN yum -y install MySQL-python](https://reader030.vdocuments.us/reader030/viewer/2022040306/5ec7e348a70344178f308a33/html5/thumbnails/33.jpg)
@KeithResar
application layer
kubernetes layer
ETCDpod
ETCDpodPhase II
Manage application objects
01001etcd data
01001etcd data
![Page 34: WRITING YOUR FIRST ANSIBLE OPERATOR FOR OPENSHIFT · Manage application objects 01001 etcd data 01001 etcd data @KeithResar A GIFT OF THE _DEMO_ TO YOU ... RUN yum -y install MySQL-python](https://reader030.vdocuments.us/reader030/viewer/2022040306/5ec7e348a70344178f308a33/html5/thumbnails/34.jpg)
![Page 35: WRITING YOUR FIRST ANSIBLE OPERATOR FOR OPENSHIFT · Manage application objects 01001 etcd data 01001 etcd data @KeithResar A GIFT OF THE _DEMO_ TO YOU ... RUN yum -y install MySQL-python](https://reader030.vdocuments.us/reader030/viewer/2022040306/5ec7e348a70344178f308a33/html5/thumbnails/35.jpg)
@KeithResar
A GIFT OF THE _DEMO_ TO YOU
![Page 36: WRITING YOUR FIRST ANSIBLE OPERATOR FOR OPENSHIFT · Manage application objects 01001 etcd data 01001 etcd data @KeithResar A GIFT OF THE _DEMO_ TO YOU ... RUN yum -y install MySQL-python](https://reader030.vdocuments.us/reader030/viewer/2022040306/5ec7e348a70344178f308a33/html5/thumbnails/36.jpg)
@KeithResar
Demo Operator for data service _SimpleDB,_ that manages instantiation and version upgrades.
RBAC
CRD
CR
DC
![Page 37: WRITING YOUR FIRST ANSIBLE OPERATOR FOR OPENSHIFT · Manage application objects 01001 etcd data 01001 etcd data @KeithResar A GIFT OF THE _DEMO_ TO YOU ... RUN yum -y install MySQL-python](https://reader030.vdocuments.us/reader030/viewer/2022040306/5ec7e348a70344178f308a33/html5/thumbnails/37.jpg)
@KeithResar
Create service account, role, and role binding. Our operator uses these to monitor events and reconcile desired and actual states.
RBAC
CRD
CR
DC
![Page 38: WRITING YOUR FIRST ANSIBLE OPERATOR FOR OPENSHIFT · Manage application objects 01001 etcd data 01001 etcd data @KeithResar A GIFT OF THE _DEMO_ TO YOU ... RUN yum -y install MySQL-python](https://reader030.vdocuments.us/reader030/viewer/2022040306/5ec7e348a70344178f308a33/html5/thumbnails/38.jpg)
@KeithResar
ASDS_Ansible operator_
watch reconcile
ansible-runner___________________________________________________________________
![Page 39: WRITING YOUR FIRST ANSIBLE OPERATOR FOR OPENSHIFT · Manage application objects 01001 etcd data 01001 etcd data @KeithResar A GIFT OF THE _DEMO_ TO YOU ... RUN yum -y install MySQL-python](https://reader030.vdocuments.us/reader030/viewer/2022040306/5ec7e348a70344178f308a33/html5/thumbnails/39.jpg)
@KeithResar
RBAC
CRD
CR
DC
---apiVersion: v1kind: ServiceAccountmetadata: name: simpledb---apiVersion: rbac.authorization.k8s.io/v1kind: Rolemetadata: name: simpledbrules: ...---kind: RoleBindingapiVersion: rbac.authorization.k8s.io/v1metadata: name: simpledbsubjects:- kind: ServiceAccount name: simpledbroleRef: kind: Role name: simpledb apiGroup: rbac.authorization.k8s.io
![Page 40: WRITING YOUR FIRST ANSIBLE OPERATOR FOR OPENSHIFT · Manage application objects 01001 etcd data 01001 etcd data @KeithResar A GIFT OF THE _DEMO_ TO YOU ... RUN yum -y install MySQL-python](https://reader030.vdocuments.us/reader030/viewer/2022040306/5ec7e348a70344178f308a33/html5/thumbnails/40.jpg)
@KeithResar
Define the custom resource SimpleDB. This extends what Kubernetes accepts, but doesn’t actually change any behavior.
RBAC
CRD
CR
DC
![Page 41: WRITING YOUR FIRST ANSIBLE OPERATOR FOR OPENSHIFT · Manage application objects 01001 etcd data 01001 etcd data @KeithResar A GIFT OF THE _DEMO_ TO YOU ... RUN yum -y install MySQL-python](https://reader030.vdocuments.us/reader030/viewer/2022040306/5ec7e348a70344178f308a33/html5/thumbnails/41.jpg)
@KeithResar
RBAC
CRD
CR
DC
---apiVersion: apiextensions.k8s.io/v1beta1kind: CustomResourceDefinitionmetadata: name: simpledbs.example.comspec: group: example.com names: kind: SimpleDB listKind: SimpleDBList plural: simpledbs singular: simpledb scope: Namespaced version: v1alpha1
![Page 42: WRITING YOUR FIRST ANSIBLE OPERATOR FOR OPENSHIFT · Manage application objects 01001 etcd data 01001 etcd data @KeithResar A GIFT OF THE _DEMO_ TO YOU ... RUN yum -y install MySQL-python](https://reader030.vdocuments.us/reader030/viewer/2022040306/5ec7e348a70344178f308a33/html5/thumbnails/42.jpg)
@KeithResar
Define and deploy the Ansible Operator container which executes an ansible-runner process.
RBAC
CRD
CR
DC
![Page 43: WRITING YOUR FIRST ANSIBLE OPERATOR FOR OPENSHIFT · Manage application objects 01001 etcd data 01001 etcd data @KeithResar A GIFT OF THE _DEMO_ TO YOU ... RUN yum -y install MySQL-python](https://reader030.vdocuments.us/reader030/viewer/2022040306/5ec7e348a70344178f308a33/html5/thumbnails/43.jpg)
@KeithResar
ASDS_Ansible operator_
watch reconcile
ansible-runner___________________________________________________________________
![Page 44: WRITING YOUR FIRST ANSIBLE OPERATOR FOR OPENSHIFT · Manage application objects 01001 etcd data 01001 etcd data @KeithResar A GIFT OF THE _DEMO_ TO YOU ... RUN yum -y install MySQL-python](https://reader030.vdocuments.us/reader030/viewer/2022040306/5ec7e348a70344178f308a33/html5/thumbnails/44.jpg)
@KeithResar
RBAC
CRD
CR
DC
---apiVersion: apps/v1kind: Deploymentmetadata: name: simpledbspec: template: spec: serviceAccountName: simpledb containers: - name: simpledb image: hk1232/operator-simpledb-runner:0.1 env: - name: WATCH_NAMESPACE valueFrom: fieldRef: fieldPath: metadata.namespace - name: OPERATOR_NAME value: "simpledb"
![Page 45: WRITING YOUR FIRST ANSIBLE OPERATOR FOR OPENSHIFT · Manage application objects 01001 etcd data 01001 etcd data @KeithResar A GIFT OF THE _DEMO_ TO YOU ... RUN yum -y install MySQL-python](https://reader030.vdocuments.us/reader030/viewer/2022040306/5ec7e348a70344178f308a33/html5/thumbnails/45.jpg)
@KeithResar
RBAC
CRD
CR
DC
# Dockerfile
FROM quay.io/water-hole/ansible-operatorUSER root
RUN yum -y install MySQL-python && \ pip --no-cache-dir install dnspython
COPY roles/ ${HOME}/roles/COPY playbook.yaml ${HOME}/playbook.yamlCOPY watches.yaml ${HOME}/watches.yaml
![Page 46: WRITING YOUR FIRST ANSIBLE OPERATOR FOR OPENSHIFT · Manage application objects 01001 etcd data 01001 etcd data @KeithResar A GIFT OF THE _DEMO_ TO YOU ... RUN yum -y install MySQL-python](https://reader030.vdocuments.us/reader030/viewer/2022040306/5ec7e348a70344178f308a33/html5/thumbnails/46.jpg)
@KeithResar
ASDS_Ansible operator_
watch reconcile
ansible-runner___________________________________________________________________
![Page 47: WRITING YOUR FIRST ANSIBLE OPERATOR FOR OPENSHIFT · Manage application objects 01001 etcd data 01001 etcd data @KeithResar A GIFT OF THE _DEMO_ TO YOU ... RUN yum -y install MySQL-python](https://reader030.vdocuments.us/reader030/viewer/2022040306/5ec7e348a70344178f308a33/html5/thumbnails/47.jpg)
@KeithResar
RBAC
CRD
CR
DC
# Dockerfile
FROM quay.io/water-hole/ansible-operatorUSER root
RUN yum -y install MySQL-python && \ pip --no-cache-dir install dnspython
COPY roles/ ${HOME}/roles/COPY playbook.yaml ${HOME}/playbook.yamlCOPY watches.yaml ${HOME}/watches.yaml
![Page 48: WRITING YOUR FIRST ANSIBLE OPERATOR FOR OPENSHIFT · Manage application objects 01001 etcd data 01001 etcd data @KeithResar A GIFT OF THE _DEMO_ TO YOU ... RUN yum -y install MySQL-python](https://reader030.vdocuments.us/reader030/viewer/2022040306/5ec7e348a70344178f308a33/html5/thumbnails/48.jpg)
@KeithResar
RBAC
CRD
CR
DC
---apiVersion: apps/v1kind: Deploymentmetadata: name: simpledbspec: template: spec: serviceAccountName: simpledb containers: - name: simpledb image: hk1232/operator-simpledb-runner:0.1 env: - name: WATCH_NAMESPACE valueFrom: fieldRef: fieldPath: metadata.namespace - name: OPERATOR_NAME value: "simpledb"
![Page 49: WRITING YOUR FIRST ANSIBLE OPERATOR FOR OPENSHIFT · Manage application objects 01001 etcd data 01001 etcd data @KeithResar A GIFT OF THE _DEMO_ TO YOU ... RUN yum -y install MySQL-python](https://reader030.vdocuments.us/reader030/viewer/2022040306/5ec7e348a70344178f308a33/html5/thumbnails/49.jpg)
@KeithResar
ASDS_Ansible operator_
watch reconcile
ansible-runner___________________________________________________________________
![Page 50: WRITING YOUR FIRST ANSIBLE OPERATOR FOR OPENSHIFT · Manage application objects 01001 etcd data 01001 etcd data @KeithResar A GIFT OF THE _DEMO_ TO YOU ... RUN yum -y install MySQL-python](https://reader030.vdocuments.us/reader030/viewer/2022040306/5ec7e348a70344178f308a33/html5/thumbnails/50.jpg)
@KeithResar
RBAC
CRD
CR
DC
# watches.yml---
- version: v1alpha1 group: example.com kind: SimpleDB playbook: /opt/ansible/playbook.yaml
![Page 51: WRITING YOUR FIRST ANSIBLE OPERATOR FOR OPENSHIFT · Manage application objects 01001 etcd data 01001 etcd data @KeithResar A GIFT OF THE _DEMO_ TO YOU ... RUN yum -y install MySQL-python](https://reader030.vdocuments.us/reader030/viewer/2022040306/5ec7e348a70344178f308a33/html5/thumbnails/51.jpg)
@KeithResar
RBAC
CRD
CR
DC
# playbook.yml---
- hosts: localhost gather_facts: no
tasks: - import_role: name: "SimpleDB"
![Page 52: WRITING YOUR FIRST ANSIBLE OPERATOR FOR OPENSHIFT · Manage application objects 01001 etcd data 01001 etcd data @KeithResar A GIFT OF THE _DEMO_ TO YOU ... RUN yum -y install MySQL-python](https://reader030.vdocuments.us/reader030/viewer/2022040306/5ec7e348a70344178f308a33/html5/thumbnails/52.jpg)
@KeithResar
RBAC
CRD
CR
DC
# roles/SimpleDB/tasks/main.yml---
![Page 53: WRITING YOUR FIRST ANSIBLE OPERATOR FOR OPENSHIFT · Manage application objects 01001 etcd data 01001 etcd data @KeithResar A GIFT OF THE _DEMO_ TO YOU ... RUN yum -y install MySQL-python](https://reader030.vdocuments.us/reader030/viewer/2022040306/5ec7e348a70344178f308a33/html5/thumbnails/53.jpg)
@KeithResar
RBAC
CRD
CR
DC
# roles/SimpleDB/tasks/main.yml---
# … (skip setting some variables)
![Page 54: WRITING YOUR FIRST ANSIBLE OPERATOR FOR OPENSHIFT · Manage application objects 01001 etcd data 01001 etcd data @KeithResar A GIFT OF THE _DEMO_ TO YOU ... RUN yum -y install MySQL-python](https://reader030.vdocuments.us/reader030/viewer/2022040306/5ec7e348a70344178f308a33/html5/thumbnails/54.jpg)
@KeithResar
RBAC
CRD
CR
DC
# roles/SimpleDB/tasks/main.yml---
# … (skip setting some variables)
# If no service defined then run our install playbook# This is idempotent so we could run it regardless- include_tasks: mariadb_install.yml when: mysql_ip == "NXDOMAIN"
![Page 55: WRITING YOUR FIRST ANSIBLE OPERATOR FOR OPENSHIFT · Manage application objects 01001 etcd data 01001 etcd data @KeithResar A GIFT OF THE _DEMO_ TO YOU ... RUN yum -y install MySQL-python](https://reader030.vdocuments.us/reader030/viewer/2022040306/5ec7e348a70344178f308a33/html5/thumbnails/55.jpg)
@KeithResar
RBAC
CRD
CR
DC
# roles/SimpleDB/tasks/main.yml---
# … (skip setting some variables)
# If no service defined then run our install playbook# This is idempotent so we could run it regardless- include_tasks: mariadb_install.yml when: mysql_ip == "NXDOMAIN"
# Run our upgrade path if we need to change versions- include_tasks: mariadb_upgrade.yml when: version != version_query.json.version
![Page 56: WRITING YOUR FIRST ANSIBLE OPERATOR FOR OPENSHIFT · Manage application objects 01001 etcd data 01001 etcd data @KeithResar A GIFT OF THE _DEMO_ TO YOU ... RUN yum -y install MySQL-python](https://reader030.vdocuments.us/reader030/viewer/2022040306/5ec7e348a70344178f308a33/html5/thumbnails/56.jpg)
@KeithResar
Define and deploy the Ansible Operator container which executes an ansible-runner process.
RBAC
CRD
CR
DC
![Page 57: WRITING YOUR FIRST ANSIBLE OPERATOR FOR OPENSHIFT · Manage application objects 01001 etcd data 01001 etcd data @KeithResar A GIFT OF THE _DEMO_ TO YOU ... RUN yum -y install MySQL-python](https://reader030.vdocuments.us/reader030/viewer/2022040306/5ec7e348a70344178f308a33/html5/thumbnails/57.jpg)
@KeithResar
ASDS_Ansible operator_
watch reconcile
ansible-runner___________________________________________________________________
![Page 58: WRITING YOUR FIRST ANSIBLE OPERATOR FOR OPENSHIFT · Manage application objects 01001 etcd data 01001 etcd data @KeithResar A GIFT OF THE _DEMO_ TO YOU ... RUN yum -y install MySQL-python](https://reader030.vdocuments.us/reader030/viewer/2022040306/5ec7e348a70344178f308a33/html5/thumbnails/58.jpg)
@KeithResar
Instantiate our custom resource object. The operator is listening for any SimpleDB events in our namespace.
RBAC
CRD
CR
DC
![Page 59: WRITING YOUR FIRST ANSIBLE OPERATOR FOR OPENSHIFT · Manage application objects 01001 etcd data 01001 etcd data @KeithResar A GIFT OF THE _DEMO_ TO YOU ... RUN yum -y install MySQL-python](https://reader030.vdocuments.us/reader030/viewer/2022040306/5ec7e348a70344178f308a33/html5/thumbnails/59.jpg)
@KeithResar
RBAC
CRD
CR
DC
---apiVersion: example.com/v1alpha1kind: SimpleDBmetadata: name: simpledbspec: # Add fields here version: 1
![Page 60: WRITING YOUR FIRST ANSIBLE OPERATOR FOR OPENSHIFT · Manage application objects 01001 etcd data 01001 etcd data @KeithResar A GIFT OF THE _DEMO_ TO YOU ... RUN yum -y install MySQL-python](https://reader030.vdocuments.us/reader030/viewer/2022040306/5ec7e348a70344178f308a33/html5/thumbnails/60.jpg)
@KeithResar
ASDS_Ansible operator_
watch reconcile
ansible-runner___________________________________________________________________
Ansible playbook or roleThis is the only component you need to worry about!
![Page 61: WRITING YOUR FIRST ANSIBLE OPERATOR FOR OPENSHIFT · Manage application objects 01001 etcd data 01001 etcd data @KeithResar A GIFT OF THE _DEMO_ TO YOU ... RUN yum -y install MySQL-python](https://reader030.vdocuments.us/reader030/viewer/2022040306/5ec7e348a70344178f308a33/html5/thumbnails/61.jpg)
![Page 62: WRITING YOUR FIRST ANSIBLE OPERATOR FOR OPENSHIFT · Manage application objects 01001 etcd data 01001 etcd data @KeithResar A GIFT OF THE _DEMO_ TO YOU ... RUN yum -y install MySQL-python](https://reader030.vdocuments.us/reader030/viewer/2022040306/5ec7e348a70344178f308a33/html5/thumbnails/62.jpg)
@KeithResar
GO FARTHER WITH THESE _RESOURCES_
● Introducing the operator framework● water-hole’s ansible-operator repo● ansible-operator-demo repo● Awesome operators in the wild
![Page 63: WRITING YOUR FIRST ANSIBLE OPERATOR FOR OPENSHIFT · Manage application objects 01001 etcd data 01001 etcd data @KeithResar A GIFT OF THE _DEMO_ TO YOU ... RUN yum -y install MySQL-python](https://reader030.vdocuments.us/reader030/viewer/2022040306/5ec7e348a70344178f308a33/html5/thumbnails/63.jpg)
@KeithResar
THANKS