SlideShare a Scribd company logo
Automating
Kubernetes
Environments with
Ansible
Automating Kubernetes Environments with Ansible
●
●
●
●
apiVersion: v1
kind: ConfigMap
metadata:
name: foo
namespace: default
data:
color: red
- name: create foo configmap
k8s:
definition:
apiVersion: v1
kind: ConfigMap
metadata:
name: foo
namespace: default
data:
color: “{{ color }}”
---
- name: create foo configmap
k8s:
definition: "{{ lookup('template', '/foo.yml') | from_yaml
}}"
Automating Kubernetes Environments with Ansible
Automating Kubernetes Environments with Ansible
$ 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.
Automating Kubernetes Environments with Ansible
Automating Kubernetes Environments with Ansible
[k8s-us-east4-test:vars]
cache_service_name: cache-service-test
cache_service_namespace: myapp
cache_service_memcached_pool_size: 3
cache_service_pool_setup: sharded
k8s_cluster_config: /path/to/gke-beta-config
[k8s-us-west1-prod:vars]
cache_service_name: cache-service-prod
cache_service_namespace: myapp
cache_service_memcached_pool_size: 9
cache_service_pool_setup: sharded
k8s_cluster_config: /path/to/gke-prod-config
apiVersion: mcrouter.example.com/v1alpha3
kind: Mcrouter
metadata:
name: {{ cache_service_name }}
namespace: {{ cache_service_namespace }}
spec:
memcached_pool_size: >
{{ cache_service_memcached_pool_size }}
- name: define cache service resource
k8s:
kubeconfig: "{{ k8s_cluster_config | default(omit) }}"
definition: "{{ lookup('template', >
'k8s-cache-service-def.yaml.j2') | from_yaml }}"
Automating Kubernetes Environments with Ansible
● 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
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
Automating Kubernetes Environments with Ansible
K8s Operator with Ansible
your Operator image
Ansible Role
Ansible Role
watches.yaml
base Ansible Operator SDK image
Operator SDK Binary
ansible-runner
Ansible
Python + Libraries
● 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
mcroutermcrouter-operator
Automating Kubernetes Environments with Ansible
21
GitOps Workflow
CI REGISTRY
DEV
CODE
REPO
CONFIG
REPO
RW
RWRO
“OPS”
RW
GitOps the Ansible Way
23
CI REGISTRY
DEV
CODE
REPO
CONFIG
REPO
R
W
R
W
R
O
“OPS”
R
W
Advantages of using Ansible
24
GitOps Beyond Cloud-Native
▸ Supports cloud-native and traditional IT
automation
▸ Integrations beyond Kubernetes such as
cloud & networking
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
●
●
●
●
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/
Thank you
Ad

More Related Content

Similar to Automating Kubernetes Environments with Ansible (20)

Build your operator with the right tool
Build your operator with the right toolBuild your operator with the right tool
Build your operator with the right tool
Rafał Leszko
 
$ kubectl hacking @DevOpsCon Berlin 2019
$ kubectl hacking @DevOpsCon Berlin 2019$ kubectl hacking @DevOpsCon Berlin 2019
$ kubectl hacking @DevOpsCon Berlin 2019
Tobias Schneck
 
Scaling docker with kubernetes
Scaling docker with kubernetesScaling docker with kubernetes
Scaling docker with kubernetes
Liran Cohen
 
