A Kubernetes offline deployment method and system

By providing an automated Kubernetes offline deployment method and system, the problem of Kubernetes deployment in network-constrained environments is solved, and efficient and secure Kubernetes installation and configuration is achieved, ensuring the integrity and security of the deployment.

CN119512580BActive Publication Date: 2025-03-28BEIJING LEXUN TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510072710.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-01-17
Publication Date
2025-03-28
Estimated Expiration
2045-01-17

AI Technical Summary

Technical Problem

The deployment of Kubernetes usually relies on online resources, making it difficult to efficiently complete installation and configuration in intranet environments with high security requirements, industrial control systems with network isolation, and remote offline devices, and there are security risks and problems with outdated components.

Method used

Provides a Kubernetes offline deployment method and system, which automatically identifies the operating system of the target node, selects and configures suitable containers to run, performs exception analysis of dependent files, ensures that all dependent files have no exceptions, automatically transmits and loads the Kubernetes platform image, performs image verification, generates management policies, and automatically generates kubelet service configuration files.

Benefits of technology

It realizes efficient installation and configuration of Kubernetes in a network-constrained environment, avoids manual intervention and configuration errors, ensures the integrity of dependent files and the security of mirrors, and reduces security risks and the risk of outdated components.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119512580B_ABST
    Figure CN119512580B_ABST
Patent Text Reader

Abstract

The present invention discloses a Kubernetes offline deployment method and system, which relates to the technical field of platform deployment. All non-abnormal dependent files construct a file collection, and after detecting the reachability of all devices in the target node list, the dependent files in the file collection are automatically transmitted to the selected target node. When the target node loads the image stored offline and imports it into the container, the imported image is verified to determine whether it meets the operation requirements, and a management policy is automatically generated based on the judgment result. When all images meet the requirements, a service configuration file of kubelet is automatically generated. The deployment system automatically identifies the operating system of the target node, selects and configures a suitable container to run, avoids manual intervention and configuration errors, and ensures that all required dependent files are without problems by performing abnormal analysis of dependent files before deployment, avoiding the impact of missing, version mismatched or damaged files on the subsequent deployment process.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of platform deployment, and in particular to a Kubernetes offline deployment method and system. Background Art

[0002] With the development of container technology, Kubernetes has gradually become the mainstream platform for enterprise-level container orchestration. However, the deployment of Kubernetes usually relies on online resources (such as image repositories and official software repositories). In some scenarios, such as intranet environments with high security requirements, network-isolated industrial control systems, and remote offline devices, it becomes difficult to directly obtain resources online. Therefore, a batch offline deployment solution is needed to ensure that Kubernetes can be installed and configured efficiently even in a network-restricted environment.

[0003] However, the Kubernetes deployment process usually relies on online resources, such as image repositories (such as Docker Hub) and official software repositories. Continuous access to online resources enables Kubernetes to be updated, managed, and expanded in a timely manner. Existing technologies still have the following defects:

[0004] 1. This deployment mode faces huge challenges in some special environments. In some application scenarios, network security and access control are crucial (for example, the containerized platform for drone swarm tasks cannot rely on online resources for real-time updates because the task execution environment is completely disconnected from the Internet. When deploying Kubernetes and running containerized tasks, no resources can be obtained from the outside and offline resource packages must be relied on);

[0005] 2. In many offline deployment scenarios, container images may come from untrusted public image repositories, such as DockerHub. If these images are not strictly verified, they may contain malicious code or unaudited vulnerabilities, posing security risks. In addition, in an environment without network connection, updates cannot be obtained from public image repositories in a timely manner, resulting in outdated components in the cluster environment.

[0006] Based on this, the present invention proposes a Kubernetes offline deployment method and system, which automatically identifies the operating system of the target node, selects and configures a suitable container to run, avoids manual intervention and configuration errors, and performs abnormal analysis of dependent files before deployment to ensure that all required dependent files are in good condition, thus avoiding missing, version mismatched or damaged files from affecting the subsequent deployment process. Summary of the invention

[0007] The purpose of the present invention is to provide a Kubernetes offline deployment method and system to solve the deficiencies in the background technology.

[0008] In order to achieve the above object, the present invention provides the following technical solution: a Kubernetes offline deployment method, the deployment method comprising the following steps:

[0009] The deployment system downloads the Kubernetes platform installation dependency files based on the software library, performs abnormal analysis on all dependency files, and processes the dependency files with abnormalities. When all dependency files are normal, all dependency files are built into a file collection.

[0010] After detecting the reachability of all devices in the target node list, the dependent files in the file collection are automatically transferred to the selected target node. After the deployment system configures the target node, the corresponding container is selected based on the target node operating system. The image stored offline on the Kubernetes platform is loaded on the target node and imported into the container. The imported image is verified to determine whether it meets the Kubernetes platform operation requirements, and management policies are automatically generated based on the judgment results.

[0011] When all images meet the requirements, the kubelet service configuration file is automatically generated, and the join command generated by the Master node is distributed to all working nodes. After the Kubernetes cluster is deployed, the Kubernetes platform is built, and the health status of the Kubernetes platform is automatically checked and a deployment report is generated.

[0012] In a preferred implementation, the join command generated by the Master node is distributed to all working nodes, the Kubernetes platform is built after the Kubernetes cluster is deployed, and a deployment report is generated after the health status of the Kubernetes platform is automatically checked, including the following steps:

