Configuration method and device of K8s cluster, equipment and storage medium
Through ansible, a role and shell script for K8s cluster in the domestic environment is built, and configuration files are created, which solves the problem of complex configuration of K8s cluster in the domestic environment, and achieves fast and accurate cluster configuration, improving deployment efficiency and adaptability.
Patent Information
- Application Number
- CN202311257489.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-26
- Publication Date
- 2025-03-28
AI Technical Summary
The lack of a complete set of K8s cluster configuration solutions in a domestic environment makes the deployment complex and time-consuming.
Through ansible, build role and shell scripts required for the K8s cluster in the domestic environment, create configuration files, including inventory files and group_vars files, and use these files to complete the configuration of the K8s cluster.
It realizes rapid configuration of K8s clusters, reduces manual operations, reduces the possibility of errors, and improves deployment consistency and adaptability.
Smart Images

Figure CN119718340A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to communication technology, and in particular to a configuration method, device, equipment and storage medium for a K8s cluster. Background Art
[0002] Kubernetes technology, referred to as K8s, is an open source system for automatically deploying, scaling, and managing containerized applications. K8s technology has become the standard for cloud-native application development and deployment. It simplifies application management and scaling, improves availability and maintainability, and makes it easier for containerized applications to run in a distributed environment.
[0003] K8s deployment is complex for users, especially in the environment of domestic operating systems. This is mainly reflected in the need to perform a series of debugging and configuration of cluster nodes before installation and deployment. In a domestic offline environment, there is no complete private deployment solution because the domestic environment may be different from the public cloud or standard data center environment. Summary of the invention
[0004] The present application provides a configuration method, apparatus, device and storage medium of a K8s cluster, which are used to solve the problem of a complete set of K8s cluster configuration in a localized environment in the prior art.
[0005] In a first aspect, the present application provides a configuration method for a K8s cluster, including:
[0006] Use Ansible to build the role and shell script required for the localized environment k8s cluster, where the role is used to encapsulate the playbook file directory, and the shell script is used to adapt the localized environment os parameter configuration and yumrepo source configuration;
[0007] Create a configuration file according to the hosts and host groups required by the localized environment. The configuration file includes an inventory file and a group_vars file. The inventory file is used to define the hosts and host groups operated in ansible-playbook, and the group_vars file is used to store variables associated with the host group.
[0008] According to the role, the shell script and the configuration file, the k8s cluster configuration of the localized environment is completed.
[0009] Optionally, completing the K8s cluster configuration of the localized environment according to the role, the shell script, and the configuration file includes:
[0010] By executing ansible-playbook, the shell script is called to perform the os parameter configuration adapted to the localized environment and the yumrepo source configuration on the hosts and host groups in the inventory file;
[0011] By executing ansible-playbook, the task in the role is called to configure disk partitions, clock source synchronization, firewalls, host names, and kernel upgrades for the hosts and host groups in the inventory file according to the variables in the group_vars file.
[0012] Optionally, before creating a configuration file according to the hosts and host groups required by the localized environment, the process further includes:
[0013] The host information in the deployment table template is obtained through a python script, wherein the host information includes the host and the host group; wherein the deployment table template is used for the user to fill in the host information.
[0014] Optionally, after using Ansible to build the roles and shell scripts required for the localized K8s cluster, it also includes:
[0015] The role, the shell script and the configuration file are packaged by rpmbuild to form an installation package.
[0016] Optionally, after the role, the shell script and the configuration file are packaged by rpmbuild, the step further includes:
[0017] Use the CLI command to upload the installation package of the configuration file and the yumrepo binary file package to the host.
[0018] Optionally, after completing the K8s cluster configuration of the localized environment, the following steps are also included:
[0019] Use kubeadm to quickly install the K8s cluster in the localized environment.
[0020] Optionally, the method further includes:
[0021] The localization environment is an ARM environment.
[0022] In a second aspect, the present application provides a configuration device for a K8s cluster, including:
[0023] A construction module is used to build the role and shell script required for the localized environment k8s cluster through ansible, wherein the role is used to encapsulate the playbook file directory, and the shell script is used to adapt the localized environment os parameter configuration and yumrepo source configuration;
[0024] A configuration module is used to create a configuration file according to the hosts and host groups required by the localized environment. The configuration file includes an inventory file and a group_vars file. The inventory file is used to define the hosts and host groups operated in ansible-playbook, and the group_vars file is used to store variables associated with the host group.
[0025] An execution module is used to complete the k8s cluster configuration of the localized environment according to the role, the shell script and the configuration file.
[0026] Optionally, the configuration module is specifically used to:
[0027] By executing ansible-playbook, the task in the role is called to configure disk partitions, clock source synchronization, firewalls, host names, and kernel upgrades for the hosts and host groups in the inventory file according to the variables in the group_vars file.
[0028] Optionally, the configuration module is further used for, before creating the configuration file according to the hosts and host groups required by the localized environment,
[0029] The host information in the deployment table template is obtained through a python script, wherein the host information includes the host and the host group; wherein the deployment table template is used for the user to fill in the host information.
[0030] Optionally, the construction module is also used to, after the roles and shell scripts required for building the localized environment K8s cluster through Ansible,
[0031] The role, the shell script and the configuration file are packaged by rpmbuild to form an installation package.
[0032] Optionally, the configuration module is further configured to, after the role, the shell script and the configuration file are packaged by rpmbuild,
[0033] Use the CLI command to upload the installation package of the configuration file and the yumrepo binary file package to the host.
[0034] Optionally, the execution module is specifically used to, after completing the K8s cluster configuration of the localized environment,
[0035] Use kubeadm to quickly install the K8s cluster in the localized environment.
[0036] Optionally, any of the three modules in the device is also used for:
[0037] The localization environment is an ARM environment.
[0038] In a third aspect, the present application provides a configuration device for a K8s cluster, comprising: a processor, and a memory in communication with the processor;
[0039] Memory stores computer-executable instructions;
[0040] The processor executes the computer execution instructions stored in the memory to implement various optional K8s cluster configuration methods as in the first aspect.
[0041] In a fourth aspect, the present application provides a readable storage medium, including computer execution instructions. When a processor executes the computer execution instructions, it executes various optional K8s cluster configuration methods such as the first aspect.
[0042] In a fifth aspect, the present application provides a program product, which includes a computer program, and the computer program is executed by a processor to implement various optional K8s cluster configuration methods as in the first aspect.
[0043] The present application provides a configuration method, device, equipment and storage medium for a K8s cluster. The method uses ansible to build the role and shell script required for the k8s cluster in a localized environment, wherein the role is used to encapsulate the file directory of the playbook, and the shell script is used to adapt the os parameter configuration and yumrepo source configuration of the localized environment; according to the host and host group required by the localized environment, a configuration file is created, the configuration file includes an inventory file and a group_vars file, the inventory file is used to define the host and host group operated in ansible-playbook, and the group_vars file is used to store the variables associated with the host group; according to the role, the shell script and the configuration file, the k8s cluster configuration of the localized environment is completed, thereby achieving the rapid configuration effect of the entire set of K8s clusters, using automated deployment configuration, reducing the need for manual operation, reducing the possibility of errors, improving the consistency of deployment, and the adaptability of the K8s cluster in the localized environment. It is achieved that the cluster configuration of the entire set of K8s is completed quickly and accurately according to the requirements of the localized environment. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0045] Figure 1 A K8s cluster configuration method process provided in this application embodiment Figure 1 ;
[0046] Figure 2 A K8s cluster configuration method process provided in this application embodiment Figure 2 ;
[0047] Figure 3 A schematic diagram of the configuration device structure of a K8s cluster provided in an embodiment of the present application;
[0048] Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application.
[0049] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0050] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0051] With the continuous development of science and technology, it is of great significance to establish a complete set of configurations for K8s clusters in a localized environment. The complete set of configurations for K8s improves the performance and availability of the cluster, meeting the high requirements of various businesses in a private cloud environment. It provides a more flexible, maintainable and manageable K8s infrastructure in a nationalized environment, promoting the sustainable development of information technology and the improvement of its competitiveness.
[0052] In the existing technology, in the scenario of domestic offline environment, there is a lack of a complete set of private deployment solutions. Manual construction and maintenance make K8s deployment complicated for users. Before installation and deployment, a series of debugging and configuration of cluster nodes are required, which is time-consuming and labor-intensive, increasing the complexity and cost of deployment.
[0053] Based on this, this application proposes a configuration method for a K8s cluster, which completes the K8s cluster configuration in a localized environment through the pre-built environment configuration package, localized scripts and configuration files, and uses ansible-playbook for unified execution. This increases the configurability and adaptability of the K8s cluster in the localized environment, helps to improve the deployment and management efficiency of the K8s cluster, and reduces labor costs and configuration time.
[0054] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.
[0055] Figure 1 A K8s cluster configuration method process provided in this application embodiment Figure 1 .like Figure 1 As shown, the method includes:
[0056] S101. Use Ansible to build the roles and shell scripts required for the localized K8s cluster. Roles are used to encapsulate the playbook file directory, and shell scripts are used to adapt the localized environment OS parameter configuration and yumrepo source configuration.
[0057] In this embodiment, role is a modular organization method of Ansible, which can be used for automated configuration and management tasks of K8s clusters. Ansible can cooperate with role to perform various tasks, including configuration management, application deployment, task automation and collaboration. Shell scripts are a set of text files used to execute shell commands and operations, which can be customized to adapt to the parameter configuration of the local environment.
[0058] Use ansible to create a file directory role, which is used to store and write the configuration tasks required for the localized K8s cluster, as well as shell scripts for os parameter configuration and yumrepo source configuration that adapt to the localized environment. Use the rpmbuild tool to package the created role, shell script, and other configuration files into an installation package, and then upload it to the required host through the CLI command.
[0059] S102. Create configuration files based on the hosts and host groups required for the localized environment. The configuration files include inventory files and group_vars files. The inventory files are used to define the hosts and host groups operated in ansible-playbook, and the group_vars files are used to store variables associated with the host groups.
[0060] In this embodiment, the host and host group are used to adapt to specific configuration and deployment requirements to meet the requirements of the localized environment.
[0061] The inventory file is an inventory file of Ansible, which is used to define the hosts and host groups to be operated in the Ansible playbook, including host names, IP addresses, usernames and passwords, etc.
[0062] The group_vars file is used to store localized environment parameter configuration variables associated with the host group. Each host group can have one or more group_vars files, each of which contains configuration parameters specific to the host group and contains instructions for turning on and off the content required to configure the localized environment. These parameter variables can be used in ansible-playbook.
[0063] ansible-playbook is a command-line tool used in ansible tools to execute playbooks, where playbooks contain tasks and host configurations for automated deployment and configuration.
[0064] According to the hosts and host groups required by the target localization environment, create the inventory file and group_vars file required to deploy the K8s cluster. The inventory file is used as an Ansible inventory file to define the hosts and host groups to be operated. At the same time, the group_vars file is used to store the variable tasks that need to be executed related to the host group.
[0065] S103. Complete the K8s cluster configuration of the localized environment based on the role, shell script, and configuration file.
[0066] In this embodiment, ansible-playbook is used to call the shell script to perform operating system parameter configuration and yumrepo source configuration of the localized environment on the host. In addition, ansible-playbook is used to automatically configure the task task according to the variables that need to be configured in the group_vars file, and the K8s cluster configuration of the localized environment is quickly completed through the kubeadm method.
[0067] The present application provides a configuration method, device, equipment and storage medium for a K8s cluster. The method uses ansible to build the role and shell script required for the K8s cluster in a localized environment, wherein the role is used to encapsulate the file directory of the playbook, and the shell script is used to adapt the OS parameter configuration and yumrepo source configuration of the localized environment; according to the host and host group required for the localized environment, a configuration file is created, the configuration file includes an inventory file and a group_vars file, the inventory file is used to define the host and host group operated in ansible-playbook, and the group_vars file is used to store variables associated with the host group; according to the role, shell script and configuration file, the K8s cluster configuration of the localized environment is completed, thereby achieving the rapid configuration effect of the entire set of K8s clusters, using automated deployment configuration, reducing the need for manual operation, reducing the possibility of errors, improving the consistency of deployment, and the adaptability of the K8s cluster in the localized environment. The cluster configuration of the entire set of K8s is completed quickly and accurately according to the requirements of the localized environment.
[0068] Figure 2 This is a K8s cluster configuration method process provided by the embodiment of the present application Figure 2 Based on the above embodiments, this embodiment describes the process of K8s cluster configuration in detail. Figure 2 As shown, the method includes:
[0069] S201. In the localized ARM environment, use ansible to build the roles and shell scripts required for the localized k8s cluster. Roles are used to encapsulate the playbook file directory, and shell scripts are used to adapt the localized environment os parameter configuration and yumrepo source configuration.
[0070] In this embodiment, the localized ARM environment refers to an ARM architecture computer system, in which ansible and Shell scripts can be used to build a K8s cluster to perform multiple tasks.
[0071] S202, packaging the role, shell script and configuration file through rpmbuild to form an installation package;
[0072] rpmbuild is a tool used to build installation packages. It can package roles, shell scripts, and configuration files into an installation package for subsequent operations.
[0073] In this embodiment, after the role, shell script and other configuration files are organized, the rpmbuild tool is used to package these files as a whole to form an installation package.
[0074] S203, uploading the installation package of the configuration file and the yumrepo binary file package to the host through the CLI command;
[0075] In this embodiment, the CLI command refers to issuing instructions in a text format to execute uploading the packaged configuration file installation package and the yumrepo binary file package to the host. The yumrepo binary file package refers to a software package for updating and managing various configuration files.
[0076] Upload the installation package containing roles, shell scripts, and other configuration files, as well as the yumrepo binary file package for updating and managing configuration files to the host through CLI commands for operation.
[0077] S204, obtaining host information in the deployment table template through a python script, where the host information includes hosts and host groups; wherein the deployment table template is used by users to fill in host information;
[0078] In this embodiment, the deployment table template includes a table file containing information about the deployment plan or deployment task, and is mainly used for users to fill in host information.
[0079] Use Python script to import the deployment table template table data with host information, and extract the host information including the main sentence and host name from the table data.
[0080] S205. Create configuration files according to the hosts and host groups required by the localized environment. The configuration files include inventory files and group_vars files. The inventory files are used to define the hosts and host groups operated in ansible-playbook, and the group_vars files are used to store variables associated with the host groups.
[0081] S206. By executing ansible-playbook, a shell script is called to perform OS parameter configuration and yumrepo source configuration adapted to the localized environment on the hosts and host groups in the inventory file;
[0082] In this embodiment, ansible-playbook calls and executes a shell script, using the hosts and host groups in the inventory file to perform OS parameter configuration and yumrepo source configuration adapted to the localized environment.
[0083] S207, by executing ansible-playbook, calling the task in the role to configure disk partitions, clock source synchronization, firewalls, host names, and kernel upgrades for the hosts and host groups in the inventory file according to the variables in the group_vars file;
[0084] The task in role refers to the task defined in the role, which can be called by one or more ansible-playbooks to perform corresponding operations. These tasks include disk partitioning, clock source synchronization, firewall, host name, and kernel upgrade.
[0085] In this embodiment, according to the established task, ansible-playbook is called in the role to use the host and host group to perform corresponding configurations of disk partitioning, clock source synchronization, firewall, host name, and kernel upgrade.
[0086] S208. Quickly install the K8s cluster in the localized environment through kubeadm.
[0087] The kubeadm method refers to a tool in K8s that can quickly and simply perform a K8s cluster on the required host.
[0088] In this embodiment, according to the configured environment parameters and configuration file installation package, the K8s cluster in the localized environment is quickly installed using the kubeadm method to implement the K8s cluster configuration in the localized environment.
[0089] The present application provides a configuration method, device, equipment and storage medium for a K8s cluster, which realizes the use of rpmbuild to package various files and upload the file package to the host through the CLI command, providing convenience for the installation of the K8s cluster configuration and ensuring the availability of the file package required for deployment. At the same time, the use of python scripts for information collection realizes the automatic collection of host information, reduces the possibility of manual input errors, further simplifies the installation process of the K8s cluster, improves deployment efficiency, helps to deploy and configure the K8s cluster in the domestic ARM environment, improves the maintainability and manageability of the K8s cluster in the domestic environment, and reduces the complexity of deployment.
[0090] Figure 3 A schematic diagram of a configuration device structure of a K8s cluster provided in an embodiment of the present application; Figure 3 As shown, the device comprises:
[0091] Module 301 is constructed to build the role and shell script required for the localized environment k8s cluster through ansible, where the role is used to encapsulate the playbook file directory, and the shell script is used to adapt the localized environment os parameter configuration and yumrepo source configuration;
[0092] Configuration module 302 is used to create a configuration file according to the hosts and host groups required by the localization environment. The configuration file includes an inventory file and a group_vars file. The inventory file is used to define the hosts and host groups operated in ansible-playbook, and the group_vars file is used to store variables associated with the host group.
[0093] Execution module 303 is used to complete the k8s cluster configuration of the localized environment according to the role, shell script and configuration file.
[0094] In a possible implementation, the configuration module 302 is specifically configured to:
[0095] By executing ansible-playbook, call the task in the role to configure disk partitions, clock source synchronization, firewalls, host names, and kernel upgrades for the hosts and host groups in the inventory file according to the variables in the group_vars file.
[0096] In a possible implementation, the configuration module 302 is further configured to, before creating a configuration file according to the hosts and host groups required by the localization environment,
[0097] The host information in the deployment table template is obtained through a python script. The host information includes hosts and host groups. The deployment table template is used by users to fill in the host information.
[0098] In a possible implementation, the construction module 301 is also used to, after using ansible to build the roles and shell scripts required for the localized environment K8s cluster,
[0099] Use rpmbuild to package the roles, shell scripts, and configuration files to form an installation package.
[0100] In a possible implementation, the configuration module 302 is further configured to package the role, shell script and configuration file through rpmbuild.
[0101] Use the CLI command to upload the configuration file installation package and the yumrepo binary file package to the host.
[0102] In a possible implementation, the execution module 303 is further used to, after completing the K8s cluster configuration of the localized environment,
[0103] Quickly install the K8s cluster in the localized environment through kubeadm.
[0104] In a possible implementation, any of the three modules described above is also used for
[0105] The localization environment is the ARM environment.
[0106] The present application also provides an electronic device, comprising: at least one processor and a memory; wherein,
[0107] Memory stores computer-executable instructions;
[0108] At least one processor executes the computer-executable instructions stored in the memory, so that the at least one processor performs the above method.
[0109] Figure 4 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. Figure 4 As shown, the electronic device 40 provided in this embodiment includes: at least one processor 401 and a memory 402. The device 40 also includes a communication component 403. The processor 401, the memory 402 and the communication component 403 are connected via a bus 404.
[0110] During the specific implementation process, at least one processor 401 executes the computer execution instructions stored in the memory 402, so that at least one processor 401 executes the above-mentioned K8s cluster configuration method.
[0111] The specific implementation process of the processor 401 can be found in the above method embodiment, and its implementation principle and technical effect are similar, so this embodiment will not be repeated here.
[0112] In the above Figure 4 In the illustrated embodiment, it should be understood that the processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. A general-purpose processor may be a microprocessor or any conventional processor. The steps of the method disclosed in the invention may be directly implemented as being executed by a hardware processor, or may be executed by a combination of hardware and software modules in the processor.
[0113] The memory may include a high-speed memory (Random Access Memory, RAM), and may also include a non-volatile memory (Non-volatile Memory, NVM), such as at least one disk memory.
[0114] The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, the bus in the drawings of the present application is not limited to only one bus or one type of bus.
[0115] The present application also provides a computer program product, including a computer program, which implements the above-mentioned K8s cluster configuration method when executed by a processor.
[0116] The present application also provides a computer-readable storage medium, in which computer execution instructions are stored. When a processor executes the computer execution instructions, the above-mentioned K8s cluster configuration method is implemented.
[0117] The above-mentioned readable storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk. The readable storage medium can be any available medium that can be accessed by a general or special-purpose computer.
[0118] An exemplary readable storage medium is coupled to a processor so that the processor can read information from the readable storage medium and write information to the readable storage medium. Of course, the readable storage medium can also be a component of the processor. The processor and the readable storage medium can be located in an application specific integrated circuit (Application Specific Integrated Circuits, referred to as: ASIC). Of course, the processor and the readable storage medium can also exist in the device as discrete components.
[0119] The division of units is only a logical function division, and there may be other divisions in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interface, device or unit, which can be electrical, mechanical or other forms.
[0120] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0121] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0122] If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention can essentially or in other words, the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods of each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
[0123] Those skilled in the art can understand that all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned storage medium includes: ROM, RAM, disk or optical disk and other media that can store program codes.
[0124] Finally, it should be noted that those skilled in the art will readily conceive of other embodiments of the present invention after considering the specification and practicing the invention disclosed herein. The present invention is intended to cover any variations, uses or adaptations of the present invention, which follow the general principles of the present invention and include common knowledge or customary technical means in the art not disclosed by the present invention, are not limited to the precise structure described above and shown in the drawings, and may be modified and changed in various ways without departing from the scope thereof. The scope of the present invention is limited only by the appended claims.
[0125] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary techniques in the art that are not disclosed in the present application. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present application are indicated by the following claims.
[0126] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.
Claims
1. A configuration method for a K8s cluster, characterized in that: include: Use Ansible to build the role and shell script required for the localized environment k8s cluster, where the role is used to encapsulate the playbook file directory, and the shell script is used to adapt the localized environment os parameter configuration and yumrepo source configuration; Create a configuration file according to the hosts and host groups required by the localized environment. The configuration file includes an inventory file and a group_vars file. The inventory file is used to define the hosts and host groups operated in ansible-playbook, and the group_vars file is used to store variables associated with the host group. According to the role, the shell script and the configuration file, the k8s cluster configuration of the localized environment is completed.
2. The method according to claim 1, characterized in that The K8s cluster configuration of the localized environment is completed according to the role, the shell script and the configuration file, including: By executing ansible-playbook, the shell script is called to perform the os parameter configuration adapted to the localized environment and the yumrepo source configuration on the hosts and host groups in the inventory file; By executing ansible-playbook, the task in the role is called to configure disk partitions, clock source synchronization, firewalls, host names, and kernel upgrades for the hosts and host groups in the inventory file according to the variables in the group_vars file.
3. The method according to claim 1, characterized in that Before creating the configuration file according to the host and host group required by the localized environment, the method further includes: The host information in the deployment table template is obtained through a python script, wherein the host information includes the host and the host group; wherein the deployment table template is used for the user to fill in the host information.
4. The method according to claim 1, characterized in that: After building the roles and shell scripts required for the localized environment K8s cluster through Ansible, the method further includes: The role, the shell script and the configuration file are packaged by rpmbuild to form an installation package.
5. The method according to claim 4, characterized in that After the role, the shell script and the configuration file are packaged by rpmbuild, the method further comprises: Use the CLI command to upload the installation package of the configuration file and the yumrepo binary file package to the host.
6. The method according to claim 1, characterized in that After completing the K8s cluster configuration of the localized environment, the method further includes: Use kubeadm to quickly install the K8s cluster in the localized environment.
7. The method according to any one of claims 1 to 6, characterized in that: The localization environment is an ARM environment.
8. A configuration device for a K8s cluster, characterized in that: include: A construction module is used to build the role and shell script required for the localized environment K8s cluster through Ansible, wherein the role is used to encapsulate the playbook file directory, and the shell script is used to adapt the localized environment OS parameter configuration and yumrepo source configuration; A configuration module is used to create a configuration file according to the hosts and host groups required by the localized environment. The configuration file includes an inventory file and a group_vars file. The inventory file is used to define the hosts and host groups operated in ansible-playbook, and the group_vars file is used to store variables associated with the host group. The execution module is used to complete the K8s cluster configuration of the localized environment according to the role, the shell script and the configuration file.
9. An electronic device, characterized in that: include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the configuration method of the K8s cluster as described in any one of claims 1 to 7.