Installation and Deployment Pre-environment Check Tool Guide
Background
Users have found that during the use of installation and deployment tools, due to possible residual configuration files from other software in the environment, as well as some applications that conflict with specifications, installation and deployment processes may be abnormal or fail. To ensure successful installation and deployment, a pre-environment check tool needs to be built to ensure the environment is available before installation and deployment. The tool currently implements the following functions:
- Given a file path list, query whether files remain in the current environment and output a check report.
- Given a file path list, support safe deletion (asking user for deletion confirmation) and forced deletion (delete directly without asking), and output a check report.
- Check whether specified programs are installed in the environment and output a check report.
- Support time synchronization verification between multiple machines, detecting whether clocks between other nodes and the bootstrap node are synchronized.
Prerequisites
This tool currently only supports execution in Linux amd64 and Linux arm64 environments, please download the corresponding version of the tool according to your environment.
| Download Item | amd64 | arm64 |
|---|---|---|
| envCheck tool | Download | Download |
| Default configuration file | Download | Download |
Configuration files can be created manually or downloaded and modified as default configuration files.
Restrictions
None.
Guide
Note:
- After download, the tool is named
envCheckand is a binary executable file.- You can use different functions of the tool by modifying the configuration file and executing different commands. The corresponding configuration file and tool are in the same folder and named
config.json(the configuration file location can be placed elsewhere, but when placed in other locations, the command line parameter--configneeds to be explicitly specified). Here it defaults to the same folder with the content shown in the examples below.
Complete Configuration File Example
// config.json
{
"log_file": "./envCheck.log",
"output_format": "text",
"paths": [
"$HOME/.kube",
"/etc/kubernetes",
"/usr/bin/kube*",
"/usr/local/bin/kube*",
"/usr/local/bin/crictl",
"/etc/sysctl.d/k8s.conf",
"/etc/systemd/system/kubelet.service",
"/etc/systemd/system/kubelet.service.d",
"/var/lib/openFuyao/etcd",
"/var/lib/kubelet",
"/run/containerd/containerd.sock",
"/usr/lib/systemd/system/kubelet.service.d",
"/var/run/containerd/containerd.sock",
"/var/run/docker.sock"
],
"clean_force": false,
"program_list": [
"docker",
"kubectl",
"containerd"
],
"hosts": [
{
"ip": "192.168.1.1",
"username": "root",
"password": "******",
"port": "22",
"role": ["bootstrap"]
},
{
"ip": "192.168.1.2",
"username": "root",
"password": "******",
"port": "22",
"role": ["master"]
}
],
"clock_threshold": 10
}Notice:
Regarding configuration files, the tool will perform the following validations:
- When using file query or cleanup functions,
pathscannot be empty.- When using conflicting application detection function,
program_listcannot be empty.- When using clock synchronization detection function,
hostscannot be empty.
Configuration file field descriptions:
| Field Name | Description |
|---|---|
| log_file | Path to store log files (including filename) |
| output_format | Tool execution result report output format, currently supports text, json |
| paths | File path list that needs to be specified for file query and cleanup |
| clean_force | Whether to execute forced deletion (no user confirmation needed) |
| program_list | List of application names to check for installation |
| hosts | List of machines that need clock synchronization detection |
| ip | IP address used for ssh connection |
| username | Username used for ssh connection |
| password | Password used for ssh connection |
| port | Port used for ssh connection |
| role | Machine role (bootstrap indicates bootstrap node) |
| clock_threshold | Machine clock error allowable threshold (unit: seconds) |
Note:
When the tool runs, it will output running results to the terminal by default and generate a corresponding html file in the current folder, and the running process will record logs in the envCheck.log file in the current folder. Users can set this by modifying corresponding fields in the configuration file. The following sections default to
output_formatbeingtextin the configuration file.
Users can execute the following command to get tool help documentation.
envCheck -hFile Query Function
Execute the following command for default query.
bashenvCheck queryThe tool will query whether files exist in the paths specified by
pathsinconfig.jsonin the current folder. After the tool finishes running, query results will be output to the terminal and aquery.htmlfile will be generated in the current folder.Execute the following command to specify configuration file path during query.
bashenvCheck query --config=./queryConfig.jsonThe tool will query whether files exist in the paths specified by
pathsinqueryConfig.jsonin the current folder. After the tool finishes running, query results will be output to the terminal and aquery.htmlfile will be generated in the current folder.
File Cleanup Function
Note:
Before executing the file cleanup function, you need to confirm the
clean_forcefield value in the configuration file, which defaults tofalse.falsemeans you will be asked for confirmation before deleting files,truemeans no confirmation will be requested. If you add the--forceexecution command, it means regardless of theclean_forcefield value, the tool will directly delete corresponding files.
Execute the following command for default cleanup (user will be asked before deleting each file).
bashenvCheck cleanThe tool will ask whether to delete files in the paths specified by
pathsinconfig.jsonin the current folder. After the tool finishes running, cleanup results will be output to the terminal and aclean.htmlfile will be generated in the current folder.Execute the following command for forced deletion, files will be deleted directly without asking the user.
bashenvCheck clean --forceThe tool will directly delete files in the paths specified by
pathsinconfig.jsonin the current folder. After the tool finishes running, cleanup results will be output to the terminal and aclean.htmlfile will be generated in the current folder.Execute the following command to specify configuration file path during deletion.
bashenvCheck clean --config=./cleanConfig.jsonThe tool will execute file cleanup function according to settings in the
cleanConfig.jsonfile. After the tool finishes running, cleanup results will be output to the terminal and aclean.htmlfile will be generated in the current folder.
Program Existence Detection
Execute the following command for default application query.
bashenvCheck checkThe tool will query whether applications specified by
program_listinconfig.jsonin the current folder are installed. After the tool finishes running, query results will be output to the terminal and acheck.htmlfile will be generated in the current folder.Execute the following command to specify configuration file path during query.
bashenvCheck check --config=./checkConfig.jsonThe tool will query whether applications specified by
program_listincheckConfig.jsonin the current folder are installed. After the tool finishes running, query results will be output to the terminal and acheck.htmlfile will be generated in the current folder.
Clock Synchronization Detection Function
Prerequisites
Using the clock synchronization detection function requires users to first modify related host information in the default configuration file.
Getting Started
Execute the following command to query clock error between other hosts and the bootstrap node host.
bashenvCheck clockThe tool will judge based on
hostsandclock_thresholdinconfig.jsonin the current folder whether clock error between non-bootstrap nodes and bootstrap node (bootstrap) does not exceed the specified threshold. After the tool finishes running, detection results will be output to the terminal and aclock.htmlfile will be generated in the current folder.Execute the following command to specify configuration file during query.
bashenvCheck clock --config=./clockConfig.jsonThe tool will judge based on
hostsandclock_thresholdinclockConfig.jsonin the current folder whether clock error between non-bootstrap nodes and bootstrap node (bootstrap) does not exceed the specified threshold. After the tool finishes running, detection results will be output to the terminal and aclock.htmlfile will be generated in the current folder.