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
.shscript 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.,
etcduser for etcd,rootfor 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 updateto 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 statusis used to verify the state of managed processes, displaying whether they areRUNNINGwith their process ID (pid) and uptime.^[400-devops-06-kubernetes-k8s-paas-02-k8s.md]
Related Concepts¶
- [[etcd]]
- Kubelet
- Kube-controller-manager
- Kube-apiserver
Sources¶
- 400-devops-06-kubernetes-k8s-paas-02-k8s.md