Cluster management configuration method and device, computer device and storage medium
By obtaining the K8S cluster configuration file on the management machine, creating users and establishing relationships, and installing toolsets to verify management operations, the problem of remotely managing multiple K8S clusters on the same management machine is solved, achieving efficient and secure cluster management.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-06-29
- Publication Date
- 2026-03-24
AI Technical Summary
In existing technologies, a user can only manage one Kubernetes cluster, and it is not possible to remotely manage multiple Kubernetes clusters on the same management machine.
By obtaining the configuration file generated on the master node of the Kubernetes cluster, creating multiple users and adding them to the user group, establishing the correspondence between the Kubernetes cluster and the users, adding the configuration file to the directory of the corresponding user, installing the toolset and executing management commands, the feasibility of remote management operations is verified.
This enables remote management of multiple Kubernetes clusters from a single management machine, avoiding frequent logins, improving management efficiency, and ensuring security.
Smart Images

Figure CN115543956B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of cloud computing, and particularly relates to a cluster management configuration method and device, computer equipment and a storage medium. BACKGROUND
[0002] With the gradual promotion of containerization, more and more clusters need to be managed, and how to remotely manage multiple clusters through the same management machine is an urgent problem to be solved.
[0003] Specifically, the current problems are as follows:
[0004] 1. One user can only manage the configuration of one cluster.
[0005] 2. Multiple K8S clusters cannot be remotely managed on the same management machine. SUMMARY
[0006] The main purpose of the present application is to provide a cluster management configuration method and device, computer equipment and a storage medium, which aims to overcome the defect that multiple K8S clusters cannot be remotely managed on the same management machine.
[0007] To achieve the above purpose, the present application provides a cluster management configuration method, comprising the following steps:
[0008] Obtaining the configuration file generated on the master node of each K8S cluster to be managed;
[0009] Creating multiple users, adding each user to a user group, and establishing a corresponding relationship between each K8S cluster and the user;
[0010] According to the corresponding relationship between the K8S cluster and the user, the configuration file generated on each master node is added to the directory of the corresponding user;
[0011] Installing and running a preset tool set, executing a preset management command through the preset tool set, and verifying whether the management operation on the K8S cluster can be remotely executed;
[0012] If it is verified that the management operation on the K8S cluster can be remotely executed, the management configuration of each K8S cluster is successful.
[0013] Further, before the step of obtaining the configuration file generated on the master node of each K8S cluster to be managed, the following steps are included:
[0014] When receiving an instruction of acquiring configuration files generated on master nodes of each K8S cluster to be managed, identification information carried in the instruction is parsed; wherein the identification information includes a plurality of sequentially sorted characters;
[0015] According to a preset database, the plurality of sequentially sorted characters are respectively mapped to corresponding letters to obtain a plurality of sequentially sorted letters; wherein the preset database stores a mapping relationship between different characters and letters, and a plurality of different strings are pre-stored in the preset database;
[0016] It is judged whether the plurality of sequentially sorted letters satisfy a preset sorting rule;
[0017] If the preset sorting rule is satisfied, the plurality of sequentially sorted letters are sequentially spliced according to the sorting to obtain spliced letters;
[0018] Hash calculation is performed on the spliced letters to obtain a corresponding spliced hash value, and it is judged whether there is a string corresponding to the spliced hash value in the preset database;
[0019] If there is a corresponding string, the step of acquiring the configuration files generated on the master nodes of each K8S cluster to be managed is entered.
[0020] Further, the step of judging whether the plurality of sequentially sorted letters satisfy a preset sorting rule further includes:
[0021] If the preset sorting rule is not satisfied, the plurality of sequentially sorted letters are arranged in reverse order to obtain reverse order arranged letters;
[0022] It is judged whether the reverse order arranged letters satisfy a preset sorting rule;
[0023] If the preset sorting rule is satisfied, the reverse order arranged letters are sequentially spliced according to the order to obtain reverse order spliced letters;
[0024] Hash calculation is performed on the reverse order spliced letters to obtain a corresponding reverse order spliced hash value, and it is judged whether there is a string corresponding to the reverse order spliced hash value in the database;
[0025] If there is a corresponding string, the step of acquiring the configuration files generated on the master nodes of each K8S cluster to be managed is entered.
[0026] Further, the step of creating a plurality of users includes:
[0027] The container type of each K8S cluster to be managed is acquired;
[0028] According to the container type, the K8S clusters are correspondingly divided into multiple groups, wherein the container types of the K8S clusters in each group are the same;
[0029] The number of K8S clusters in each group is obtained, and it is respectively judged whether the number is greater than a threshold value;
[0030] If the number is greater than the threshold value, the corresponding group is randomly divided into multiple subgroups, and the number of K8S clusters in each subgroup is less than the threshold value; if the number is not greater than the threshold value, the corresponding group is taken as a target group;
[0031] For each target group or each subgroup, a user is correspondingly created, and a mapping relationship between the user and the corresponding target group or subgroup is established.
[0032] Further, the step of correspondingly creating a user for each target group or each subgroup comprises:
[0033] The container type and the number of K8S clusters included in each target group and each subgroup are obtained;
[0034] For each target group and each subgroup, a string is randomly selected from a preset database; wherein the preset database pre-stores multiple different strings;
[0035] For each target group and each subgroup, the container type and the number of K8S clusters included therein are spliced, and then spliced with the corresponding string to obtain corresponding splicing information;
[0036] The splicing information is subjected to hash calculation to obtain a corresponding hash value, and the hash value is encoded to obtain a corresponding encoding string, which is taken as a user name to create a user.
[0037] Further, after the step of installing and running a preset tool set, and executing a preset management command through the preset tool set to verify whether the management operation on the K8S cluster can be remotely executed, the step further comprises:
[0038] If the management operation on each K8S cluster can be remotely executed, the initial state value of each K8S cluster in each target group is obtained, and the initial state value of each K8S cluster in each subgroup is obtained;
[0039] The initial state values of each K8S cluster in each target group are combined, and the initial state values of each K8S cluster in each subgroup are combined, to obtain a target state value corresponding to each target group or subgroup;
[0040] Hash computing is performed on the target state value corresponding to each target group or sub-group, to obtain a corresponding hash value;
[0041] The hash value is used as the management password of the user corresponding to each target group or sub-group.
[0042] The application further provides a management configuration device for a cluster, comprising:
[0043] A first obtaining unit is configured to obtain configuration files generated on master nodes of each K8S cluster to be managed;
[0044] A creating unit is configured to create a plurality of users, add each user to a user group, and establish a correspondence between each K8S cluster and the user;
[0045] An adding unit is configured to add the configuration file generated on each master node to the directory of the corresponding user according to the correspondence between the K8S cluster and the user;
[0046] An executing unit is configured to install and run a preset tool set, execute a preset management command through the preset tool set, verify whether the management operation on the K8S cluster can be remotely performed, and if the management operation on the K8S cluster can be remotely performed, the management configuration of each K8S cluster is successful.
[0047] The application further provides a computer device comprising a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the method according to any one of the preceding embodiments.
[0048] The application further provides a computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to implement the steps of the method according to any one of the preceding embodiments.
[0049] The management configuration method, device, computer device and storage medium provided by the application can obtain configuration files generated on master nodes of each K8S cluster to be managed when a plurality of K8S clusters need to be managed, create a plurality of users, add each user to a user group, establish a correspondence between each K8S cluster and the user, and add the configuration file generated on the master node of each K8S cluster to the directory of the corresponding user according to the correspondence between the K8S cluster and the user, so that the same management machine can be used to manage a plurality of K8S clusters without frequent login to the K8S cluster, and each K8S cluster can correspond to a user, so that the user can be switched to manage different K8S clusters by switching the user on the management machine. BRIEF DESCRIPTION OF DRAWINGS
[0050] Figure 1 is a management configuration method step schematic diagram of a cluster in an embodiment of the present application;
[0051] Figure 2 is a management configuration device structure block diagram of a cluster in an embodiment of the present application;
[0052] Figure 3 is a structure schematic block diagram of a computer device in an embodiment of the present application.
[0053] The implementation, functional features and advantages of the present application will be further described with reference to the embodiments and the accompanying drawings. DETAILED DESCRIPTION
[0054] In order to make the purpose, technical solutions and advantages of the present application more clear, the present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and not to limit the present application.
[0055] Referring to Figure 1 In an embodiment of the present application, a management configuration method of a cluster is provided, comprising the following steps:
[0056] Step S1, obtaining configuration files generated on master nodes of each K8S cluster to be managed;
[0057] Step S2, creating multiple users, adding each user to a user group, and establishing a corresponding relationship between each K8S cluster and the user;
[0058] Step S3, according to the corresponding relationship between the K8S cluster and the user, adding the configuration file generated on each master node to the directory of the corresponding user;
[0059] Step S4, installing and running a preset tool set, executing a preset management command through the preset tool set to verify whether the management operation on the K8S cluster can be remotely executed, and if the management operation on the K8S cluster can be remotely executed, the management configuration of each K8S cluster is successful.
[0060] In the present embodiment, the above method is applied to remotely manage multiple clusters on the same management machine, wherein the above cluster is a K8S cluster. At present, if a management operation is to be performed on a K8S cluster, it is usually necessary to log in to the master node of the K8S cluster, which not only is cumbersome to operate, but also is easy to cause misoperation on the K8S cluster environment.
[0061] As described in the above step S1, in the present embodiment, the management machine pre-establishes communication connection with each K8S cluster to be managed, thereby realizing remote management of multiple K8S clusters on the same management machine. The K8S cluster includes a master node and a node node. The master node is mainly responsible for the control of the cluster, and mainly implements functions such as scheduling and token management. Therefore, the management of the K8S cluster mainly lies in the management of the master node. Specifically, the management machine obtains the configuration file generated on the master node of each K8S cluster to be managed. The configuration file is automatically generated on the master node of the K8S cluster, and the configuration file is a config configuration file.
[0062] Further, as described in the above step S2, multiple users are created on the management machine, each user is used to manage a different K8S cluster, and each user created is added to a user group.
[0063] As described in the above step S3, in order to directly manage the K8S cluster on the management machine and avoid frequent login to the K8S cluster, the configuration file generated on the master node of the K8S cluster needs to be added to the management machine. Preferably, in order to enable different users to manage different K8S clusters, the configuration file generated on the master node of the K8S cluster is added to the directory corresponding to the user according to the correspondence between the K8S cluster and the user. In the actual process of managing a certain K8S cluster, only the corresponding user needs to be logged in and the kubectl command needs to be executed to manage the corresponding cluster.
[0064] Further, as described in the above step S4, in order to enable the management machine to manage the K8S cluster, a tool set needs to be installed on the management machine. The tool set is used to realize remote management of the K8S cluster. The tool set provides a command set such as kubectl. The command set reads the config configuration file and communicates with the cluster master. The executed command is transmitted to the master for processing. After obtaining the processing result, the processing result is returned and displayed. In order to verify whether the remote management operation of the K8S cluster can be realized after the configuration in the present embodiment, a management command needs to be executed for verification, for example, the kubectl command. If the config configuration file and the cluster master can be read and communicated to realize remote management, it indicates that the management configuration of the K8S cluster is successful.
[0065] In an embodiment, before the step S1 of obtaining the configuration file generated on the master node of each K8S cluster to be managed, the method further includes:
[0066] Step S11, when receiving the instruction of obtaining the configuration file generated on the master node of each K8S cluster to be managed, the identification information carried in the instruction is parsed; wherein the identification information includes a plurality of sequentially sorted characters;
[0067] Step S12, according to the preset database, the plurality of sequentially sorted characters are respectively mapped to corresponding letters to obtain a plurality of sequentially sorted letters; wherein the preset database stores the mapping relationship between different characters and letters, and the preset database also pre-stores a plurality of different strings;
[0068] Step S13, determine whether the plurality of sequentially sorted letters satisfy a preset sorting rule;
[0069] Step S14, if the preset sorting rule is satisfied, the plurality of sequentially sorted letters are concatenated according to the sorting to obtain a concatenated letter.
[0070] Step S15, the concatenated letter is subjected to hash calculation to obtain a corresponding concatenated hash value, and it is determined whether there is a string corresponding to the concatenated hash value in the preset database, if there is a corresponding string, the step of obtaining the configuration file generated on the master node of each K8S cluster to be managed is entered.
[0071] It can be understood that a large amount of information is configured on the K8S cluster, and the management security should be guaranteed when the K8S cluster is managed. Therefore, before obtaining the configuration file generated on the master node of the plurality of K8S clusters to be managed, the instruction of generating the configuration file can be verified. Specifically, the sequentially sorted characters such as 5**-Ag@@ are carried in the above-mentioned instruction, and the sequentially sorted letters obtained by mapping the above-mentioned characters to corresponding letters can be wttzagoo; and then it is determined whether the plurality of sequentially sorted letters satisfy a preset sorting rule, and the above-mentioned sorting rule is pre-configured in the database, which is used to verify the correctness of the sorting of the sequentially sorted letters.
[0072] If the above sorting is correct, the plurality of sequentially sorted letters can be spliced according to the sorting to obtain spliced letters, and a hash value corresponding to the spliced letters is calculated, and it is judged whether there is a string corresponding to the hash value in the database. If there is, it means that the identification information carried in the above acquisition instruction is correct, and can be verified. If not, the identification information is incorrect, and cannot be verified. Specifically, the operation algorithm of the above hash calculation includes a plurality of algorithms, such as md5, sha256, etc. The above hash calculation refers to converting a text or other data into a unique string (i.e. hash value) through an algorithm. The string can be a shorter string, which is used as a text or data expression for simplification. When any position in the above text or data changes, the hash value calculated by the hash calculation will also change. Therefore, the hash value calculated by the hash calculation is unique. In the embodiment, when the plurality of sequentially sorted letters are spliced according to the sorting, the letters can be directly spliced, or other characters (such as “-”) can be used for splicing. After splicing, the hash value is calculated to obtain the above spliced hash value.
[0073] In an embodiment, after the step S13 of judging whether the plurality of sequentially sorted letters meet the preset sorting rule, the method further comprises:
[0074] In step S13a, if the plurality of sequentially sorted letters do not meet the preset sorting rule, the plurality of sequentially sorted letters are arranged in reverse order to obtain reverse order arranged letters.
[0075] In step S14a, it is judged whether the reverse order arranged letters meet the preset sorting rule.
[0076] In step S15a, if the reverse order arranged letters meet the preset sorting rule, the reverse order arranged letters are sequentially spliced according to the order to obtain reverse order spliced letters.
[0077] In step S16a, a hash value corresponding to the reverse order spliced letters is calculated, and it is judged whether there is a string corresponding to the hash value in the database. If there is a corresponding string, the step of obtaining the configuration file generated on the master node of each K8S cluster to be managed is entered.
[0078] The implementation manner in the embodiment is described with reference to the above embodiment, and will not be described here.
[0079] In an embodiment, the step of creating a plurality of users comprises:
[0080] The container type of each K8S cluster to be managed is obtained.
[0081] According to the container type, the K8S clusters are correspondingly divided into multiple groups, wherein the container types of the K8S clusters in each group are the same;
[0082] The number of K8S clusters in each group is obtained, and it is respectively judged whether the number is greater than a threshold value;
[0083] If the number is greater than the threshold value, the corresponding group is randomly divided into multiple subgroups, and the number of K8S clusters in each subgroup is less than the threshold value; if the number is not greater than the threshold value, the corresponding group is taken as a target group;
[0084] For each target group or each subgroup, a user is correspondingly created, and a mapping relationship between the user and the corresponding target group or subgroup is established.
[0085] In the embodiment, when multiple users are created, the number of K8S clusters needs to be considered, each user can manage multiple K8S clusters, but the threshold value (for example, 3) of the number of manageable K8S clusters needs to be set.
[0086] In the embodiment, according to the container type of the K8S cluster, the K8S clusters are correspondingly divided into multiple groups, when the number of K8S clusters in each group is not greater than the threshold value, each user can manage one group, so that the types of the clusters managed by the same user are the same in the subsequent process, which facilitates to reduce the management difficulty and improve the management efficiency. When the number of K8S clusters in a certain group is greater than the threshold value, the group needs to be divided into multiple subgroups, and the number of K8S clusters in each subgroup is less than the threshold value, and each subgroup is managed by one user.
[0087] In an embodiment, the step of correspondingly creating a user for each target group or each subgroup comprises:
[0088] The container type and the number of K8S clusters included in each target group and each subgroup are obtained;
[0089] For each target group and each subgroup, a string is randomly selected from a preset database; wherein the preset database pre-stores multiple different strings;
[0090] For each target group and each subgroup, the container type and the number of K8S clusters included therein are spliced, and then spliced with the corresponding string to obtain corresponding splicing information; a hash value corresponding to the splicing information is obtained by performing hash calculation on the splicing information, an encoding string corresponding to the hash value is obtained by encoding the hash value, and the encoding string is taken as a user name to create a user.
[0091] In the embodiment, a scheme for creating a user name of the user is proposed. When a user is created for each target group and each sub-combination, the container type and the number of clusters of the K8S cluster included in the target group and each sub-combination are obtained, and a user name of the user is obtained by performing a hash calculation based on the information, so that the user name of the user is associated with the corresponding K8S cluster. Further, in order to avoid the consistency of the user name, a random string is added before the hash calculation is performed, so as to ensure the uniqueness of each user name.
[0092] In an embodiment, after the step S4 of installing and running the preset tool set, and executing the preset management command through the preset tool set to verify whether the management operation on the K8S cluster can be remotely performed, the method further includes:
[0093] In step S5, if the management operation on each K8S cluster can be remotely performed, the initial state value of each K8S cluster in each target group is obtained, and the initial state value of each K8S cluster in each sub-combination is obtained.
[0094] In step S6, the initial state value of each K8S cluster in each target group is combined, and the initial state value of each K8S cluster in each sub-combination is combined, to obtain a target state value corresponding to each target group or sub-combination.
[0095] In step S7, the target state value corresponding to each target group or sub-combination is subjected to a hash calculation to obtain a corresponding hash value.
[0096] In step S8, the hash value is used as a management password of a user corresponding to each target group or sub-combination.
[0097] In the embodiment, when each user manages the K8S cluster, in order to avoid confusion and management disorder between users, a management password of the K8S cluster for each user needs to be set.
[0098] Specifically, each of the above users does not set an initial password, and in the initial state, the management of the K8S cluster can be directly performed, at this time, the initial state value of each K8S cluster in each target group is obtained, and the initial state value of each K8S cluster in each sub-combination is obtained, the initial state value of each K8S cluster in the target group and the initial state value of each K8S cluster in each sub-combination are taken as a set alone, and the initial state value in each set is combined to obtain a string of state value information, that is, the above target state value. Because the number and type of K8S clusters in each target group or each sub-combination are different, the initial state values are also different. Therefore, the target state value corresponding to each of the target group or the sub-combination is also different, and the hash calculation of the target state value is also different.
[0099] Finally, the management password of the user corresponding to each of the target group or the sub-combination is set, so that the above different hash values can be directly used as the management password of the user corresponding to each of the target group or the sub-combination, avoiding the use of the same management password by different users, and improving the management security.
[0100] In an embodiment, the cluster management configuration method further includes:
[0101] The configuration file generated on the master node of each K8S cluster to be managed is stored in a blockchain. The blockchain is a new application mode of distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm and other computer technologies. The blockchain is essentially a decentralized database, which is a series of data blocks associated using cryptographic methods, each data block contains information of a batch of network transactions, and is used to verify the validity (anti-fake) of the information and generate the next block. The blockchain can include a blockchain underlying platform, a platform product service layer, and an application service layer.
[0102] Referring to Figure 2 In an embodiment of the present application, a cluster management configuration device is also provided, which includes:
[0103] The first obtaining unit 10 is configured to obtain the configuration file generated on the master node of each K8S cluster to be managed;
[0104] The creating unit 20 is configured to create a plurality of users, add each of the users to a user group, and establish a corresponding relationship between each of the K8S clusters and the users;
[0105] An adding unit 30 is configured to add the configuration file generated on each master node to the directory of the corresponding user according to the correspondence between the K8S cluster and the user.
[0106] An executing unit 40 is configured to install and run a preset tool set, execute a preset management command through the preset tool set, and verify whether the management operation on the K8S cluster can be remotely performed. If the management operation on the K8S cluster can be remotely performed, the management configuration of each K8S cluster is successful.
[0107] In an embodiment, the device further comprises:
[0108] An analyzing unit is configured to analyze identification information carried in an instruction of acquiring the configuration file generated on the master node of each K8S cluster to be managed when the instruction is received. The identification information includes a plurality of sequentially ordered characters.
[0109] A mapping unit is configured to map the plurality of sequentially ordered characters into corresponding letters respectively according to a preset database to obtain a plurality of sequentially ordered letters. The preset database stores a mapping relationship between different characters and letters, and a plurality of different strings are pre-stored in the preset database.
[0110] A first judging unit is configured to judge whether the plurality of sequentially ordered letters satisfy a preset ordering rule.
[0111] A first concatenating unit is configured to concatenate the plurality of sequentially ordered letters according to the ordering sequentially to obtain concatenated letters if the preset ordering rule is satisfied.
[0112] A first calculating unit is configured to perform a hash calculation on the concatenated letters to obtain a corresponding concatenated hash value, judge whether there is a string corresponding to the concatenated hash value in a preset database, and acquire the configuration file generated on the master node of each K8S cluster to be managed if there is the corresponding string.
[0113] In an embodiment, the device further comprises:
[0114] A reverse ordering unit is configured to arrange the plurality of sequentially ordered letters in a reverse order to obtain reverse-ordered letters if the preset ordering rule is not satisfied.
[0115] A second judging unit is configured to judge whether the reverse-ordered letters satisfy a preset ordering rule.
[0116] A second concatenating unit is configured to concatenate the reverse-ordered letters according to the order sequentially to obtain reverse-concatenated letters if the preset ordering rule is satisfied.
[0117] The second computing unit is configured to perform hash calculation on the reverse spliced letters to obtain a corresponding reverse spliced hash value, determine whether a string corresponding to the reverse spliced hash value exists in the database, and if the string exists, execute the obtaining of the configuration file generated on the master node of each K8S cluster to be managed.
[0118] In an embodiment, the creating unit 20 creates a plurality of users, specifically including:
[0119] Obtaining the container type of each K8S cluster to be managed;
[0120] According to the container type, the K8S clusters are divided into a plurality of groups, wherein the container types of the K8S clusters in each group are the same;
[0121] Obtaining the number of K8S clusters in each group and respectively determining whether the number is greater than a threshold value;
[0122] If the number is greater than the threshold value, the corresponding group is randomly divided into a plurality of subgroups, and the number of K8S clusters in each subgroup is less than the threshold value; if the number is not greater than the threshold value, the corresponding group is taken as a target group;
[0123] For each target group or each subgroup, a user is created, and a mapping relationship between the user and the corresponding target group or subgroup is established.
[0124] In an embodiment, the creating unit 20 creates a user for each target group and each subgroup, specifically including:
[0125] Obtaining the container type and the number of K8S clusters included in each target group and each subgroup;
[0126] For each target group and each subgroup, a string is randomly selected from a preset database; wherein the preset database pre-stores a plurality of mutually different strings;
[0127] For each target group and each subgroup, the container type and the number of K8S clusters included therein are spliced, and then spliced with the corresponding string to obtain corresponding splicing information; the splicing information is subjected to hash calculation to obtain a corresponding hash value, the hash value is encoded to obtain a corresponding encoded string, and the encoded string is taken as a user name to create a user.
[0128] In an embodiment, the apparatus further includes:
[0129] The second acquisition unit is configured to acquire initial state values of each K8S cluster in each target group and initial state values of each K8S cluster in each subcombination if the management operation on each K8S cluster can be remotely performed.
[0130] The combination unit is configured to combine the initial state values of each K8S cluster in each target group and combine the initial state values of each K8S cluster in each subcombination, to obtain target state values corresponding to each target group or subcombination.
[0131] The third calculation unit is configured to perform hash calculation on the target state values corresponding to each target group or subcombination, to obtain corresponding hash values.
[0132] The password setting unit is configured to set the hash values as management passwords of users corresponding to each target group or subcombination.
[0133] In the above embodiment, the specific implementation of each unit can refer to the description in the method embodiment, and will not be described here.
[0134] Reference Figure 3 In the embodiment of the present application, a computer device can be a server, and the internal structure thereof can be as shown in Figure 3 The computer device includes a processor, a memory, a network interface and a database connected through a system bus. The processor of the computer device is configured to provide calculation and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operating system and the computer program in the non-volatile storage medium. The database of the computer device is configured to store cluster data and the like. The network interface of the computer device is configured to communicate with an external terminal through a network connection. The computer program is executed by the processor to implement a cluster management configuration method.
[0135] Those skilled in the art can understand that Figure 3 The structure shown in the embodiment of the present application is only a block diagram of part of the structure related to the scheme of the present application, and does not constitute a limitation on the computer device to which the scheme of the present application is applied.
[0136] The embodiment of the present application further provides a computer readable storage medium having a computer program stored thereon. The computer program is executed by the processor to implement a cluster management configuration method. It can be understood that the computer readable storage medium in the embodiment of the present application can be a volatile readable storage medium or a non-volatile readable storage medium.
[0137] In summary, the cluster management configuration method, device, computer device and storage medium provided in the embodiments of the present application can be used to manage multiple K8S clusters. When multiple K8S clusters need to be managed, the configuration file generated on the master node of each K8S cluster to be managed is obtained; multiple users are created, and each user is added to a user group, and a corresponding relationship between each K8S cluster to be managed and the user is established; and the configuration file generated on the master node of each K8S cluster to be managed is added to the directory of the corresponding user. In this way, multiple K8S clusters can be managed on the same management machine without frequent login to the K8S cluster. Meanwhile, each K8S cluster can correspond to a user, so that switching the user on the management machine can switch to manage different K8S clusters.
[0138] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be completed by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer readable storage medium. When the computer program is executed, the processes of the above-mentioned embodiments can be included. Any reference to memory, storage, database or other medium provided in the present application and used in the embodiments can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration but not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (SSRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM) and memory bus dynamic RAM (RDRAM) and the like.
[0139] It should be noted that in this document, the terms "comprising", "including", or any other variant thereof are intended to cover non-exclusive inclusions, so that processes, devices, articles or methods including a series of elements not only include those elements, but also include other elements not explicitly listed, or include elements inherent to such processes, devices, articles or methods. Without more limitations, the element defined by the statement "including a" does not exclude the presence of another identical element in the process, device, article or method including the element.
[0140] The above merely provides the preferred embodiments of the present application, and is not intended to limit the patent scope of the present application. Any equivalent structure or equivalent flowchart transformation based on the content of the present application specification and drawings, or direct or indirect application in other related technical fields, are also included in the patent protection scope of the present application.
Claims
1. A cluster management and configuration method, characterized in that, Includes the following steps: Obtain the configuration files generated on the master nodes of each Kubernetes cluster to be managed; Create multiple users, add each user to a user group, and establish a correspondence between each K8S cluster and the user; Based on the correspondence between the K8S cluster and the user, the configuration files generated on each master node are added to the directory of the corresponding user. Install and run a preset toolset, and execute preset management commands through the preset toolset to verify whether remote management operations on the K8S cluster can be performed; If it is verified that management operations on the K8S cluster can be performed remotely, then the management configuration of each K8S cluster is successful. The steps for creating multiple users include: Get the container type for each Kubernetes cluster to be managed; Based on the container type, the K8S cluster is divided into multiple groups, where the K8S clusters in each group have the same container type. Obtain the number of K8S clusters in each group, and determine whether the number is greater than the threshold. If the number of clusters exceeds the threshold, the corresponding group is randomly divided into multiple subgroups, and the number of K8S clusters in each subgroup is less than the threshold; if the number of clusters does not exceed the threshold, the corresponding group is taken as the target group. For each target group or subgroup, create a corresponding user and establish a mapping relationship between the user and the corresponding target group or subgroup.
2. The cluster management and configuration method according to claim 1, characterized in that, Before the step of obtaining the configuration files generated on the master nodes of each Kubernetes cluster to be managed, the following steps are included: When receiving an instruction to retrieve the configuration files generated on the master nodes of each K8S cluster to be managed, the identifier information carried in the instruction is parsed; wherein, the identifier information includes multiple characters in sequential order; The multiple sequentially ordered characters are mapped to corresponding letters according to a preset database, resulting in multiple sequentially ordered letters; wherein, the preset database stores different character-letter mapping relationships, and the preset database also pre-stores multiple distinct strings; Determine whether the plurality of sequentially ordered letters satisfy a preset sorting rule; If the preset sorting rules are met, the multiple sequentially sorted letters are concatenated according to the sorting order to obtain concatenated letters; Perform a hash calculation on the concatenated letters to obtain the corresponding concatenated hash value, and determine whether a string corresponding to the concatenated hash value exists in the preset database; If the corresponding string exists, proceed to the step of obtaining the configuration files generated on the master nodes of each K8S cluster to be managed.
3. The cluster management and configuration method according to claim 2, characterized in that, After the step of determining whether the plurality of sequentially sorted letters satisfy a preset sorting rule, the method further includes: If the preset sorting rules are not met, the multiple sequentially sorted letters will be reversed to obtain reversed letters. Determine whether the reverse-ordered letters satisfy a preset sorting rule; If the preset sorting rules are met, the reversed letters are concatenated sequentially to obtain reversed concatenated letters. The reversed concatenation of letters is hashed to obtain the corresponding reversed concatenation hash value, and it is determined whether a string corresponding to the reversed concatenation hash value exists in the database; If the corresponding string exists, proceed to the step of obtaining the configuration files generated on the master nodes of each K8S cluster to be managed.
4. The cluster management and configuration method according to claim 1, characterized in that, The step of creating a user for each target group or subgroup includes: Obtain the container type and number of K8S clusters included in each target group and each subgroup; For each target group and each subgroup, a string is randomly selected from a preset database; wherein, the preset database contains multiple distinct strings. For each target group and each subgroup, the container type and number of clusters of the K8S cluster are concatenated and then concatenated with the corresponding string to obtain the corresponding concatenation information; The concatenated information is hashed to obtain a corresponding hash value, the hash value is encoded to obtain a corresponding encoded string, and the encoded string is used as the username to create a user.
5. The cluster management and configuration method according to claim 1, characterized in that, After the steps of installing and running a preset toolset, and executing preset management commands through the preset toolset to verify whether remote management operations on the K8S cluster can be performed, the method further includes: If management operations on each of the K8S clusters can be performed remotely, then the initial state value of each of the K8S clusters in each target group and the initial state value of each of the K8S clusters in each sub-group are obtained. The initial state values of each K8S cluster in each target group are combined, and the initial state values of each K8S cluster in each sub-group are combined to obtain the target state value corresponding to each target group or sub-group. Perform hash calculations on the target state values corresponding to each target group or subgroup to obtain the corresponding hash values; The hash value is used as the management password for the user corresponding to each target group or subgroup.
6. A cluster management and configuration apparatus, used to execute the cluster management and configuration method as described in any one of claims 1-5, characterized in that, include: The first acquisition unit is used to acquire the configuration files generated on the master nodes of each K8S cluster to be managed; A creation unit is used to create multiple users, add each user to a user group, and establish a correspondence between each K8S cluster and the user; The adding unit is used to add the configuration files generated on each of the master nodes to the directory of the corresponding user according to the correspondence between the K8S cluster and the user; The execution unit is used to install and run a preset toolset, and execute preset management commands through the preset toolset to verify whether management operations on the K8S cluster can be performed remotely; If it is verified that management operations on the K8S cluster can be performed remotely, then the management configuration of each K8S cluster is successful.
7. The cluster management and configuration device according to claim 6, characterized in that, The device further includes: The parsing unit is used to parse the identification information carried in the instruction when it receives an instruction to obtain the configuration files generated on the master node of each K8S cluster to be managed; wherein, the identification information includes multiple characters in a sequential order; A mapping unit is used to map the plurality of sequentially ordered characters to corresponding letters according to a preset database, thereby obtaining a plurality of sequentially ordered letters; wherein, the preset database stores different character-letter mapping relationships, and the preset database also pre-stores a plurality of distinct strings; The first judgment unit is used to determine whether the plurality of sequentially sorted letters meet the preset sorting rules; The first splicing unit is used to splice the multiple sequentially sorted letters in the order of the preset sorting rules to obtain spliced letters. The first calculation unit is used to perform hash calculation on the concatenated letters to obtain the corresponding concatenated hash value, determine whether there is a string corresponding to the concatenated hash value in the preset database, and if there is a corresponding string, execute to obtain the configuration file generated on the master node of each K8S cluster to be managed.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 5.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 5.
Citation Information
Patent Citations
K8S cluster user resource calling method, device and equipment and readable medium
CN112468539A
Control processing method and device for multiple sets of clusters and computer equipment
CN112714022A