April 5, 2019

Puppet & Kubernetes: How to Easily Install, Configure & Manage Kubernetes Clusters

Ecosystems & Integrations
How to & Use Cases

Containerization has immense potential for development, particularly in cloud environments. The benefits of virtualizing a portable computing environment are attractive for any organization to make their DevOps approach faster and more flexible.

This blog provides a quick overview of how Puppet and Kubernetes work and how to use the Puppet Kubernetes module to install, bootstrap, and configure Kubernetes using Puppet.

Back to top

How Do Puppet and Kubernetes Work?

Puppet can be used to install and configure Kubernetes clusters at scale using modules and Puppet's desired state enforcement.

Kubernetes is an open-source system for managing containerized applications. It's great for automating deployment, scaling, and management of containers. But for all its strengths, there are a few ways Puppet helps cover for some of the problems IT teams face with Kubernetes.

DOWNLOAD MODULE

With Puppet and the puppetlabs kubernetes module from the Forge, you can...

  • Easily identify what resources exist in your Kubernetes cluster
  • Manage and enforce desired state of Kubernetes resources across servers
  • Monitor and report on the current state of your Kubernetes cluster
  • Automatically remediate drift and other discrepancies in your Kubernetes cluster
  • Audit, version control, and track changes to your Kubernetes cluster

The puppetlabs kubernetes module is fully open source, it works with both Open Source Puppet and Puppet Enterprise, and we welcome community contributions to help make it even better for users like you.

Back to top

What the Puppet Kubernetes Module Does

The Puppet Kubernetes module installs and configures Kubernetes on your target servers. It uses Puppet's declarative automation capabilities to continuously enforce desired state of a Kubernetes cluster.

You define the desired state of your Kubernetes clusters as Puppet manifests, and the Puppet Kubernetes module will apply them to your Puppet-managed servers. It automates the process of setting up and configuring Kubernetes across all of the servers you want it on.

It also makes sure that configurations are consistent across all nodes. When you make a change to the Puppet primary server, Puppet will apply that change to all of the servers it's managing. If Puppet detects any drift in the configurations on a managed server during its regular run (eveyr 30 minutes by default), it'll request code from the primary server to correct it automatically.

Keep in mind that the puppetlabs kubernetes module does not control any containerized applications deployed to the Kubernetes cluster.

Using this module will help you deploy Kubernetes quicker, using the Puppet Desired State Language (DSL) to define the state. The module uses the kubeadm toolkit to bootstrap the Kubernetes cluster.

New to Kubernetes? Try Out the Puppet Kubernetes Sandbox

If you're new to Kubernetes and want get a basic cluster running with a controller and two workers, you're in luck. Kubernetes Rules Everything Around Me (KREAM) is a development environment for the Puppet Kubernetes module that can help you get up to speed.

Watch the below video for a tutorial on installing and configuring a Kubernetes cluster:

Back to top

How Install and Configure Kubernetes with Puppet

Install the Puppet Kubernetes Module

Start by downloading the Puppet Kubernetes module from the Puppet Forge. The module comes with a kubetool which will generate the yaml configuration for your Kubernetes deployment. The files produced for each member of the etcd cluster contain certificate information to bootstrap an initial etcd cluster.

Add the Configuration Files to Hiera

Next, add the configuration files generated by the kubetool to Hiera. Each cluster can be allocated its own configuration.

Configure Your Controller or Worker Nodes

Now it's time to configure the nodes. There can be controller and worker nodes. A node be either controller or worker, but not both.

To configure a controller note, add the following code to a manifest:

class {'kubernetes':
controller => true,
}

To configure a worker note, add this code instead:

class {'kubernetes':
worker => true,
}

Using the module in this way will keep your Kubernetes installation consistently enforced based on the manifests used for its creation, and Puppet will prevent any drift.

GET A FREE TRIAL OF PUPPET

Learn More

Back to top