[0013] Run a command on the Master node to generate a token for the worker node to join the cluster, extract the token and the CA certificate hash value, and generate a standard join command based on the generated token and the Master node's APIServer address;

[0014] Use SSH or Ansible management tools to distribute the join command to all working nodes, configure the execution environment of the join command, including permissions and paths, and execute the join command on each working node through scripts or automation tools;

[0015] Deploy the Kubernetes network plug-in on the Master node, run kubectl get nodes to view the node status, view the status of all Pods in the system namespace, and use tools to test the interconnection of Pods between nodes;

[0016] Generate a deployment report, which includes node status information, system service information, log information, performance statistics, and deployment results. The deployment report is output in JSON, YAML, or PDF format.

[0017] In a preferred implementation, verifying the imported image to determine whether it meets the Kubernetes platform operating requirements includes the following steps:

[0018] Obtain the hash check factor, version difference index and metadata consistency index of the road image, normalize the version difference index and metadata consistency index, map the value range of the version difference index and metadata consistency index to [0,1], and then calculate the image condition coefficient, the expression is: , where is the mirror condition coefficient, is the normalized metadata consistency index, is the normalized version difference index, is the hash check factor;

[0019] If the image condition coefficient is greater than or equal to the condition threshold, it is judged that the Kubernetes platform operation requirements are met. If the image condition coefficient is less than the condition threshold, it is judged that the Kubernetes platform operation requirements are not met.

[0020] In a preferred embodiment, the deployment system downloads the Kubernetes platform installation dependency files based on the software library, performs abnormal analysis on all dependency files, and processes the dependency files with abnormalities, including the following steps:

[0021] Get the damage detection value, file coverage, and dependency matching of dependent files. Get the file index by calculating the damage detection value, file coverage, and dependency matching. The expression is: , where is the file index, Assign values ​​to damage detection, is the file coverage, is the maximum file coverage among all dependent files, To rely on matching, The maximum dependency matching degree among all dependency files;

[0022] Compare the obtained file index with the preset index threshold. The index threshold is used to analyze whether the dependent file has an abnormality. If the file index is less than the index threshold, the dependent file is analyzed to have an abnormality. If the file index is greater than or equal to the index threshold, the dependent file is analyzed to have no abnormality.

[0023] For dependent files with exceptions, use the repair tool to automatically repair them. If the dependent files still have exceptions after the repair, re-download the dependent files until all dependent files are normal, and then build a file collection for all dependent files.

[0024] In a preferred embodiment, after detecting the reachability of all devices in the target node list, automatically transmitting the dependent files in the file set to the selected target node includes the following steps:

[0025] After obtaining the port connectivity score and the network security score of the target node, the port connectivity score and the network security score are normalized so that the value range of the port connectivity score and the network security score is mapped to [0,1], and the normalized value of the port connectivity score and the normalized value of the network security score are obtained. The normalized value of the port connectivity score and the normalized value of the network security score are summed to obtain the reachability factor of the target node;

[0026] All target nodes are sorted from large to small according to the reachability factor to generate a node list. After selecting the target node ranked first in the node list, the dependent files in the file collection are automatically transferred to the selected target node.

[0027] In a preferred embodiment, the calculation expression of the metadata consistency index is: , where is the metadata consistency index, is the number of metadata, For the The matching status of metadata;

[0028] The calculation logic of the version difference index is as follows: obtain the current version label of the image, subtract the image required version label from the current version label of the image to obtain the label difference, and take the absolute value of the label difference as the version difference index;

[0029] The generation expression of the hash check factor is: , where is the image hash value calculated by algorithms such as SHA256. The expected hash value recorded in the image metadata.

[0030] In a preferred embodiment, after the deployment system configures the target node, the corresponding container is selected based on the target node operating system, the image stored offline on the Kubernetes platform is loaded on the target node, and imported into the container, including the following steps:

[0031] Obtain the operating system type and version of the target node, check whether the operating system supports the pre-selected container, generate an adaptability report based on the operating system, and record compatibility information;

[0032] Install and configure the container runtime that supports Kubernetes on the target node, select the container runtime installation package that is compatible with the target node's operating system from the offline resource library, transfer it, and install the container runtime;

[0033] Transfer the offline image required by the Kubernetes platform from the deployment system to the target node, use the verification tool to verify the integrity of the image file, send the image file to the image storage directory of the target node through the transmission protocol, and run the container on the target node;

[0034] Import the image into the container and run it. Use the dockerimages or ctrimagesls command to check whether the image is loaded successfully.

[0035] In a preferred embodiment, the calculation expression of the port connectivity score is: , where Score port connectivity, For the The connectivity of the ports, For the The weight of the port, is the number of ports in the target node;

[0036] The calculation expression of the network security score is: , where Score the network security. is the authentication success rate, The number of firewall blocking rules. , is the adjustment coefficient, and , Both are greater than 0.

[0037] In a preferred embodiment, the acquisition logic of the damage detection value is: detect the downloaded dependent file, if the dependent file is not damaged after detection, the damage detection value is equal to 1, if the dependent file is damaged after detection, the damage detection value is equal to 0;

