Skip to content

Supervisor process management for Kubernetes components

Supervisor is a process control system utilized in the Kubernetes Deployment architecture to manage the lifecycle of critical cluster components.^[400-devops-06-kubernetes-k8s-paas-02-k8s.md] It acts as a daemon manager (守护进程工具), ensuring that services such as etcd and Kubernetes Control Plane binaries maintain their expected state automatically.^[400-devops-06-kubernetes-k8s-paas-02-k8s.md]

In the provided deployment architecture, Supervisor is installed on运算节点 and主控节点 to manage background services, allowing the system to automatically restart processes if they fail unexpectedly.^[400-devops-06-kubernetes-k8s-paas-02-k8s.md]

Configuration

Supervisor functionality is defined through initialization (.ini) files located in /etc/supervisord.d/.^[400-devops-06-kubernetes-k8s-paas-02-k8s.md] A typical configuration file for a Kubernetes component includes several key directives:

  • [program]: The section header defining the specific process name (e.g., [program:etcd-server-7-12]).^[400-devops-06-kubernetes-k8s-paas-02-k8s.md]
  • command: The full path to the startup script or binary (e.g., the .sh script for the component).^[400-devops-06-kubernetes-k8s-paas-02-k8s.md]
  • autostart & autorestart: Boolean values (true) configured to ensure the process starts when Supervisor starts and restarts automatically if it quits unexpectedly.^[400-devops-06-kubernetes-k8s-paas-02-k8s.md]
  • user: The system user account under which the process runs (e.g., etcd user for etcd, root for API server).^[400-devops-06-kubernetes-k8s-paas-02-k8s.md]
  • stdout_logfile: The path where standard output logs are stored, which is crucial for troubleshooting (e.g., /data/logs/kubernetes/...).^[400-devops-06-kubernetes-k8s-paas-02-k8s.md]
  • startsecs: The number of seconds the program must stay running to be considered a successful start (default often set to 30).^[400-devops-06-kubernetes-k8s-paas-02-k8s.md]

Usage

Once the configuration files are in place, the supervisorctl command-line tool is used to manage the services.

  • Update: After adding or modifying configuration files, run supervisorctl update to reload the configuration and add the new process group to the Supervisor daemon.^[400-devops-06-kubernetes-k8s-paas-02-k8s.md]
  • Status: The command supervisorctl status is used to verify the state of managed processes, displaying whether they are RUNNING with their process ID (pid) and uptime.^[400-devops-06-kubernetes-k8s-paas-02-k8s.md]

Sources

  • 400-devops-06-kubernetes-k8s-paas-02-k8s.md