I do, in fact am writing a book about it ;) It does change the particular things Ansible is used for (less application side, more initialization-side and cluster management). Answer from geerlingguy on reddit.com
Ansible
docs.ansible.com › projects › ansible › latest › collections › kubernetes › core › docsite › kubernetes_scenarios › k8s_intro.html
Introduction to Ansible for Kubernetes — Ansible Community Documentation
The kubernetes.core collection offers several modules and plugins for orchestrating Kubernetes.
Kubernetes
kubernetes.io › blog › 2019 › 03 › 15 › kubernetes-setup-using-ansible-and-vagrant
Kubernetes Setup Using Ansible and Vagrant | Kubernetes
January 3, 2026 - - name: Remove swapfile from /etc/fstab mount: name: "{{ item }}" fstype: swap state: absent with_items: - swap - none - name: Disable swap command: swapoff -a when: ansible_swaptotal_mb > 0 · - name: Add an apt signing key for Kubernetes apt_key: url: https://packages.cloud.google.com/apt/doc/apt-key.gpg state: present - name: Adding apt repository for Kubernetes apt_repository: repo: deb https://apt.kubernetes.io/ kubernetes-xenial main state: present filename: kubernetes.list - name: Install Kubernetes binaries apt: name: "{{ packages }}" state: present update_cache: yes vars: packages: - kubelet - kubeadm - kubectl - name: Configure node ip lineinfile: path: /etc/default/kubelet line: KUBELET_EXTRA_ARGS=--node-ip={{ node_ip }} - name: Restart kubelet service: name: kubelet daemon_reload: yes state: restarted
Do you use ansible with kubernetes?
I do, in fact am writing a book about it ;) It does change the particular things Ansible is used for (less application side, more initialization-side and cluster management). More on reddit.com
How can you use Ansible with Kubernetes to automate ifrastructure deployment?
I’m new to DevOps in general and would like to know how I can use Ansible with Kubernetes to deploy a web api? Like, what parts of the deployment would be Ansible useful at. More on discuss.kubernetes.io
Trying to understand the difference between Ansible, Docker, and Kubernetes
Ok, so I think you get ansible. It's a task(really a state) automation frameworks. Docker is a container system. Think of a container as a VM.. but one that runs on the same kernel as the host and only runs one process. They are easily stood up and torn down so they are considered temporary. Kubeenetes is a layer on top of docker that orchestrates the building up and tearing down of those containers across multiple container hosts. You don't need ansible for containers, but you do need docket for k8s. Edit: for your situation I would find an xvf container in docker hub and modify it to suit. More on reddit.com
EDA Event Driven with AWX installation Kubernetes
A Subreddit dedicated to fostering communication in the Ansible Community, includes Ansible, AWX, Ansible Galaxy, ansible-lint, Molecule, etc. ... Sorry, this post was deleted by the person who originally posted it. ... Create your account and connect with a world of communities. More on reddit.com
Videos
41:12
Easy Kubernetes Using Ansible! (RKE2) - YouTube
Building a Highly Available Kubernetes Cluster with Ansible - YouTube
Automate Your Entire K8s Cluster Deployment with One ...
Ansible for Kubernetes by Example - YouTube
04:35
How To Use Ansible With Kubernetes? - Next LVL Programming - YouTube
01:48:24
Managing Kubernetes with Ansible - Kubernetes tutorial, Ansible ...
Red Hat
redhat.com › en › topics › automation › Ansible-vs-Kubernetes
Ansible vs. Kubernetes: how they work together
Ansible addresses these challenges by automating cluster provisioning, enforcing configurations, and managing application deployments across Kubernetes environments. By pairing Ansible with Kubernetes, organizations can combine the strengths of both—taking advantage of Ansible’s library of modules, human-readable playbooks, and support for complex tasks like virtual machine migration.
Ansibleforkubernetes
ansibleforkubernetes.com
Ansible for Kubernetes - a book by Jeff Geerling
Ansible is a powerful infrastructure automation tool. Kubernetes is a powerful application deployment platform. Learn how to use these tools to automate massively-scalable, highly-available infrastructure. Buy on LeanPub $9.99 ebook Buy on Amazon (coming soon) Buy on iTunes (coming soon) This ...
Ansible
docs.ansible.com › projects › ansible › latest › collections › kubernetes › core › k8s_module.html
kubernetes.core.k8s module – Manage Kubernetes (K8s) objects — Ansible Community Documentation
- name: Create a k8s namespace ... from a local file kubernetes.core.k8s: state: present src: /testing/deployment.yml - name: >- Read definition file from the Ansible controller file system. If the definition file has been encrypted with Ansible Vault it will automatically ...
GitHub
github.com › geerlingguy › ansible-for-kubernetes
GitHub - geerlingguy/ansible-for-kubernetes: Ansible and Kubernetes examples from Ansible for Kubernetes Book · GitHub
cluster-aws-eks: An AWS EKS Cluster with an EKS Node Group, which uses Ansible to apply CloudFormation templates that set up stacks for a VPC and networking, an EKS Cluster, and an associated EKS Node Group. ... testing-molecule-kind: A Molecule-based test environment which allows development and testing of Ansible playbooks against a Kind Kubernetes cluster.
Starred by 731 users
Forked by 320 users
Languages Shell 80.0% | Go 13.0% | Ruby 4.5% | Dockerfile 2.5%
Reddit
reddit.com › r/ansible › do you use ansible with kubernetes?
r/ansible on Reddit: Do you use ansible with kubernetes?
February 15, 2021 -
Or does kubernetes declarative nature reduce the need for playbooks?
Top answer 1 of 8
30
I do, in fact am writing a book about it ;) It does change the particular things Ansible is used for (less application side, more initialization-side and cluster management).
2 of 8
9
I've largely moved away from using configuration management tools with Kubernetes. Most of the environments I've worked in have been AWS based, so a tool such as Terraform is pretty good for bringing the basic infrastructure up. Some form of templating is helpful when deploying applications on Kubernetes. Even though Kube API objects are declarative, there are a lot of use cases for basic control structures, conditional logic, and interpolation. If you're looking for publically available templates to deploy common apps on Kube, Helm has a big repository to work from. If you're looking to write custom templates, Jsonnet is interesting. You can use Ansible to deploy apps on Kube, but it's not a very common approach right now.
Ansible
docs.ansible.com › projects › ansible › latest › collections › kubernetes › core › kubectl_connection.html
kubernetes.core.kubectl connection – Execute tasks in pods running on Kubernetes. — Ansible Community Documentation
- name: Run a command in a pod using local kubectl with kubeconfig file ~/.kube/config hosts: localhost gather_facts: no vars: ansible_connection: kubernetes.core.kubectl ansible_kubectl_namespace: my-namespace ansible_kubectl_pod: my-pod ansible_kubectl_container: my-container tasks: # be aware that the command is executed as the user that started the container # and requires python to be installed in the image - name: Run a command in a pod ansible.builtin.command: echo "Hello, World!"
TauCeti
tauceti.blog › posts › kubernetes-the-not-so-hard-way-with-ansible-the-basics
Kubernetes the not so hard way with Ansible - The basics - (K8s v1.28) - TauCeti blog
January 1, 2024 - Also in the blog series about virtualization mentioned above I created a Python virtual environment with Ansible installed for my Physical Hosts in /opt/scripts/ansible/k8s-01_phy (/opt/scripts/ansible is my base directory for everything Ansible related). Now I’ll create one for my Virtual Machines in /opt/scripts/ansible/k8s-01_vms. So in /opt/scripts/ansible directory I execute the following command: ... That creates a directory called k8s-01_vms. k8s-01 is for “Kubernetes Cluster 01” and vms for “Virtual Machines”. So everything related to the “Physical Hosts” will be managed by k8s-01_phy (just FYI, not relevant for this blog series) and every thing related to the “Virtual Machines” which runs on the Physical Hosts will go into k8s_01_vms.
Top answer 1 of 2
2
To be honest, while you can use ansible to spin stuff up in kubernetes, its not as well suited to it as other tools (e.g. helm, skaffold, or kustomize). You’re essentially using yaml to describe yaml and unless you have to inject some information from common ansible vars I’d look into pursuing other…
2 of 2
1
Hi, parrotstone
you can for Automate config kubernetes and services used Ansible Kubernetes modules
https://docs.ansible.com/ansible/latest/collections/community/kubernetes/k8s_module.html
Amazon
amazon.com › Ansible-Kubernetes-Example-Automate-Cluster › dp › 1484292847
Ansible for Kubernetes by Example: Automate Your Kubernetes Cluster with Ansible: Berton, Luca: 9781484292846: Amazon.com: Books
Implementing GitOps with Kubernetes: Automate, manage, scale, and secure infrastructure and cloud-native applications on AWS and Azure ... Learn Ansible: Automate your cloud infrastructure, security configuration, and application deployment with Ansible
Medium
medium.com › @a.j.longchamps › home-lab-kubernetes-part-3-initializing-the-kubernetes-cluster-with-ansible-d979dc1aeea0
Home Lab Kubernetes Part 3: Initializing The Kubernetes Cluster With Ansible | by Aaron Longchamps | Medium
June 19, 2024 - Ansible makes editing files easy so I’m going to take advantage of it. My initial version of this script was longer, but I took this opportunity to move up the apt repo configs, consolidate the installations, and shorten everything. This is where we really start building the Kubernetes cluster. In 5 steps, I do the following: Initialize the Kubernetes cluster with kubeadm init and quite a few options (more on this below)
Springer
link.springer.com › home › book
Ansible for Kubernetes by Example: Automate Your Kubernetes Cluster with Ansible | Springer Nature Link
Ansible for Kubernetes by Example (eBook)
This book shows you how to automate more tasks and save time with Kubernetes infrastructure using Ansible.
Price €49.99
Author Luca Berton
Pages 22
GitHub
github.com › ansible-collections › kubernetes.core
GitHub - ansible-collections/kubernetes.core: The collection includes a variety of Ansible content to help automate the management of applications in Kubernetes and OpenShift clusters, as well as the provisioning and maintenance of clusters themselves. · GitHub
The collection includes a variety of Ansible content to help automate the management of applications in Kubernetes and OpenShift clusters, as well as the provisioning and maintenance of clusters themselves.
Starred by 254 users
Forked by 166 users
Languages Python
Cicd-tutorials
cicd-tutorials.net › tutorials › jenkins › ansible-kubernetes
Deploy application to Kubernetes with Ansible - CI/CD Tutorials
String d = "docs/tutorials/jenkins/ansible-kubernetes" pipeline { agent any parameters { choice(name: 'ANIMAL', choices: ['cat', 'cow', 'dog', 'lion', 'pig'], description: 'Tag to use for deployment image') } stages { stage("deploy") { agent { dockerfile { dir "$d" reuseNode true } } environment { K8S_AUTH_KUBECONFIG = credentials('kubeconfig') KUBECONFIG = credentials('kubeconfig') } steps { sh """ ansible-playbook $d/deploy-to-kubernetes.yml --extra-vars "animal=${params.ANIMAL}" ./$d/wait-until-service-up.sh """ } } } } After you have created the pipeline, try to execute it by clicking Build Now. The pipeline should have deployed the example application into the Kubernetes cluster with the default image tag (cow) defined in the deploy-to-kubernetes.yml Ansible playbook.
Medium
akpolatcem.medium.com › building-a-production-ready-kubernetes-cluster-with-ansible-from-zero-to-running-in-30-minutes-a09f34deb671
Building a Production-Ready Kubernetes Cluster with Ansible: From Zero to Running in 30 Minutes | by ca | Medium
August 4, 2025 - The kubelet acts as the node agent, communicating with the control plane and managing container lifecycle. The kube-proxy handles network routing for services, and the CNI plugin manages pod-to-pod networking across the cluster. To understand better what Ansible code does, instead of adding the code here, I decided to place the sequence diagram of the steps, so that we can clearly see how the interaction occurs between the ansible code and the remote virtual machine. To deploy the kubernetes, three roles are created:
Jeff Geerling
jeffgeerling.com › blog › 2020 › kubernetes-collection-ansible
The Kubernetes Collection for Ansible - Jeff Geerling
February 18, 2020 - In Ansible 2.10, the code for anything not deemed 'core' (which includes the majority of plugins and modules that are currently stored in the ansible/ansible repository) will be moved into separate collection repositories, with the majority moving into a 'general' collection. As time goes on, some of the more actively-maintained content in the general collection may be extracted into more specific collections. Seeing the huge increase in Kubernetes adoption—often by teams using some automation tooling already—I decided to help organize the Kubernetes Working Group, and get all the current Kubernetes-related plugins and modules extracted into their own, dedicated Kubernetes collection.