[0038] The calculation logic of the file coverage rate is as follows: obtain the number of downloaded files in the dependent files, and divide the number of downloaded files by the total number of dependent files to obtain the file coverage rate;

[0039] The calculation logic of the dependency matching degree is: obtaining the number of files of matching versions in the dependency files, and dividing the number of files of matching versions by the total number of files in the dependency files to obtain the dependency matching degree.

[0040] A Kubernetes offline deployment system, including a file processing module, a node analysis module, an image verification module, and a platform construction module;

[0041] File processing module: Downloads Kubernetes platform installation dependency files based on the software library, performs abnormal analysis on all dependency files, and processes the dependency files with abnormalities. When all dependency files are normal, all dependency files are built into a file collection.

[0042] Node analysis module: After detecting the reachability of all devices in the target node list, it automatically transfers the dependent files in the file collection to the selected target node. After configuring the target node, it selects the corresponding container based on the target node operating system, loads the image stored offline on the Kubernetes platform on the target node, and imports it into the container.

[0043] Image verification module: Verify the imported images to determine whether they meet the Kubernetes platform operation requirements, and automatically generate management policies based on the judgment results. When all images meet the requirements, the kubelet service configuration file is automatically generated;

[0044] Platform construction module: distributes the join command generated by the Master node to all working nodes, builds the Kubernetes platform after the Kubernetes cluster is deployed, and automatically checks the health status of the Kubernetes platform and generates a deployment report, including the node status and the running status of system services.

[0045] In the above technical solution, the technical effects and advantages provided by the present invention are:

[0046] 1. The present invention analyzes all dependent files for exceptions and processes the dependent files with exceptions. When all dependent files are normal, all dependent files are constructed into a file set. After detecting the reachability of all devices in the target node list, the dependent files in the file set are automatically transmitted to the selected target node. When the image stored offline by the Kubernetes platform is loaded at the target node and imported into the container, the imported image is verified to determine whether the Kubernetes platform operation requirements are met, and the management strategy is automatically generated according to the judgment result. When all images meet the requirements, the service configuration file of kubelet is automatically generated. The deployment system automatically identifies the operating system of the target node, selects and configures a suitable container to run, avoids manual intervention and configuration errors, and ensures that all required dependent files have no problems by performing abnormal analysis of dependent files before deployment, avoiding missing, version mismatched or damaged files from affecting the subsequent deployment process, automatically detecting the reachability of the target node, ensuring that the file is successfully transmitted at the target node, and performing integrity verification, avoiding deployment failures caused by transmission errors, and importing and verifying the image in an offline environment to ensure that the imported image meets the requirements of the Kubernetes platform, avoiding security risks caused by non-compliant or unreviewed images.

[0047] 2. This application distributes the join command generated by the Master node to all working nodes, builds the Kubernetes platform after the Kubernetes cluster is deployed, and automatically checks the health status of the Kubernetes platform and generates a deployment report, including the node status and the operating status of system services. By performing comprehensive health checks on the built Kubernetes platform, it is helpful to improve the stability of the later operation of the Kubernetes platform. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the present invention. For ordinary technicians in this field, other drawings can also be obtained based on these drawings.

[0049] Figure 1 The present invention is a flow chart of the method. DETAILED DESCRIPTION

[0050] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0051] Example 1: Please refer to Figure 1 As shown, a Kubernetes offline deployment method described in this embodiment includes the following steps:

[0052] The deployment system downloads the Kubernetes platform installation dependency files based on the software library, analyzes all dependency files for exceptions, and processes the dependency files with exceptions. When all dependency files are normal, all dependency files are built into a file collection. After detecting the reachability of all devices in the target node list, the dependency files in the file collection are automatically transferred to the selected target node. After the deployment system configures the target node, it selects the corresponding container based on the target node operating system, loads the image stored offline on the target node, and when it is imported into the container, it verifies the imported image to determine whether it meets the Kubernetes platform operation requirements, and automatically generates a management policy based on the judgment result. When all images meet the requirements, the kubelet service configuration file (the service configuration file includes Kubernetes components and network plug-ins) is automatically generated to complete service registration and initialization configuration, and the join command generated by the Master node is distributed to all working nodes. After the Kubernetes cluster is deployed, the Kubernetes platform is built, and the health status of the Kubernetes platform is automatically checked to generate a deployment report, including the node status and the running status of the system service.

[0053] The Master node includes:

[0054] API-Server: provides an interface for interacting with the Kubernetes cluster.

[0055] Controller-Manager: manages the state of resources and ensures that the expected state is consistent with the actual state.

[0056] Scheduler: Responsible for allocating containers to appropriate nodes to run.

[0057] etcd: A distributed storage database used to store cluster configuration information and status.

[0058] The working nodes include:

[0059] kubelet: An agent running on each node that manages containers.

[0060] Container-Runtime: Container runtime, such as Docker or containerd.

[0061] kube-proxy: provides network communication and load balancing functions.