Kubernetes Cluster API - managing the infrastructure of multi clusters (k8s ...
Kubernetes Cluster API - managing the infrastructure of  multi clusters (k8s ...Kubernetes Cluster API - managing the infrastructure of  multi clusters (k8s ...
Kubernetes Cluster API - managing the infrastructure of multi clusters (k8s ...
Tobias Schneck
 
An intro to Kubernetes operators
An intro to Kubernetes operatorsAn intro to Kubernetes operators
An intro to Kubernetes operators
J On The Beach
 
Ansible & Salt - Vincent Boon
Ansible & Salt - Vincent BoonAnsible & Salt - Vincent Boon
Ansible & Salt - Vincent Boon
MyNOG
 
Operator Lifecycle Management
Operator Lifecycle ManagementOperator Lifecycle Management
Operator Lifecycle Management
DoKC
 
Operator Lifecycle Management
Operator Lifecycle ManagementOperator Lifecycle Management
Operator Lifecycle Management
DoKC
 
Spark with kubernates
Spark with kubernatesSpark with kubernates
Spark with kubernates
David Tung
 
K8s in 3h - Kubernetes Fundamentals Training
K8s in 3h - Kubernetes Fundamentals TrainingK8s in 3h - Kubernetes Fundamentals Training
K8s in 3h - Kubernetes Fundamentals Training
Piotr Perzyna
 
Shakr - Container CI/CD with Google Cloud Platform
Shakr - Container CI/CD with Google Cloud PlatformShakr - Container CI/CD with Google Cloud Platform
Shakr - Container CI/CD with Google Cloud Platform
Minku Lee
 
Openshift operator insight
Openshift operator insightOpenshift operator insight
Openshift operator insight
Ryan ZhangCheng
 
Hands-On Introduction to Kubernetes at LISA17
Hands-On Introduction to Kubernetes at LISA17Hands-On Introduction to Kubernetes at LISA17
Hands-On Introduction to Kubernetes at LISA17
Ryan Jarvinen
 
Exploring MySQL Operator for Kubernetes in Python
Exploring MySQL Operator for Kubernetes in PythonExploring MySQL Operator for Kubernetes in Python
Exploring MySQL Operator for Kubernetes in Python
Ivan Ma
 
Creating Kubernetes multi clusters with ClusterAPI in the Hetzner Cloud
Creating Kubernetes multi clusters with ClusterAPI in the Hetzner CloudCreating Kubernetes multi clusters with ClusterAPI in the Hetzner Cloud
Creating Kubernetes multi clusters with ClusterAPI in the Hetzner Cloud
Tobias Schneck
 
Kubernetes Basis: Pods, Deployments, and Services
Kubernetes Basis: Pods, Deployments, and ServicesKubernetes Basis: Pods, Deployments, and Services
Kubernetes Basis: Pods, Deployments, and Services
Jian-Kai Wang
 
Ansible roles done right
Ansible roles done rightAnsible roles done right
Ansible roles done right
Dan Vaida
 
Open stack and k8s(v4)
Open stack and k8s(v4)Open stack and k8s(v4)
Open stack and k8s(v4)
H K Yoon
 
Kube-AWS
Kube-AWSKube-AWS
Kube-AWS
CoreOS
 
Meetup - Principles of the kube api and how to extend it
Meetup - Principles of the kube api and how to extend itMeetup - Principles of the kube api and how to extend it
Meetup - Principles of the kube api and how to extend it
Stefan Schimanski
 
Build your operator with the right tool
Build your operator with the right toolBuild your operator with the right tool
Build your operator with the right tool
Rafał Leszko
 
$ kubectl hacking @DevOpsCon Berlin 2019
$ kubectl hacking @DevOpsCon Berlin 2019$ kubectl hacking @DevOpsCon Berlin 2019
$ kubectl hacking @DevOpsCon Berlin 2019
Tobias Schneck
 
Scaling docker with kubernetes
Scaling docker with kubernetesScaling docker with kubernetes
Scaling docker with kubernetes
Liran Cohen
 
Kubernetes Cluster API - managing the infrastructure of multi clusters (k8s ...
Kubernetes Cluster API - managing the infrastructure of  multi clusters (k8s ...Kubernetes Cluster API - managing the infrastructure of  multi clusters (k8s ...
Kubernetes Cluster API - managing the infrastructure of multi clusters (k8s ...
Tobias Schneck
 
An intro to Kubernetes operators
An intro to Kubernetes operatorsAn intro to Kubernetes operators
An intro to Kubernetes operators
J On The Beach
 
Ansible & Salt - Vincent Boon
Ansible & Salt - Vincent BoonAnsible & Salt - Vincent Boon
Ansible & Salt - Vincent Boon
MyNOG
 
Operator Lifecycle Management
Operator Lifecycle ManagementOperator Lifecycle Management
Operator Lifecycle Management
DoKC
 
Operator Lifecycle Management
Operator Lifecycle ManagementOperator Lifecycle Management
Operator Lifecycle Management
DoKC
 
Spark with kubernates
Spark with kubernatesSpark with kubernates
Spark with kubernates
David Tung
 
K8s in 3h - Kubernetes Fundamentals Training
K8s in 3h - Kubernetes Fundamentals TrainingK8s in 3h - Kubernetes Fundamentals Training
K8s in 3h - Kubernetes Fundamentals Training
Piotr Perzyna
 
Shakr - Container CI/CD with Google Cloud Platform
Shakr - Container CI/CD with Google Cloud PlatformShakr - Container CI/CD with Google Cloud Platform
Shakr - Container CI/CD with Google Cloud Platform
Minku Lee
 
Openshift operator insight
Openshift operator insightOpenshift operator insight
Openshift operator insight
Ryan ZhangCheng
 
Hands-On Introduction to Kubernetes at LISA17
Hands-On Introduction to Kubernetes at LISA17Hands-On Introduction to Kubernetes at LISA17
Hands-On Introduction to Kubernetes at LISA17
Ryan Jarvinen
 
Exploring MySQL Operator for Kubernetes in Python
Exploring MySQL Operator for Kubernetes in PythonExploring MySQL Operator for Kubernetes in Python
Exploring MySQL Operator for Kubernetes in Python
Ivan Ma
 
Creating Kubernetes multi clusters with ClusterAPI in the Hetzner Cloud
Creating Kubernetes multi clusters with ClusterAPI in the Hetzner CloudCreating Kubernetes multi clusters with ClusterAPI in the Hetzner Cloud
Creating Kubernetes multi clusters with ClusterAPI in the Hetzner Cloud
Tobias Schneck
 
Kubernetes Basis: Pods, Deployments, and Services
Kubernetes Basis: Pods, Deployments, and ServicesKubernetes Basis: Pods, Deployments, and Services
Kubernetes Basis: Pods, Deployments, and Services
Jian-Kai Wang
 
Ansible roles done right
Ansible roles done rightAnsible roles done right
Ansible roles done right
Dan Vaida
 
Open stack and k8s(v4)
Open stack and k8s(v4)Open stack and k8s(v4)
Open stack and k8s(v4)
H K Yoon
 
Kube-AWS
Kube-AWSKube-AWS
Kube-AWS
CoreOS
 
Meetup - Principles of the kube api and how to extend it
Meetup - Principles of the kube api and how to extend itMeetup - Principles of the kube api and how to extend it
Meetup - Principles of the kube api and how to extend it
Stefan Schimanski
 

Recently uploaded (20)

AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
Ad

Automating Kubernetes Environments with Ansible

  • 4. apiVersion: v1 kind: ConfigMap metadata: name: foo namespace: default data: color: red - name: create foo configmap k8s: definition: apiVersion: v1 kind: ConfigMap metadata: name: foo namespace: default data: color: “{{ color }}”
  • 5. --- - name: create foo configmap k8s: definition: "{{ lookup('template', '/foo.yml') | from_yaml }}"
  • 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.
  • 11. [k8s-us-east4-test:vars] cache_service_name: cache-service-test cache_service_namespace: myapp cache_service_memcached_pool_size: 3 cache_service_pool_setup: sharded k8s_cluster_config: /path/to/gke-beta-config [k8s-us-west1-prod:vars] cache_service_name: cache-service-prod cache_service_namespace: myapp cache_service_memcached_pool_size: 9 cache_service_pool_setup: sharded k8s_cluster_config: /path/to/gke-prod-config apiVersion: mcrouter.example.com/v1alpha3 kind: Mcrouter metadata: name: {{ cache_service_name }} namespace: {{ cache_service_namespace }} spec: memcached_pool_size: > {{ cache_service_memcached_pool_size }} - name: define cache service resource k8s: kubeconfig: "{{ k8s_cluster_config | default(omit) }}" definition: "{{ lookup('template', > 'k8s-cache-service-def.yaml.j2') | from_yaml }}"
  • 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
  • 16. K8s Operator with Ansible
  • 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/