This document discusses automating Kubernetes environments with Ansible. It describes how Ansible can be used to define Kubernetes objects like ConfigMaps through templates and deploy them. It also explains how to create an Operator using the Operator SDK that is based on Ansible for automating application provisioning and lifecycle management. Key advantages of using Ansible include supporting both cloud-native and traditional IT automation through integrations beyond just Kubernetes, and providing flexibility to choose the level of automation needed.
8. $ kubectl create -f
deploy/crds/cache.example.com_memcacheds_crd.yaml
$ kubectl create -f deploy/service_account.yaml
$ kubectl create -f deploy/role.yaml
$ kubectl create -f deploy/role_binding.yaml
$ kubectl create -f deploy/operator.yaml
# we are skipping over the instructions to run sed commands or make
# manual edits to these files here.
13. ● 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
Operators simplify management of complex applications
on Kubernetes
14. Phase I Phase II Phase III Phase IV Phase V
Basic Install
Automated application
provisioning and
configuration management
Seamless Upgrades
Patch and minor version
upgrades supported
Full Lifecycle
App lifecycle, storage
lifecycle (backup, failure
recovery)
Deep Insights
Metrics, alerts, log
processing and workload
analysis
Auto Pilot
Horizontal/vertical scaling,
auto config tuning, abnormal
detection, scheduling tuning
17. your Operator image
Ansible Role
Ansible Role
watches.yaml
base Ansible Operator SDK image
Operator SDK Binary
ansible-runner
Ansible
Python + Libraries
18. ● 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
22. GitOps the Ansible Way
23
CI REGISTRY
DEV
CODE
REPO
CONFIG
REPO
R
W
R
W
R
O
“OPS”
R
W
23. Advantages of using Ansible
24
GitOps Beyond Cloud-Native
▸ Supports cloud-native and traditional IT
automation
▸ Integrations beyond Kubernetes such as
cloud & networking
24. Advantages of using Ansible
25
Flexibility To Do More
▸ Flexibility and freedom to choose what you
need
▸ Deploy, manage and automate multiple
environments thru one control plane.
▸ No dedicated GitOps “agent” required
26. Resources & More
27
▸ Ansible K8s Modules
・ https://docs.ansible.com/ansible/latest/modules/list_of_clustering_modules.html#k8s
▸ How Useful Is Ansible In A Cloud-Native Kubernetes Environment?
・ https://www.ansible.com/blog/how-useful-is-ansible-in-a-cloud-native-kubernetes-environment
▸ Building Kubernetes Operators in an Ansible-native way (Webinar)
・ https://www.cncf.io/webinars/building-kubernetes-operators-in-an-ansible-native-way/
▸ Creating Ansible-based Operators
・ https://docs.openshift.com/container-platform/4.5/operators/operator_sdk/osdk-ansible.html
▸ Using Ansible Automation Webhooks for GitOps
・ https://www.redhat.com/sysadmin/ansible-webhooks-gitops
▸ Guide to GitOps
・ https://www.weave.works/technologies/gitops/