[0062] This application analyzes all dependent files for exceptions and processes the dependent files with exceptions. When all dependent files are normal, all dependent files are constructed into a file collection. After detecting the reachability of all devices in the target node list, the dependent files in the file collection are automatically transferred to the selected target node. When the image stored offline by the Kubernetes platform is loaded on the target node and imported into the container, the imported image is verified to determine whether it meets the operating requirements of the Kubernetes platform, and the management policy is automatically generated based on the judgment result. When all images meet the requirements, the service configuration file of kubelet is automatically generated. The deployment system automatically identifies the operating system of the target node, selects and configures a suitable container to run, avoiding manual intervention and configuration errors. By performing abnormal analysis of dependent files before deployment, it ensures that all required dependent files are OK, avoiding missing, version mismatched or damaged files from affecting the subsequent deployment process, automatically detecting the reachability of the target node, ensuring that the file is successfully transmitted at the target node, and performing integrity verification, avoiding deployment failures caused by transmission errors, and importing and verifying the image in an offline environment to ensure that the imported image meets the requirements of the Kubernetes platform, avoiding security risks caused by non-compliant or unreviewed images.

[0063] This application distributes the join command generated by the Master node to all working nodes, builds the Kubernetes platform after the Kubernetes cluster is deployed, and automatically checks the health status of the Kubernetes platform and generates a deployment report, including the node status and the operating status of system services. By performing comprehensive health checks on the built Kubernetes platform, it is helpful to improve the stability of the later operation of the Kubernetes platform.

[0064] Embodiment 2: The deployment system downloads Kubernetes platform installation dependency files based on the software library, performs abnormal analysis on all dependency files, and processes the dependency files with abnormalities. When all dependency files are normal, all dependency files are constructed into a file set, including the following steps:

[0065] The deployment system automatically connects to the preconfigured software library (such as a private warehouse or an offline repository), downloads the dependency files required for Kubernetes installation, obtains the target version of the Kubernetes platform and a list of related components, and extracts all related dependency files from the software library, including: Kubernetes core components (kube-apiserver, kube-scheduler, kube-controller-manager, etc.), container operation (such as containerd or Docker), network plug-ins (such as Flannel, Calico, etc.), cluster tools (such as kubeadm, kubectl), and stores the downloaded dependency files in the local cache directory.

[0066] Get the damage detection value, file coverage, and dependency matching of dependent files. Get the file index by calculating the damage detection value, file coverage, and dependency matching. The expression is: , where is the file index, Assign values ​​to damage detection, is the file coverage, is the maximum file coverage among all dependent files, To rely on matching, The maximum dependency matching degree among all dependency files;

[0067] The larger the file index, the less abnormal the dependent file is. The obtained file index is compared with the preset index threshold. The index threshold is used to analyze whether the dependent file is abnormal. If the file index is less than the index threshold, the dependent file is abnormal. If the file index is greater than or equal to the index threshold, the dependent file is not abnormal.

[0068] For dependent files with exceptions, use the repair tool to automatically repair them. If the dependent files still have exceptions after the repair, re-download the dependent files until all dependent files are normal, and then build a file collection for all dependent files.

[0069] The logic for obtaining the damage detection value is as follows: the downloaded dependent file is detected. If the dependent file is not damaged after the detection, the damage detection value is equal to 1; if the dependent file is damaged after the detection, the damage detection value is equal to 0;

[0070] The calculation logic of file coverage is: obtain the number of downloaded files in the dependent files, and divide the number of downloaded files by the total number of dependent files to obtain the file coverage. The larger the file coverage, the more complete the dependent files are.

[0071] The calculation logic of dependency matching is as follows: obtain the number of files with matching versions in the dependency file, and divide the number of files with matching versions by the total number of dependency files to obtain the dependency matching degree. The larger the dependency matching degree, the more suitable the dependency file is for use on the Kubernetes platform.

[0072] After detecting the reachability of all devices in the target node list, automatically transferring dependent files in the file collection to the selected target node includes the following steps:

[0073] Get a list of target nodes, including IP addresses or host names, port numbers, etc. Perform connectivity tests on each target node (such as using ICMPPing or TCP port detection);

[0074] After obtaining the port connectivity score and network security score of the target node, the port connectivity score and the network security score are normalized so that the value range of the port connectivity score and the network security score is mapped to [0,1], and the normalized value of the port connectivity score and the normalized value of the network security score are obtained. The normalized value of the port connectivity score and the normalized value of the network security score are summed to obtain the reachability factor of the target node. The larger the value of the reachability factor is, the higher the reachability of the target node is.

[0075] All target nodes are sorted from large to small according to the reachability factor to generate a node list. After selecting the target node ranked first in the node list, the dependent files in the file collection are automatically transferred to the selected target node.

[0076] The calculation expression of port connectivity score is: , where Score port connectivity, For the The connectivity of the ports (1 means connected, 0 means disconnected), For the The weight of the port, is the number of ports in the target node. The larger the port connectivity score is, the better the overall port connectivity of the target node is.

[0077] The calculation expression of network security score is: , where is the network security score, is the authentication success rate (value range: 0-1), The number of firewall blocking rules. , is the adjustment coefficient, and , Both are greater than 0. The larger the network security score is, the higher the network security of the target node is.

[0078] Package and optimize the file collection to improve transmission efficiency, and select the corresponding dependent files according to the target node operating system and architecture. Compress the file collection (such as using tar.gz format) to reduce the amount of data transmitted. Create a metadata file to record the structure and verification information of the file collection (such as SHA256 hash). Ensure that the file collection has passed the integrity verification and confirmed that it is not damaged.

