Home > Mobile >  DevOps: Difference between Ansible and orchestrators like Kubernetes
DevOps: Difference between Ansible and orchestrators like Kubernetes

Time:08-04

I am currently confused by the differences between Ansible and Kubernetes. And the related terms of automation and orchestration. As far as I can tell automation is just the process of performing specific tasks automatically. At the same time, orchestration is a process of automating a series of individual tasks to work together.

Ansible can be used to set up Playbooks that are able to represent single tasks and steps to install, update or remove a software package, config, etc. Once you have a playbook you can define a state for multiple servers and the software they should have installed through your playbooks. But basically, you have to tell Ansible what state should be reached on which host.

With Orchestration tools like Kubernetes, you can simply define a State (i.e 3 containers of type x, 2 of type y, etc. And then the software will autonomously choose notes to start your pods etc.

So is basically Orchestration (reaching a given state automatically) and Configuration (like Ansible) simply performing commands automatically?

Thanks.

Regards Artur

CodePudding user response:

The short answer is; ansible -> one-off tasks (install a bunch of stuff and exit), kubernetes -> life-cycle management (not just deploy, monitor, maintain, health-check, protect, high-availability and so on).

Long Answer

Ansible, as you rightly point out is a system for declarative automation; i.e. you define a state you want something to be in, and it will idempotently (it checks if something already has been done and skips it to avoid side-effects) achieve that for you.

Kubernetes is also a declarative system, wherein you define what state you want for your infrastructure to be in, and it achieves it for you.

The difference lies in the purpose of each, and the problem they are solving. Ansible solves the problem of performing what we call day-1 operations of infrastructure, i.e. installing operating systems, dependencies packages, performing network configurations etc on your infrastructure components. It does so with declarative playbooks (just define what you want done), instead of imperative scripting (where you have to describe how you want it done as well). It is termed as infrastructure-as-code.

Kubernetes is what comes after this, i.e. day-2 operation, where you already have your underlying infrastructure ready and you want now to be able to provision a cloud infrastructure on top of it. And not that you just want to deploy your containerised cloud, but also maintain it, provide HA for it, security for it, to be able to manage application workloads on it, audit it, scale it up and down and many other things that can be termed as day-3, day-4 tasks etc.

So, as you can imagine, they both have some things in common (both do infra management, both are declarative) but they have different use cases. Typically, if you were to setup a cloud setup you will do something like..

day-0; get all of your infrastructure; hardware/public-cloud etc.
day-1; use something like Ansible to setup the infrastructure components (EC2 nodes, hardware servers or GCE instances)
day-2; install k8s on them to start running containerized workloads
day-3; use k8s native mechanisms to deploy and manage and monitor applications
...

I hope this clarifies the bigger picture in your mind!

  • Related