Disclosure of Invention
In order to solve the problems in the prior art, embodiments of the present invention provide a service access management method and system in a container cloud environment. The technical scheme is as follows:
in one aspect, an embodiment of the present invention provides a service access management method in a container cloud environment, where the method includes:
acquiring a service mirror image required by service instance operation;
defining corresponding specification and service configuration information for the service instance;
compiling and uploading a yaml file containing required container resources, wherein the container resources are used for constructing a service instance of a kubernets platform;
converting the uploaded yaml file into a container resource which can be managed by a kubernetes container cloud platform by using a freemarker template engine;
constructing a required service instance by using the converted container resources, and defining a user access entrance for the constructed service instance;
and detecting the constructed service instance, and issuing a corresponding service instance on a kubernets container cloud platform after the detection is passed.
In the above service access management method according to the embodiment of the present invention, the obtaining a service image required by service instance operation includes:
the required service image is downloaded from the official website,
alternatively, the desired service image is re-prepared based on the existing base image.
In the above service access management method according to the embodiment of the present invention, the writing of the yaml file including the required container resource includes:
the yaml file is directly written according to the yaml file format,
or filling the information of the container resource in a preset yaml file editing interface to form a corresponding yaml file.
In the foregoing service access management method according to the embodiment of the present invention, when defining a user access entry for a constructed service instance, the method further includes:
and associating other services on which the constructed service instance runs for the constructed service instance.
In the foregoing service access management method according to the embodiment of the present invention, before the kubernets container cloud platform issues the corresponding service instance, the method further includes:
defining corresponding service basic information for a service instance, wherein the service basic information comprises: at least one of name, version, icon, description information of the service.
In another aspect, an embodiment of the present invention provides a service access management system in a container cloud environment, including:
the acquisition module is used for acquiring a service mirror image required by service instance operation;
the definition module is used for defining corresponding specification and service configuration information for the service instance;
the processing module is used for compiling and uploading a yaml file containing required container resources, and the container resources are used for constructing a service instance of the kubernets platform;
the processing module is also used for converting the uploaded yaml file into a container resource which can be managed by a kubernets container cloud platform by using a freemarker template engine;
the building module is used for building a required service instance by utilizing the converted container resources and defining a user access entrance for the built service instance;
the processing module is further used for detecting the constructed service instance and issuing the corresponding service instance on the kubernets container cloud platform after the detection is passed.
In the service access management system according to the above-mentioned embodiment of the present invention, the obtaining module is further configured to download a required service image from an official website,
alternatively, the desired service image is re-prepared based on the existing base image.
In the service access management system according to the above embodiment of the present invention, the processing module is further configured to write a yaml file directly according to a yaml file format,
or filling the information of the container resource in a preset yaml file editing interface to form a corresponding yaml file.
In the service access management system according to the embodiment of the present invention, when defining the user access entry for the constructed service instance, the processing module is further configured to associate, for the constructed service instance, another service on which the operation depends.
In the service access management system according to the embodiment of the present invention, before the cloud platform of the kubernets container issues the corresponding service instance, the definition module is further configured to define corresponding service basic information for the service instance, where the service basic information includes: at least one of name, version, icon, description information of the service.
The technical scheme provided by the embodiment of the invention has the following beneficial effects:
the embodiment of the invention provides a convenient access method for accessing the service of the cloud management platform by utilizing the kubernets container arrangement technology, can meet the increasing service access requirements of the cloud management platform, does not need to be redeveloped when accessing a new service, and only needs to make a service mirror image and define a kubernets yaml resource file. The cloud management platform supports the user-defined resource specification and the user-defined service access mode, can effectively improve the service access efficiency, and has the capability of rapidly releasing new services.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, embodiments of the present invention will be described in detail with reference to the accompanying drawings.
Example one
The embodiment of the invention provides a service access management method in a container cloud environment, which is suitable for a Kubernets container cloud platform, and referring to fig. 1, the method can comprise the following steps:
step S11, obtain the service image required by the service instance running.
In this embodiment, one service instance is a set of a plurality of resource objects, and adding a service instance in the container cloud platform enables new services to be accessed for the container cloud platform. Service instances are operated in a kubernets container cluster, and the operation of the container needs to depend on images, so that corresponding service images need to be constructed firstly. Among them, Kubernetes is an open source platform for automated container operations including deployment, scheduling, and inter-node cluster extension.
Specifically, the step S11 can be implemented as follows:
the required service image is downloaded from an official website or is prepared anew based on an existing base image.
In this embodiment, the image may be downloaded from an official party, or may be completely reproduced based on the basic image, and the container runtime may receive environment variables transmitted by kubernets, so that it is necessary to consider which environment variables need to be transferred when the image is generated, and the container replaces configuration items of the service through shell scripts before starting. After the mirror image is manufactured, the mirror image needs to be pushed to a mirror image warehouse associated with the kubernetes cluster, so that the mirror image can be normally pulled when the service instance is started. Fig. 2 is an illustration of a redis service instance as an example, and a redis mirror is created and pushed to a mirror repository in fig. 2.
Step S12, defining corresponding specification and service configuration information for the service instance;
in this embodiment, each service uses different CPUs, memories and storages, and multiple resource specifications can be flexibly formulated according to service and service usage scenarios, so that different selection spaces are provided for users. The specifications of the service instance such as CPU, memory, storage specification and the like and the service configuration information (such as the example of FIG. 3) can be flexibly customized to meet the requirements of users to the maximum extent. The fields to be displayed during user application and activation, the regular expressions, default values and verification specifications of the fields can be configured in service instance configuration, and the field configuration information can be transmitted to a freemarker template engine during service application or starting, and then the freemarker template engine analyzes and transmits the information to a container.
Step S13, compiling and uploading a yaml file containing the required container resources, wherein the container resources are used for constructing the service instance of the kubernets platform.
In this embodiment, yaml is a language that is used exclusively for writing configuration files, and is very compact and powerful, far more convenient than the json format. All resources managed by kubernets can be called resource objects, kubernets support the creation of resource objects (pod, deployment, replicationController, etc.) using yaml files, and a service instance is a collection of resource objects. The creation of a service instance is to convert the yaml file into a kubernets manageable resource object. In practical application, one yaml can be written for each kubernets resource type, and all resource types can also be written in one yaml file. The changed content in the Yaml file is replaced by a placeholder, and when the service is created, the freemarker template engine automatically replaces the placeholder with real data of an instance.
Specifically, the step S13 can be implemented as follows:
the yaml file is written directly in the yaml file format (see the example of figure 4),
or filling in the information of the container resource in a preset yaml file editing interface to form a corresponding yaml file (see the example of fig. 5).
In this embodiment, the tenant may implement access to the service through the system access interface, and for the operation administrator, may write a kubernets yaml resource file to implement fast access to the service. Because the display modes and the capabilities of different access means are different, support for different access modes is provided, and good use effect of various access modes can be ensured.
And step S14, converting the uploaded yaml file into a container resource which can be managed by a kubernets container cloud platform by using a freemarker template engine.
In the embodiment, a yaml file editing service component is used, and a freemarker template engine is combined to dynamically modify the yaml resource file, so that service instances meeting different requirements are created. Fig. 6 is an example of uploading a yaml file.
And step S15, constructing the required service instance by using the converted container resource, and defining a user access entry for the constructed service instance.
In this embodiment, the access portal, that is, the portal ultimately provided for the user to access, supports different protocols (http, tcp, udp), and fig. 7 is a defined example of the service instance user access portal.
Step S16, associate the constructed service instance with other services on which it operates.
In this embodiment, other services dependent on the services may be defined when the services are accessed, the dependencies between the services are decoupled, that is, the service dependencies may associate the services dependent on each other, for example, when a kafka cluster is accessed, a zookeeper cluster needs to be accessed at the same time, and at this time, the zookeeper cluster may be accessed first, and only the zookeeper cluster needs to be selected when the kafka cluster is accessed. It should be noted that not every service instance needs to depend on other services, and therefore, step S16 may be selected for use according to a specific service instance, which is not limited herein (for example, the redis service instance does not depend on other services, so it is not filled).
Step S17, defining corresponding service basic information for the service instance, where the service basic information includes: at least one of name, version, icon, description information of the service.
In this embodiment, the service basic information may include information such as name, version, icon, and description of the service, which is displayed on the service list interface, so that the user can roughly know about the service (for example, the example shown in fig. 8). When the service is created, the corresponding access service is selected, the product name, the product catalog, the icon and the remark information of the service are defined, and the icon which is accessed by the service is selected by default and can be modified.
And step S18, detecting the constructed service instance, and issuing a corresponding service instance on the kubernets container cloud platform after the detection is passed.
In this embodiment, the service can be created after the information filled in the above steps is stored, and the service access personnel and the tester can perform the function test first to verify whether the mirror image, configuration and yaml files have problems, and the current service can be issued after the verification is passed. It should be noted that when the component has a new characteristic, the service component can be upgraded without affecting the operation of the original service instance, the new service instance has a new characteristic, and the two version instances can operate simultaneously.
FIG. 9 shows that the service instance (redis service) is tested and then released on the platform for the user to apply. FIG. 10 is a user applying for a redis service, including filling in instance names, selecting a deployment mode, selecting an instance specification, and selecting a storage size. In fig. 11, the system provides an access address after the service instance (redis service) is activated, and the application program can access the service instance through the access address, namely, the user can use the service instance.
The embodiment of the invention provides a convenient access method for accessing the service of the cloud management platform by utilizing the kubernets container arrangement technology, can meet the increasing service access requirements of the cloud management platform, does not need to be redeveloped when accessing a new service, and only needs to make a service mirror image and define a kubernets yaml resource file. The cloud management platform supports the user-defined resource specification and the user-defined service access mode, can effectively improve the service access efficiency, and has the capability of rapidly releasing new services.
Example two
The embodiment of the invention provides a device. The service access management system in the container cloud environment performs the method described in the first embodiment, referring to fig. 12, and the system may include: an acquisition module 100, a definition module 200, a processing module 300, and a construction module 400.
The obtaining module 100 is configured to obtain a service image required by service instance operation.
In this embodiment, one service instance is a set of a plurality of resource objects, and adding a service instance in the container cloud platform enables new services to be accessed for the container cloud platform. Service instances are operated in a kubernets container cluster, and the operation of the container needs to depend on images, so that corresponding service images need to be constructed firstly. Among them, Kubernetes is an open source platform for automated container operations including deployment, scheduling, and inter-node cluster extension.
The definition module 200 is configured to define corresponding specification and service configuration information for the service instance.
In this embodiment, each service uses different CPUs, memories and storages, and multiple resource specifications can be flexibly formulated according to service and service usage scenarios, so that different selection spaces are provided for users. The specifications of the service instance such as CPU, memory, storage specification and the like and the service configuration information (such as the example of FIG. 3) can be flexibly customized to meet the requirements of users to the maximum extent. The fields to be displayed during user application and activation, the regular expressions, default values and verification specifications of the fields can be configured in service instance configuration, and the field configuration information can be transmitted to a freemarker template engine during service application or starting, and then the freemarker template engine analyzes and transmits the information to a container.
And the processing module 300 is used for compiling and uploading a yaml file containing the required container resources, and the container resources are used for constructing the service instance of the kubernets platform.
In this embodiment, yaml is a language that is used exclusively for writing configuration files, and is very compact and powerful, far more convenient than the json format. All resources managed by kubernets can be called resource objects, kubernets support the creation of resource objects (pod, deployment, replicationController, etc.) using yaml files, and a service instance is a collection of resource objects. The creation of a service instance is to convert the yaml file into a kubernets manageable resource object. In practical application, one yaml can be written for each kubernets resource type, and all resource types can also be written in one yaml file. The changed content in the Yaml file is replaced by a placeholder, and when the service is created, the freemarker template engine automatically replaces the placeholder with real data of an instance.
The processing module 300 is further configured to convert the uploaded yaml file into a container resource manageable by a kubernets container cloud platform by using a freemarker template engine.
In the embodiment, a yaml file editing service component is used, and a freemarker template engine is combined to dynamically modify the yaml resource file, so that service instances meeting different requirements are created.
And the building module 400 is used for building the required service instance by using the converted container resource and defining a user access entrance for the built service instance.
In this embodiment, the access portal, i.e. the portal ultimately provided for user access, supports different protocols (http, tcp, udp).
The processing module 300 is further configured to detect the constructed service instance, and publish the corresponding service instance on the kubernets container cloud platform after the detection is passed.
In this embodiment, the service can be created after the information filled in the above steps is stored, and the service access personnel and the tester can perform the function test first to verify whether the mirror image, configuration and yaml files have problems, and the current service can be issued after the verification is passed. It should be noted that when the component has a new characteristic, the service component can be upgraded without affecting the operation of the original service instance, the new service instance has a new characteristic, and the two version instances can operate simultaneously.
In particular, the acquisition module 100, is also used to download the required service image from the official website,
alternatively, the desired service image is re-prepared based on the existing base image.
In this embodiment, the image may be downloaded from an official party, or may be completely reproduced based on the basic image, and the container runtime may receive environment variables transmitted by kubernets, so that it is necessary to consider which environment variables need to be transferred when the image is generated, and the container replaces configuration items of the service through shell scripts before starting. After the mirror image is manufactured, the mirror image needs to be pushed to a mirror image warehouse associated with the kubernetes cluster, so that the mirror image can be normally pulled when the service instance is started.
In particular, the processing module 300, is further configured to write the yaml file directly in the yaml file format,
or filling the information of the container resource in a preset yaml file editing interface to form a corresponding yaml file.
In this embodiment, the tenant may implement access to the service through the system access interface, and for the operation administrator, may write a kubernets yaml resource file to implement fast access to the service. Because the display modes and the capabilities of different access means are different, support for different access modes is provided, and good use effect of various access modes can be ensured.
Optionally, when defining a user access entry for the constructed service instance, the processing module 300 is further configured to associate, for the constructed service instance, other services on which the constructed service instance depends.
In this embodiment, other services dependent on the services may be defined when the services are accessed, the dependencies between the services are decoupled, that is, the service dependencies may associate the services dependent on each other, for example, when a kafka cluster is accessed, a zookeeper cluster needs to be accessed at the same time, and at this time, the zookeeper cluster may be accessed first, and only the zookeeper cluster needs to be selected when the kafka cluster is accessed.
Optionally, before the cloud platform of the kubernets container publishes the corresponding service instance, the defining module 200 is further configured to define corresponding service basic information for the service instance, where the service basic information includes: at least one of name, version, icon, description information of the service.
In this embodiment, the service basic information may include information such as name, version, icon, and description of the service, which is displayed on the service list interface, so that the user can roughly know about the service. When the service is created, the corresponding access service is selected, the product name, the product catalog, the icon and the remark information of the service are defined, and the icon which is accessed by the service is selected by default and can be modified.
The embodiment of the invention provides a convenient access method for accessing the service of the cloud management platform by utilizing the kubernets container arrangement technology, can meet the increasing service access requirements of the cloud management platform, does not need to be redeveloped when accessing a new service, and only needs to make a service mirror image and define a kubernets yaml resource file. The cloud management platform supports the user-defined resource specification and the user-defined service access mode, can effectively improve the service access efficiency, and has the capability of rapidly releasing new services.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
It should be noted that: in the service access management system in the container cloud environment provided in the foregoing embodiment, when the service access management method in the container cloud environment is implemented, only the division of the functional modules is illustrated, and in practical applications, the function distribution may be completed by different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules, so as to complete all or part of the functions described above. In addition, the service access management system in the container cloud environment and the service access management method in the container cloud environment provided by the above embodiments belong to the same concept, and specific implementation processes thereof are detailed in the method embodiments and are not described herein again.
It will be understood by those skilled in the art that all or part of the steps for implementing the above embodiments may be implemented by hardware, or may be implemented by a program instructing relevant hardware, where the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a magnetic disk or an optical disk, etc.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents, improvements and the like that fall within the spirit and principle of the present invention are intended to be included therein.