[0079] Determine the appropriate file transfer protocol to ensure that files can be transferred to the target node securely and efficiently. Select the transfer protocol based on the network environment: SSH / SCP: Applicable to scenarios with high security requirements. FTP / SFTP: Applicable to batch transfer of large files. HTTP / HTTPS: Used in scenarios that require simple and fast transfer. rsync: Used in scenarios that require incremental transfer or breakpoint-resume transfer. Configure the authentication information of the transfer channel (such as user name, password, or key).

[0080] Automatically transfer a collection of files from the deployment system to the target node, and transfer the collection of files to the specified directory of the target node (such as / opt / k8s-dependencies). Enable real-time verification during the transfer process: compare file sizes to ensure the transfer is complete. Check the file transfer rate and record abnormal situations. For nodes where the transfer fails, the system automatically retries and records logs.

[0081] Ensure that the file set received on the target node is consistent with the source file. Generate a hash value (such as SHA256) of the received file on the target node. Compare it with the hash value of the source file set. If file verification fails: Automatically retransmit the abnormal file. If it fails multiple times, record detailed logs and send alarms.

[0082] After the deployment system configures the target node, it selects the corresponding container based on the target node operating system, loads the image stored offline on the Kubernetes platform on the target node, and imports it into the container, including the following steps:

[0083] Ensure that the target node has installed container runtimes and dependencies that are compatible with its operating system. Obtain the target node's operating system type and version (such as Ubuntu, CentOS, Red Hat, Windows Server). Check whether the operating system supports the pre-selected container runtime (such as Docker, containerd, CRI-O). Generate a compatibility report based on the operating system and record the compatibility information.

[0084] Install and configure Container Runtime that supports Kubernetes on the target node. Select the Container Runtime installation package that is compatible with the target node's operating system from the offline repository. Transfer and install Container Runtime, and ensure that necessary dependencies (such as CNI plugins) are correctly installed. Check the status of the Container Runtime service to ensure that it is started normally.

[0085] Transfer the offline image required by the Kubernetes platform from the deployment system to the target node. Use verification tools (such as MD5, SHA256) to verify the integrity of the image file to ensure that it is not damaged during the transmission process. Send the image file to the image storage directory of the target node through a secure transmission protocol (such as SCP, rsync). Run the container running tool (such as dockerload or ctrimport) on the target node to import the image into the container for running. Ensure that the imported image meets the requirements of the Kubernetes platform operation. Use the dockerimages or ctrimagesls command to check whether the image is loaded successfully. Verify that the image tag (Tag), size, and hash value are consistent with the metadata recorded in the offline storage. Start the test container instance to ensure that the image can be loaded and run correctly.

[0086] The following shows the directory of the Kubernetes v1.28.2 version:

[0087] -registry.cn-beijing.aliyuncs.com / kubesphereio / pause:3.9

[0088] -registry.cn-beijing.aliyuncs.com / kubesphereio / kube-apiserver:v1.28.8

[0089] -registry.cn-beijing.aliyuncs.com / kubesphereio / kube-controller-manager:v1.28.8

[0090] -registry.cn-beijing.aliyuncs.com / kubesphereio / kube-scheduler:v1.28.8

[0091] -registry.cn-beijing.aliyuncs.com / kubesphereio / kube-proxy:v1.28.8

[0092] -registry.cn-beijing.aliyuncs.com / kubesphereio / coredns:1.9.3

[0093] -registry.cn-beijing.aliyuncs.com / kubesphereio / k8s-dns-node-cache:1.22.20

[0094] -registry.cn-beijing.aliyuncs.com / kubesphereio / kube-controllers:v3.27.3

[0095] -registry.cn-beijing.aliyuncs.com / kubesphereio / cni:v3.27.3

[0096] -registry.cn-beijing.aliyuncs.com / kubesphereio / node:v3.27.3

[0097] -registry.cn-beijing.aliyuncs.com / kubesphereio / flannel:v0.21.3

[0098] -registry.cn-beijing.aliyuncs.com / kubesphereio / flannel-cni-plugin:v1.1.2

[0099] You can execute scripts to automatically pull and package

[0100] #! / bin / bash

[0101] #Mirror list (mirror name: tag)

[0102] images=(

[0103] -registry.cn-beijing.aliyuncs.com / kubesphereio / pause:3.9

[0104] -registry.cn-beijing.aliyuncs.com / kubesphereio / kube-apiserver:v1.28.8

[0105] -registry.cn-beijing.aliyuncs.com / kubesphereio / kube-controller-manager:v1.28.8

[0106] -registry.cn-beijing.aliyuncs.com / kubesphereio / kube-scheduler:v1.28.8

[0107] -registry.cn-beijing.aliyuncs.com / kubesphereio / kube-proxy:v1.28.8

[0108] -registry.cn-beijing.aliyuncs.com / kubesphereio / coredns:1.9.3

[0109] -registry.cn-beijing.aliyuncs.com / kubesphereio / k8s-dns-node-cache:1.22.20

[0110] -registry.cn-beijing.aliyuncs.com / kubesphereio / kube-controllers:v3.27.3

[0111] -registry.cn-beijing.aliyuncs.com / kubesphereio / cni:v3.27.3

[0112] -registry.cn-beijing.aliyuncs.com / kubesphereio / node:v3.27.3

[0113] -registry.cn-beijing.aliyuncs.com / kubesphereio / flannel:v0.21.3

[0114] -registry.cn-beijing.aliyuncs.com / kubesphereio / flannel-cni-plugin:v1.1.2 )

