systemd Unit File for Kubernetes

In any of these configurations, you will run some of the components as a standard system daemon. As an example, you can see here a sample systemd unit file to run the controller-manager. Using kubeadm will create a system daemon for kubelet, while the rest will deploy as containers:

 - name: kube-controller-manager.service
    command: start 
    content: |
      [Unit]
      Description=Kubernetes Controller Manager Documentation=https://github.com/kubernetes/...
      Requires=kube-apiserver.service
      After=kube-apiserver.service
      [Service]
      ExecStartPre=/usr/bin/curl -L -o /opt/bin/kube-controller-manager -z /opt/bin/kube-controller-manager https://storage.googleapis.com...
      ExecStartPre=/usr/bin/chmod +x /opt/bin/kube-controller-manager
      ExecStart=/opt/bin/kube-controller-manager \
        --service-account-private-key-file=/opt/bin/kube-serviceaccount.key \
        --root-ca-file=/var/run/kubernetes/apiserver.crt \
        --cp=127.0.0.1:8080 \
...

This is by no means a perfect unit file. It downloads the controller binary from the published release of Kubernetes and sets a few flags to run.

As you dive deeper in the configuration of each component, you will become more familiar not only with its configuration, but also with the various existing options, including those for authentication, authorization, HA, container runtime, etc. Expect them to change.

For example, the API server is highly configurable. The Kubernetes documentation provides more details about the kube-apiserver.

Last updated