+ All Categories
Home > Documents > Ansible Kubernetes Operators ATL Slide Decks/Kubernetes Operators _heart_...K8S API Resource WATCH...

Ansible Kubernetes Operators ATL Slide Decks/Kubernetes Operators _heart_...K8S API Resource WATCH...

Date post: 30-May-2020
Category:
Upload: others
View: 7 times
Download: 0 times
Share this document with a friend
14
Kubernetes Operators Ansible Shawn Hurley Principal Software Engineer
Transcript
Page 1: Ansible Kubernetes Operators ATL Slide Decks/Kubernetes Operators _heart_...K8S API Resource WATCH EVENTS RECONCILE Action/s in cluster Controller Encode human operational knowledge

Kubernetes Operators ❤Ansible

Shawn HurleyPrincipal Software Engineer

Page 2: Ansible Kubernetes Operators ATL Slide Decks/Kubernetes Operators _heart_...K8S API Resource WATCH EVENTS RECONCILE Action/s in cluster Controller Encode human operational knowledge

Share your automation story

1. How did you get started with Ansible?

2. How long have you been using it?

3. What's your favorite thing to do when you Ansible?

Page 3: Ansible Kubernetes Operators ATL Slide Decks/Kubernetes Operators _heart_...K8S API Resource WATCH EVENTS RECONCILE Action/s in cluster Controller Encode human operational knowledge

What is Kubernetes?An open source orchestration system for implementing a microservices architecture as containerized applications run and are coordinated across a cluster of nodes.

Manage how containerized apps interact with other apps or the outside world

Run distributed systems resiliently across a cluster of nodes

Perform health checks

Scale your services up or down

Perform graceful rolling updates

Networking and routing of traffic

Manages ephemeral and persistent storage volumes

Page 4: Ansible Kubernetes Operators ATL Slide Decks/Kubernetes Operators _heart_...K8S API Resource WATCH EVENTS RECONCILE Action/s in cluster Controller Encode human operational knowledge

Level based reconciliation

K8S API Resource WATCH EVENTS

RECONCILE Action/s in cluster

Controller

Page 5: Ansible Kubernetes Operators ATL Slide Decks/Kubernetes Operators _heart_...K8S API Resource WATCH EVENTS RECONCILE Action/s in cluster Controller Encode human operational knowledge

● Encode human operational knowledge

● Automatically patch, upgrade, recover, and tune container-based apps and services

● Kubernetes-native

● Purpose-built for a specific application or service

● Enable “day 2” management

Kubernetes Operators

Operators simplify management of complex applications on Kubernetes

Page 6: Ansible Kubernetes Operators ATL Slide Decks/Kubernetes Operators _heart_...K8S API Resource WATCH EVENTS RECONCILE Action/s in cluster Controller Encode human operational knowledge

K8S API

CUSTOM RESOURCE

MY K8S APPLICATION

automatically updates resource

status

OPE

RATO

R SD

K BI

NARY

K8s Operator with Ansible

WATCHES.YML

ANSIBLERUNNER

executes & reports

Reconciliation with K8s Cluster

event monitoring

manages

Kubernetes Operators ❤ Ansible

REVERSE PROXY

reads

Page 7: Ansible Kubernetes Operators ATL Slide Decks/Kubernetes Operators _heart_...K8S API Resource WATCH EVENTS RECONCILE Action/s in cluster Controller Encode human operational knowledge

Developing your first Operator with Ansible

● Initialize Your Operator With Ansible○ $ operator-sdk new foo-operator

--api-version=cache.example.com/v1alpha1 --kind=Foo --type=ansible

● Automate With Ansible○ Create new roles and playbooks or reuse an existing one

● Define a watches file○ Map a Kubernetes object to your Ansible content

● Build Your Operator○ $ operator-sdk build foo-operator:v0.0.1

● Deploy Your Operator to a Kubernetes Cluster

Page 8: Ansible Kubernetes Operators ATL Slide Decks/Kubernetes Operators _heart_...K8S API Resource WATCH EVENTS RECONCILE Action/s in cluster Controller Encode human operational knowledge

Mapping Kubernetes events to Ansible

# watches.yaml---version: v1alpha1group: cache.example.comkind: Memcachedplaybook: /path/to/playbook

The “watches” file (watches.yaml) maps a Kubernetes object to your Ansible automation

Associates the Kubernetes Group, Version, Kind (GVK) to an Ansible Role or Playbook

The Operator SDK binary watches the cluster for matching events defined in the watches.yml

Executes the associated Ansible content when an event occurs

Page 9: Ansible Kubernetes Operators ATL Slide Decks/Kubernetes Operators _heart_...K8S API Resource WATCH EVENTS RECONCILE Action/s in cluster Controller Encode human operational knowledge

Custom resource to Ansible extra variables

apiVersion: <Group/Version>kind: <kind>metadata: name: <name>spec: <key>: <value> ….status: <key>: <value> ….

spec: values will be translated to Ansible extra_vars .

status: will have a generic status recorded by the Ansible Operator. This will use ansible-runner output to generate meaningful information for the user.

Page 10: Ansible Kubernetes Operators ATL Slide Decks/Kubernetes Operators _heart_...K8S API Resource WATCH EVENTS RECONCILE Action/s in cluster Controller Encode human operational knowledge

Demo Time!

Page 11: Ansible Kubernetes Operators ATL Slide Decks/Kubernetes Operators _heart_...K8S API Resource WATCH EVENTS RECONCILE Action/s in cluster Controller Encode human operational knowledge

Future Enhancements ● Tower Integration● Open API Generation for structural

schema in the custom resource● Using ansible during webhooks● Features to allow for more garbage

collection, cache, and dependent watches control

● And more!

If you would like to contribute:

https://github.com/operator-framework/operator-sdk

File Issues if you come across a problem or if you would like a feature.

We are always looking for contributors and would love to have you!

Page 12: Ansible Kubernetes Operators ATL Slide Decks/Kubernetes Operators _heart_...K8S API Resource WATCH EVENTS RECONCILE Action/s in cluster Controller Encode human operational knowledge

Explore Operators

OperatorHub.io is a home for the Kubernetes community to share Operators.

Find an existing Operator or list your own today.

Page 13: Ansible Kubernetes Operators ATL Slide Decks/Kubernetes Operators _heart_...K8S API Resource WATCH EVENTS RECONCILE Action/s in cluster Controller Encode human operational knowledge

etcd OperatorA great example of a sophisticated Kubernetes Operator using Ansible:github.com/water-hole/etcd-ansible-operator

Memcached OperatorSimple walkthrough for building an Operators using the Ansible Operator SDK and Kubernetes CRDs github.com/operator-framework/operator-sdk-samples/tree/master/memcached-operator

More resources

Page 14: Ansible Kubernetes Operators ATL Slide Decks/Kubernetes Operators _heart_...K8S API Resource WATCH EVENTS RECONCILE Action/s in cluster Controller Encode human operational knowledge

Recommended