[0116] #Maximum number of retries

[0117] max_retries=10

[0118] #Function to pull the image

[0119] pull_image(){

[0120] localimage=$1

[0121] localretries=0

[0122] while[$retries-lt$max_retries];do

[0123] echo "Pulling$image(attempt$((retries+1)) / $max_retries)..."

[0124] ifdocker pull $image; then

[0125] echo "$imagepulledsuccessfully."

[0126] Return-0

[0127] else

[0128] echo "Failedtopull$image.Retrying..."

[0129] retries=$((retries+1))

[0130] sleep2#Wait 2 seconds and try again

[0131] fi

[0132] done

[0133] echo "Failedtopull$imageafter$max_retriesattempts."

[0134] Return-1

[0135] }

[0136] #Batch pull images

[0137] echo "Startingtopullimages..."

[0138] forimagein"${images[@]}";do

[0139] pull_image$image

[0140] if[$?-ne0];then

[0141] echo "Errorpulling$image.Movingontothenextimage."

[0142] fi

[0143] done

[0144] echo "Allimagepullattemptscompleted."

[0145] output_file="k8s-v1.28.8.tar"

[0146] echo "Savingimagesto$output_file..."

[0147] dockersave-o$output_file "${images[@]}"

[0148] After the final execution, it is packaged into a tar package of "k8s-v1.28.8.tar".

[0149] The code shows how to pull and package the image on the target node that can access the network normally.

[0150] Verify the imported images to determine whether they meet the Kubernetes platform operation requirements, and automatically generate management policies based on the judgment results. When all images meet the requirements, automatically generate kubelet service configuration files (service configuration files include Kubernetes components and network plug-ins) to complete service registration and initialization configuration, including the following steps:

[0151] Obtain the hash check factor, version difference index and metadata consistency index of the road image, normalize the version difference index and metadata consistency index, map the value range of the version difference index and metadata consistency index to [0,1], and then calculate the image condition coefficient, the expression is: , where is the mirror condition coefficient, is the normalized metadata consistency index, is the normalized version difference index, is the hash check factor; if the image condition coefficient is greater than or equal to the condition threshold, it is judged that the Kubernetes platform operation requirements are met; if the image condition coefficient is less than the condition threshold, it is judged that the Kubernetes platform operation requirements are not met.

[0152] The calculation expression of metadata consistency index is: , where is the metadata consistency index, is the number of metadata, For the The match status of the metadata (1 for match, 0 for mismatch).

[0153] The calculation logic of the version difference index is as follows: obtain the current version label of the image, subtract the required version label of the image from the current version label of the image to obtain the label difference, and take the absolute value of the label difference as the version difference index. The larger the version difference index, the more incompatible the image is with the target node version.

[0154] The expression for generating the hash check factor is: , where is the image hash value calculated by algorithms such as SHA256. is the expected hash value recorded in the image metadata, Indicates other.

[0155] Distribute the join command generated by the Master node to all working nodes. Build the Kubernetes platform after the Kubernetes cluster is deployed. Automatically check the health status of the Kubernetes platform and generate a deployment report, including the node status and the running status of the system services. The following steps are included:

[0156] Run a command on the Master node to generate a token for the worker node to join the cluster (such as kubeadmtokencreate). Extract the token and the CA certificate hash value, and generate a standard join command based on the generated token and the APIServer address of the Master node:

[0157] kubeadmjoin <master-api-server-ip> : <port>--token <token>--discovery-token-ca-cert-hashsha256: <hash>; This command will be used to join the Kubernetes cluster on the worker node;

[0158] Use SSH, Ansible or other remote management tools to distribute the join command to all working nodes. Configure the execution environment of the join command, including permissions and paths, execute the join command on each working node through scripts or automation tools, monitor the logs during the execution process, record successful or failed nodes, and run kubectl get nodes on the Master node to verify that all working nodes have been successfully joined;

[0159] Deploy Kubernetes network plug-ins (such as Flannel, Calico) on the Master node. Verify that the network plug-in runs successfully. Ensure that the core components of Kubernetes (such as etcd, kube-scheduler, kube-controller-manager, kube-apiserver) are running correctly;

[0160] Node status check: Run kubectl get nodes to check the node status. Check whether the node's STATUS is Ready.

[0161] System service check: Use kubectl get pods -n kube-system to view the status of all Pods in the system namespace. Ensure that the Pod status of key components (such as coredns, kube-proxy, etcd) is Running.

[0162] Network connectivity check: Use tools (such as kubectlexec) to test the interconnection of Pods between nodes. Ensure that Service and Ingress functions are normal.

[0163] Resource scheduling check: Deploy a simple test Pod to verify resource scheduling capabilities.

[0164] Generates a deployment report, including:

[0165] Node status information: includes each node’s IP address, role (Master / Worker), status (such as Ready), and available resources (CPU, memory).

[0166] System service information: Lists the running status and event logs of Kubernetes system services. Checks whether there are any failed Pods and records related issues.

[0167] Log information: Collect logs of key components (such as APIServer, Scheduler, and ControllerManager).

[0168] Performance statistics: record performance data such as system startup time and resource usage.

