What is Infrastructure as Code (IaC)?

Infrastructure as Code (IaC) is infrastructure management in a descriptive model, which means you can create your infra and manage it with your source code. Like the principle that the same source code generates the same binary, the same environment is generated by an IaC model every time it is applied.

Kubernetes also follows infrastructure as code (IaC) principles which mean all of our deployment is written in the form of code. This is a tremendous benefit in two ways: Our infrastructure can now be versioned and committed to any Git repository, and our infrastructure can easily be “deployed” elsewhere with the same configuration and with no human error.

Why IaC in Kubernetes?

Now let’s take a quick to understand how powerful Kubernetes is by taking an example of a cluster which is spawned and managed by Kops, and the whole setup is running on AWS. If we make a deployment onto the cluster then in this process we never need to know which instance exactly has pod one or pod two because the Kubernetes manage that load. Moreover, when we add new deployments into our cluster, Kubernetes will handle the load across a cluster and decide where to put the new pods. We can kill one of the pods and our replica set in deployment manifest file then it will spawn a new one as a replacement. We can also try to kill one of the EC2 instances, and KOPS will re-spawn new instances. And surprisingly, we barely scratch the surface of Kubernetes and how powerful it can get.

Bear in mind that this is only covered one application deployment. Now imagine if we write all the deployments and third party dependencies we need in this way, then we will have what we want: infrastructure written as code.

#insights #kubernetes #iac principles #infrastructure as code

IaC Principles for Kubernetes Configuration Management
2.50 GEEK