Glossary: Headless

I recently saw someone call a Kubernetes Service, “headless”. I have also heard this term in the context of the Chrome web browser running in “headless” mode. It’s a confusing term to me, so let’s explore it.

“Headless” means not having a head. But what is a “head” in these contexts?

Here is the Kubernetes Service that gmr called “headless”.

kind: Service
apiVersion: v1
metadata:
  namespace: default
  name: rabbitmq
  labels:
    app: rabbitmq
spec:
  clusterIP: None            # <--- This is what makes it headless
  ports:
   - name: http
     protocol: TCP
     port: 15672
     targetPort: 15672
   - name: amqp
     protocol: TCP
     port: 5672
     targetPort: 5672
  selector:
    app: rabbitmq

By setting spec.clusterIP to None, the Service is headless. It no longer acts as a load balancer. In a way, it’s like a lot of the overhead is removed and you are left with a stripped-down version of a Service.

A headless service is a service with a service IP but instead of load-balancing it will return the IPs of our associated. This allows us to reach each Pod directly, rather than the service acting as a load-balancer or proxy.

kaoskater08

I’m starting to see that “headless” might just mean part of an application instead of the full version.

How about Headless Chrome?

Headless Chrome is a way to run the Chrome browser in a headless environment without the full browser UI. Headless Chrome gives you a real browser context without the memory overhead of running a full version of Chrome.

Eric Bidelman

That makes sense. With automated web testing, you don’t need a full-blown browser, only some of its functionality.

Summary

Headless means that you are only using part of an application’s functionality.

Glossary: Provision

To supply with food, drink, or equipment, especially for a journey.

Provision (verb)

Provision comes from the word “provide”, which means to attend to.

I remember being re-introduced to the word provision when I started using Vagrant. There is an option you can use when you start a virtual machine, --provision, that will automatically install software and alter configurations according to what is written in your Vagrantfile.

For example, this Vagrant file:

Vagrant.configure("2") do |config|
  config.vm.provision "shell",
    inline: "sudo apt-get install -y nginx"
end

Uses config.vm.provision "shell" to run a shell command that installs Nginx before the virtual machine begins its journey.

You could say, I am provisioning my webserver with Nginx ("sudo apt-get install -y nginx").

You take a bare Ubuntu virtual machine and provision it with Nginx and some configuration changes in order for it to be a functioning web server.

An important thing to understand is that the provisioning process should be automated. As a DevOps engineer, you probably don’t want to manually do sudo apt-get install -y nginx and write the configuration files each time you create a virtual machine.

It is better to automate that process by using a tool such as Vagrant, Ansible, or at least a script. You can write your Vagrantfile, Ansible playbook, or script in a repository so it is version-controlled and documented, and you can use Ansible, for example, to run the provisioning script across multiple machines at the same time.

Like the original quote at the top of this post says, provisioning is supplying a machine with software and configuration settings it needs in order to perform its function.