[0169] Deployment results: summarize the number of nodes where deployment succeeded or failed. If there are failed nodes, attach detailed reasons and solutions.

[0170] Generate report file: Output deployment report in JSON, YAML, or PDF format for operation and maintenance personnel to view and archive.

[0171] Through the above steps, the whole process from generating the join command on the Master node to distributing and executing it, and then to health check and report generation after the Kubernetes cluster is deployed can be completed efficiently. The whole process is highly automated, which can reduce human intervention and improve deployment efficiency and accuracy.

[0172] Embodiment 3: A Kubernetes offline deployment system described in this embodiment includes a file processing module, a node analysis module, an image verification module, and a platform construction module;

[0173] File processing module: Downloads Kubernetes platform installation dependency files based on the software library, performs abnormal analysis on all dependency files, and processes the dependency files with abnormalities. When all dependency files are normal, all dependency files are built into a file collection, and the file collection is sent to the node analysis module.

[0174] Node analysis module: After detecting the reachability of all devices in the target node list, it automatically transfers the dependent files in the file collection to the selected target node. After configuring the target node, it selects the corresponding container based on the target node operating system, loads the image stored offline on the Kubernetes platform on the target node, imports it into the container, and sends the imported image to the image verification module.

[0175] Image verification module: Verify the imported images to determine whether they meet the Kubernetes platform operation requirements, and automatically generate management policies based on the judgment results. When all images meet the requirements, automatically generate the kubelet service configuration file (the service configuration file includes Kubernetes components and network plug-ins), complete service registration and initialization configuration, and send the service configuration file to the platform construction module;

[0176] Platform construction module: distributes the join command generated by the Master node to all working nodes, builds the Kubernetes platform after the Kubernetes cluster is deployed, and automatically checks the health status of the Kubernetes platform and generates a deployment report, including the node status and the running status of system services.

[0177] The above formulas are all dimensionless and numerical calculations. The formula is a formula for the most recent real situation obtained by collecting a large amount of data and performing software simulation. The preset parameters in the formula are set by technicians in this field according to actual conditions.

[0178] In the description of this specification, the description with reference to the terms "one embodiment", "example", "specific example", etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any one or more embodiments or examples in a suitable manner.

[0179] The preferred embodiments of the present invention disclosed above are only used to help explain the present invention. The preferred embodiments do not describe all the details in detail, nor do they limit the invention to only specific implementation methods. Obviously, many modifications and changes can be made according to the content of this specification. This specification selects and specifically describes these embodiments in order to better explain the principles and practical applications of the present invention, so that those skilled in the art can understand and use the present invention well. The present invention is limited only by the claims and their full scope and equivalents.< / hash> < / token> < / port> < / master-api-server-ip>

Claims

1. A Kubernetes offline deployment method, characterized by: The deployment method comprises the following steps: The deployment system downloads the Kubernetes platform installation dependency files based on the software library, performs anomaly analysis on all dependency files, obtains the damage detection assignment, file coverage, and dependency matching of the dependency files, and obtains the file index through damage detection assignment, file coverage, and dependency matching calculations. The expression is: , where is the file index, Assign values ​​to damage detection, is the file coverage, is the maximum file coverage among all dependent files, To rely on matching, The maximum dependency matching degree among all dependency files; Compare the obtained file index with the preset index threshold. The index threshold is used to analyze whether there are abnormalities in the dependent files. If the file index is less than the index threshold, the dependent files are analyzed to be abnormal. If the file index is greater than or equal to the index threshold, the dependent files are analyzed to be normal. The abnormal dependent files are processed. When all dependent files are normal, all dependent files are constructed into a file set. After detecting the reachability of all devices in the target node list, the dependent files in the file collection are automatically transferred to the selected target node. After the deployment system configures the target node, the corresponding container is selected based on the target node operating system. The image stored offline on the Kubernetes platform is loaded on the target node and imported into the container. The imported image is verified to determine whether it meets the Kubernetes platform operation requirements, and management policies are automatically generated based on the judgment results. When all images meet the requirements, the kubelet service configuration file is automatically generated, and the join command generated by the Master node is distributed to all working nodes. After the Kubernetes cluster is deployed, the Kubernetes platform is built, and the health status of the Kubernetes platform is automatically checked and a deployment report is generated.

2. A Kubernetes offline deployment method according to claim 1, characterized in that: Distribute the join command generated by the Master node to all working nodes. Build the Kubernetes platform after the Kubernetes cluster is deployed. Automatically check the health status of the Kubernetes platform and generate a deployment report, including the following steps: Run a command on the Master node to generate a token for the worker node to join the cluster, extract the token and the CA certificate hash value, and generate a standard join command based on the generated token and the Master node's APIServer address; Use SSH or Ansible management tools to distribute the join command to all working nodes, configure the execution environment of the join command, including permissions and paths, and execute the join command on each working node through scripts or automation tools; Deploy the Kubernetes network plug-in on the Master node, run kubectl get nodes to view the node status, view the status of all Pods in the system namespace, and use tools to test the interconnection of Pods between nodes; Generate a deployment report, which includes node status information, system service information, log information, performance statistics, and deployment results. The deployment report is output in JSON, YAML, or PDF format.

3. A Kubernetes offline deployment method according to claim 2, characterized in that: Verify the imported image to determine whether it meets the Kubernetes platform operating requirements, including the following steps: Obtain the hash check factor, version difference index and metadata consistency index of the road image, normalize the version difference index and metadata consistency index, map the value range of the version difference index and metadata consistency index to [0,1], and then calculate the image condition coefficient, the expression is: , where is the mirror condition coefficient, is the normalized metadata consistency index, is the normalized version difference index, is the hash check factor; If the image condition coefficient is greater than or equal to the condition threshold, it is judged that the Kubernetes platform operation requirements are met. If the image condition coefficient is less than the condition threshold, it is judged that the Kubernetes platform operation requirements are not met.

4. A Kubernetes offline deployment method according to claim 3, characterized in that: Processing abnormal dependent files includes the following steps: For dependent files with exceptions, use the repair tool to automatically repair them. If the dependent files still have exceptions after the repair, re-download the dependent files until all dependent files are normal, and then build a file collection for all dependent files.

5. A Kubernetes offline deployment method according to claim 4, characterized in that: After detecting the reachability of all devices in the target node list, automatically transferring dependent files in the file collection to the selected target node includes the following steps: After obtaining the port connectivity score and the network security score of the target node, the port connectivity score and the network security score are normalized so that the value range of the port connectivity score and the network security score is mapped to [0,1], and the normalized value of the port connectivity score and the normalized value of the network security score are obtained. The normalized value of the port connectivity score and the normalized value of the network security score are summed to obtain the reachability factor of the target node; All target nodes are sorted from large to small according to the reachability factor to generate a node list. After selecting the target node ranked first in the node list, the dependent files in the file collection are automatically transferred to the selected target node.

6. A Kubernetes offline deployment method according to claim 5, characterized in that: The calculation expression of the metadata consistency index is: , where is the metadata consistency index, is the number of metadata, For the The matching status of metadata; The calculation logic of the version difference index is as follows: obtain the current version label of the image, subtract the image required version label from the current version label of the image to obtain the label difference, and take the absolute value of the label difference as the version difference index; The generation expression of the hash check factor is: , where is the image hash value calculated by the SHA256 algorithm, The expected hash value recorded in the image metadata.

7. A Kubernetes offline deployment method according to claim 6, characterized in that: After the deployment system configures the target node, it selects the corresponding container based on the target node operating system, loads the image stored offline on the Kubernetes platform on the target node, and imports it into the container, including the following steps: Obtain the operating system type and version of the target node, check whether the operating system supports the pre-selected container, generate an adaptability report based on the operating system, and record compatibility information; Install and configure the container runtime that supports Kubernetes on the target node, select the container runtime installation package that is compatible with the target node's operating system from the offline resource library, transfer it, and install the container runtime; Transfer the offline image required by the Kubernetes platform from the deployment system to the target node, use the verification tool to verify the integrity of the image file, send the image file to the image storage directory of the target node through the transmission protocol, and run the container on the target node; Import the image into the container and run it. Use the dockerimages or ctrimagesls command to check whether the image is loaded successfully.

8. A Kubernetes offline deployment method according to claim 7, characterized in that: The calculation expression of the port connectivity score is: , where Score port connectivity, For the The connectivity of the ports, For the The weight of the port, is the number of ports in the target node; The calculation expression of the network security score is: , where Score the network security. is the authentication success rate, The number of firewall blocking rules. , is the adjustment coefficient, and , Both are greater than 0.

9. A Kubernetes offline deployment method according to claim 4, characterized in that: The acquisition logic of the damage detection value is: detect the downloaded dependent file, if the dependent file is not damaged after the detection, the damage detection value is equal to 1, if the dependent file is damaged after the detection, the damage detection value is equal to 0; The calculation logic of the file coverage rate is as follows: obtain the number of downloaded files in the dependent files, and divide the number of downloaded files by the total number of dependent files to obtain the file coverage rate; The calculation logic of the dependency matching degree is: obtaining the number of files of matching versions in the dependency files, and dividing the number of files of matching versions by the total number of files in the dependency files to obtain the dependency matching degree.

10. A Kubernetes offline deployment system, used to implement the deployment method according to any one of claims 1 to 9, characterized in that: Including file processing module, node analysis module, image verification module, and platform construction module; File processing module: Downloads Kubernetes platform installation dependency files based on the software library, performs abnormal analysis on all dependency files, and processes the dependency files with abnormalities. When all dependency files are normal, all dependency files are built into a file collection. Node analysis module: After detecting the reachability of all devices in the target node list, it automatically transfers the dependent files in the file collection to the selected target node. After configuring the target node, it selects the corresponding container based on the target node operating system, loads the image stored offline on the Kubernetes platform on the target node, and imports it into the container. Image verification module: Verify the imported images to determine whether they meet the Kubernetes platform operation requirements, and automatically generate management policies based on the judgment results. When all images meet the requirements, the kubelet service configuration file is automatically generated; Platform construction module: distributes the join command generated by the Master node to all working nodes, builds the Kubernetes platform after the Kubernetes cluster is deployed, and automatically checks the health status of the Kubernetes platform and generates a deployment report, including the node status and the running status of system services.

Citation Information

Patent Citations

  • Creating method, device and equipment of application container

    CN111753291A

  • Deployment method and device of Kubernetes cluster

    CN114691153A