Code development processing method and device, electronic equipment and storage medium

文档序号:1963456 发布日期:2021-12-14 浏览:24次 中文

阅读说明:本技术 代码开发的处理方法、装置、电子设备与存储介质 (Code development processing method and device, electronic equipment and storage medium ) 是由 张东宇 常金龙 于 2021-09-09 设计创作,主要内容包括:本发明提供了一种代码开发的处理方法、装置、电子设备与存储介质,其中,代码开发的处理方法,包括:判断是否获取到灰度发布指示;若获取到所述灰度发布指示,则;为所创建的目标服务确定灰度发布路由规则;所述灰度发布路由规则定义了能够访问所述目标服务的流量;所述目标服务表征了对应的一个版本的代码集合;基于所述灰度发布路由规则,发布所述目标服务,并使得:满足所述灰度发布路由规则的流量才能访问所述目标服务。(The invention provides a processing method and a processing device for code development, electronic equipment and a storage medium, wherein the processing method for code development comprises the following steps: judging whether a gray scale issuing instruction is acquired; if the gray scale issuing instruction is obtained, then; determining a gray-scale publication routing rule for the created target service; the grey scale publication routing rules define the traffic that can access the target service; the target service represents a corresponding code set of one version; based on the gray-scale publication routing rule, publishing the target service and causing: traffic that satisfies the gray scale publication routing rule can access the target service.)

1. A method for processing code development, comprising:

judging whether a gray scale issuing instruction is acquired;

if the gray scale issuing instruction is obtained, then; determining a gray-scale publication routing rule for the created target service; the grey scale publication routing rules define the traffic that can access the target service; the target service represents a corresponding code set of one version;

based on the gray-scale publication routing rule, publishing the target service and causing: traffic that satisfies the gray scale publication routing rule can access the target service.

2. The method of processing code development according to claim 1,

the determining of the gray-scale publication routing rule for the created target service includes:

generating the gray scale release routing rule and forming a routing resource list describing the gray scale release routing rule;

submitting the routing resource list to an interface service layer of a container arrangement management system to configure a corresponding proxy component to be able to fulfill the gray-scale publication routing rule; wherein traffic is proxied to the service via the proxy component.

3. The method for processing code development according to claim 2, further comprising:

and if the gray scale distribution routing rule is changed, updating the changed routing rule to the proxy component so that the proxy component takes the changed routing rule as a new gray scale distribution routing rule.

4. The method for processing code development according to claim 2, further comprising:

forming a template resource list of the target service;

and submitting the template resource list to an interface service layer of a container arrangement management system to create the target service.

5. The code development processing method according to claim 4, wherein the service name of the target service carries a specific identifier, and the specific identifier characterizes: the target service is a gray scale distribution service with a gray scale distribution routing rule or a stable distribution service without the gray scale distribution routing rule.

6. The method according to any one of claims 2 to 5, wherein the agent component is Sidecar, the container arrangement management system is K8s, and the routing resource list is described in a CRD manner.

7. The code development processing method according to any one of claims 1 to 5, wherein the grayscale release routing rule is a preset default routing rule.

8. The code development processing method according to any one of claims 1 to 5, wherein the gray-scale release routing rule is a request identification-based routing rule; a reference request identifier is defined in the routing rule based on the request identifier;

the target service is published based on the gray-scale publication routing rule, and is caused to: the traffic meeting the gray-scale distribution routing rule can access the target service, and the method comprises the following steps:

acquiring request information sent by a request end; the request information carries a specified request identifier;

and if the specified request identifier is matched with the reference request identifier, routing the traffic of the request end to the target service.

9. The code development processing method according to claim 8, wherein the request information is test request information; after the flow of the request end is routed to the target service, the test of the target service can be executed;

the processing method for code development further comprises the following steps:

and if the target service passes the test, determining that the target service is changed into a stable release service from the gray release service, and replacing the stable release service of the previous version.

10. A processing apparatus for code development, comprising;

the judging module is used for judging whether a gray release instruction is acquired;

a rule determining module, configured to obtain the gray scale release indication; determining a gray-scale publication routing rule for the created target service; the grey scale publication routing rules define the traffic that can access the target service; the target service represents a corresponding code set of one version;

a publishing module configured to publish the target service based on the gray-scale publication routing rule, and enable: traffic that satisfies the gray scale publication routing rule can access the target service.

11. An electronic device, comprising a processor and a memory,

the memory is used for storing codes;

the processor is configured to execute the code in the memory to implement the processing method of any one of claims 1 to 9.

12. A storage medium having stored thereon a computer program which, when executed by a processor, implements the processing method of any one of claims 1 to 9.

Technical Field

The present invention relates to the field of code development, and in particular, to a method and an apparatus for processing code development, an electronic device, and a storage medium.

Background

In the process of code development, deployment and release of a code corresponding service can be realized, wherein the service can be understood as a collection of one version of code.

In the related art, the published service can be routed to all users, so that the service is perceived by all users, however, for the partial version of the service, the service does not need to be routed to all users, and in contrast, if the service is routed to all users, the service may have influence or trouble on the users.

Disclosure of Invention

The invention provides a processing method and device for code development, electronic equipment and a storage medium, and aims to solve the problems in the prior art.

According to a first aspect of the present invention, there is provided a processing method for code development, including:

judging whether a gray scale issuing instruction is acquired;

if the gray scale issuing instruction is obtained, then; determining a gray-scale publication routing rule for the created target service; the grey scale publication routing rules define the traffic that can access the target service; the target service represents a corresponding code set of one version;

based on the gray-scale publication routing rule, publishing the target service and causing: traffic that satisfies the gray scale publication routing rule can access the target service.

Optionally, the determining a gray-scale distribution routing rule for the created target service includes:

generating the gray scale release routing rule and forming a routing resource list describing the gray scale release routing rule;

submitting the routing resource list to an interface service layer of a container arrangement management system to configure a corresponding proxy component to be able to fulfill the gray-scale publication routing rule; wherein traffic is proxied to the service via the proxy component.

Optionally, the processing method for code development further includes:

and if the gray scale distribution routing rule is changed, updating the changed routing rule to the proxy component so that the proxy component takes the changed routing rule as a new gray scale distribution routing rule.

Optionally, the processing method for code development further includes:

forming a template resource list of the target service;

and submitting the template resource list to an interface service layer of a container arrangement management system to create the target service.

Optionally, the service name of the target service carries an assigned identifier, where the assigned identifier represents: the target service is a gray scale distribution service with a gray scale distribution routing rule or a stable distribution service without the gray scale distribution routing rule.

Optionally, the agent component is Sidecar, the container orchestration management system is K8s, and the routing resource list is described in a CRD manner.

Optionally, the grayscale release routing rule is a preset default routing rule.

Optionally, the grayscale release routing rule is a routing rule based on a request identifier; a reference request identifier is defined in the routing rule based on the request identifier;

based on the gray-scale publication routing rule, publishing the target service and causing: the traffic meeting the gray-scale distribution routing rule can access the target service, and the method comprises the following steps:

acquiring request information sent by a request end; the request information carries a specified request identifier;

and if the specified request identifier is matched with the reference request identifier, routing the traffic of the request end to the target service.

Optionally, the request information is test request information; after the flow of the request end is routed to the target service, the test of the target service can be executed;

the processing method for code development further comprises the following steps:

and if the target service passes the test, determining that the target service is changed into a stable release service from the gray release service, and replacing the stable release service of the previous version.

According to a second aspect of the present invention, there is provided a processing apparatus for code operation and maintenance, comprising;

the judging module is used for judging whether a gray release instruction is acquired;

a rule determining module, configured to obtain the gray scale release indication; determining a gray-scale publication routing rule for the created target service; the grey scale publication routing rules define the traffic that can access the target service; the target service represents a corresponding code set of one version;

a publishing module configured to publish the target service based on the gray-scale publication routing rule, and enable: traffic that satisfies the gray scale publication routing rule can access the target service.

According to a third aspect of the invention, there is provided an electronic device comprising a processor and a memory,

the memory is used for storing codes;

the processor is configured to execute the codes in the memory to implement the processing method according to the first aspect and the optional aspects thereof.

According to a fourth aspect of the present invention, there is provided a storage medium having stored thereon a computer program which, when executed by a processor, implements the processing method of the first aspect and its alternatives.

According to the code development processing method and device, the electronic equipment and the storage medium, when the gray scale release instruction is obtained, the exclusive gray scale release routing rule can be determined for the target service, and then when the target service is released, the target service can be accessed only by the flow meeting the gray scale release routing rule. Therefore, the invention avoids all the flow from being routed to the target service, and further, part of the users can be unaware of the part of the service, thereby avoiding the influence or the trouble caused by the part of the service.

Drawings

In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to these drawings without creative efforts.

FIG. 1 is a flow chart of a method for processing code development according to an embodiment of the present invention;

FIG. 2 is a schematic flow chart of another method for processing code development according to an embodiment of the present invention;

FIG. 3 is a schematic flow chart of a processing method for code development according to an embodiment of the present invention;

FIG. 4 is a schematic diagram of a program module of a processing device for code development according to an embodiment of the present invention;

FIG. 5 is a schematic diagram of another program module of a processing device for code development according to an embodiment of the present invention;

fig. 6 is a schematic structural diagram of an electronic device in an embodiment of the invention.

Detailed Description

The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.

The terms "first," "second," "third," "fourth," and the like in the description and in the claims, as well as in the drawings, if any, are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the invention described herein are capable of operation in sequences other than those illustrated or described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.

The technical solution of the present invention will be described in detail below with specific examples. The following several specific embodiments may be combined with each other, and details of the same or similar concepts or processes may not be repeated in some embodiments.

Referring to fig. 1, an embodiment of the present invention provides a method for processing code development, including:

s101: judging whether a gray scale issuing instruction is acquired;

if the determination result in S101 is yes (i.e., if the gray scale distribution instruction is obtained), step S102 may be executed in a subsequent processing procedure (e.g., after the target service deployment is completed): a gray-scale publication routing rule is determined for the created target service.

Further, at the time of distribution, step S103 may be executed: based on the gray-scale publication routing rule, publishing the target service and causing: traffic that satisfies the gray scale publication routing rule can access the target service.

The target service represents a corresponding code set of one version; furthermore, the services to be deployed and released in the embodiments of the present invention may be regarded as representing a code set.

The gray scale release indication can be understood as representing that a user selects a system for incorporating a target service (namely a corresponding code set of one version) to be created into gray scale release, and can also be understood as representing that the user selects a routing rule for determining the gray scale release for the target service; in one example, a selection operation interface may be displayed in an interface of service deployment, and a user may select whether to incorporate a target service to be created into a system of gray-scale publishing, in other examples, the gray-scale publishing indication may also be identified by a user by being marked in a code in advance, or may be automatically obtained according to a preset condition (that is, may not be actively selected by the user).

Wherein the grey scale distribution routing rule defines a flow rate capable of accessing the target service; any defining manner does not depart from the scope of the embodiments of the present invention, for example, traffic of which terminals (terminal, service terminal, user, address) can be directly defined to access the target service, for example, characteristics or conditions of the terminals can also be defined, and for example, whether the terminals are accessible or not can be determined based on the request identifier.

In specific examples:

the grey scale publication routing rule may be, for example, a preset default routing rule, which may be understood as: wherein it is predefined which end or ends of traffic can access the target service;

the gray-scale distribution routing rule may also be, for example, a routing rule based on a request identifier, and when the routing rule is adopted, whether one end (which may be understood as a request end) can access a target service depends on whether a specified request identifier in request information sent by the end meets requirements (i.e., whether the specified request identifier matches a reference request identifier); correspondingly, the routing rule based on the request identifier can define a reference request identifier;

further, the grayscale release routing rule may also be, for example, a grayscale release routing rule specified by a user when the target service is deployed.

In the above scheme, when the gray scale distribution instruction is obtained, a dedicated gray scale distribution routing rule may be determined for the target service, and then, when the target service is distributed, the target service may be accessed only by the traffic meeting the gray scale distribution routing rule. Therefore, the invention avoids all the flow from being routed to the target service, and further, part of the users can be unaware of the part of the service, thereby avoiding the influence or the trouble caused by the part of the service.

In one embodiment, referring to fig. 2, before step S102, the method may include:

s104: forming a template resource list of the target service;

s105: and submitting the template resource list to an interface service layer of a container arrangement management system to create the target service.

In a specific embodiment, the container arrangement management system may be K8s, and correspondingly, the interface service layer is K8s api server, and correspondingly, the agent component may be, for example, Sidecar.

Further, one process of steps S104, S105 may be, for example:

in step S104, rendering a resource list of a corresponding service to a standard output based on the template command of the palm, then capturing the standard output, submitting the standard output to an idioctl in a pipeline form, and rendering the standard output by using a kube-inject command of the idioctl to generate a template resource list, wherein the template resource list can have a corresponding proxy component (i.e., Sidecar); then, in step S105, the template resource list may be submitted to the API corresponding to the K8S API server by way of a POST request, so as to create a corresponding target service, where the target service has a proxy component (i.e. Sidecar), and all traffic is proxied to the service through the proxy component (i.e. Sidecar).

In one embodiment, the service name of the target service carries a specific identifier, where the specific identifier represents: the target service is a gray scale distribution service with a gray scale distribution routing rule or a stable distribution service without the gray scale distribution routing rule. Further, another process of steps S104, S105 may be, for example:

in step S104, the helm-based template command is rendered into a resource file (also understood as a resource manifest) of the corresponding service to a standard output, then after capturing the standard output, submitting the standard output to an idioctl in a pipeline form, rendering by using a kube-inject command of the idioctl, generating a template resource list, the template resource inventory may have a corresponding proxy component (i.e., Sidecar), but it is noted that the service name deployed here contains a specified identifier (e.g., a gray key) that characterizes the target service as a gray release service, for distinguishing the gray release service from the stable release service, and then, in step S105, these template resource manifests may be submitted to the API corresponding to K8S APIServer by way of POST request, so as to create the corresponding target service, the target service is associated with a proxy component (i.e., Sidecar), and all traffic is proxied to the service via the proxy component (i.e., Sidecar).

Wherein:

k8s APIServer, can be understood as: API entry (i.e., interface service layer of K8 s) of the container orchestration management system K8 s.

Helm, can be understood as: k8s resource packet manager.

Template, can be understood as: helm's subcommand for template rendering.

Sidecar, can be understood as: a proxy (i.e., a proxy component) that services the data plane in the grid.

Istioctl, can be understood as: the services grid control plane command line management tool.

kube-inject, which can be understood as: and the subcommand of the istioctl is used for rendering the resource list when the service gray is issued.

In one embodiment, referring to fig. 2, step S102 may include:

s1021: generating the gray scale release routing rule and forming a routing resource list describing the gray scale release routing rule;

s1023: submitting the routing resource list to an interface service layer of a container arrangement management system to configure a corresponding proxy component to be able to fulfill the gray-scale publication routing rule; wherein traffic is proxied to the service via the proxy component.

The above process may occur after the target application deployment is completed, the generated grayscale routing rule may be a default routing rule, for example, the default routing rule may be generated when the corresponding service first accesses the grid, or the generated grayscale routing rule may be a routing rule based on the request identifier, for example, the routing rule based on the request identifier may be generated when the corresponding service does not first access the grid. Other routing rules may be generated, for example.

For the default routing rule, in a specific example, in step S1021, a routing resource list of the corresponding default routing rule may be generated based on the template command of the helm, where the routing resource list may be described in the form of CRD, and then, in step S1022, the routing resource list may be submitted to the API corresponding to K8S API in the form of POST request.

For the routing rule based on the request identifier, in a specific example, in step S1021, the routing rule based on the request identifier (e.g., Header information) mode may be implemented by modifying the corresponding configuration, the gray-scale distribution routing rule may also be generated by rendering a template command based on the palm, and then, in step S1022, the routing resource list may be submitted to the API corresponding to the K8S API in the POST request mode.

Wherein:

CRD, which is understood to be: custom Resources (Custom Resources Definition) for resource extension of K8 s;

header, can be understood as: header information is one of the request identifiers mentioned above, based on the header of the HTTP protocol communication.

In one embodiment, the processing method for code development further includes:

and if the gray scale distribution routing rule is changed, updating the changed routing rule to the proxy component so that the proxy component takes the changed routing rule as a new gray scale distribution routing rule.

The above process can be implemented at any time after the grayscale publication routing rule is generated. Through the process, the change of the content of the gray scale distribution routing rule can be realized, and various changeable and diverse requirements of users and services are met.

In a specific example, the above process may specifically be, for example:

the control plane of the service grid monitors CRD change of related routing resources (namely routing resources in the routing resource list) on the K8s APIServer all the time, and once the change is found, the changed CRD resources (namely changed routing resources which describe changed routing rules) are converted into configuration files which can be identified by the Sidecar, and are issued to the Sidecar through the ADS type API based on the gRPC protocol, and then the Sidecar is dynamically loaded, configured and validated, and further, the proxy component (namely the Sidecar) can issue the routing rules as new gray scale with the changed routing rules.

Wherein:

the gRPC, which is understood to be a protocol for inter-service communication, operates based on HTTP 2.

ADS, is understood to be an API of the aggregation type used by the control plane.

In one embodiment, referring to fig. 3, step S103 may include;

s1031: acquiring request information sent by a request end; the request information carries a specified request identifier;

s1032: whether the specified request identification matches the reference request identification;

if the determination result in step S1032 is yes (i.e. the specified request identifier matches the reference request identifier), step S1033 may be executed: and routing the traffic of the request end to the target service.

The request identifier (i.e., the reference request identifier and the specific request identifier) may be any information that can be written in the request information or defined in the gray-scale distribution routing rule, and in an example, Header information (i.e., Header information) of the communication protocol may be used as the request identifier.

The requesting end may refer to any address, terminal, or user, and as long as it can send the request information, the scope of the embodiments of the present invention is not deviated. In one example, the requestor may be, for example, a user of a QA team.

In a further aspect, the request information is test request information (i.e. information requesting to test the target service); after the flow of the request end is routed to the target service, the test of the target service can be executed;

the processing method for code development further comprises the following steps:

s109: whether the target service is tested to pass;

if so (i.e., the test passes), step S110 may be implemented: and determining that the target service is changed into a stable release service from the gray release service, and replacing the stable release service of the previous version.

In a specific example, the processes of steps S109 and S110 may include, for example:

the QA team will perform a test of a target service (i.e. a gray release service) based on a routing rule in a request identifier (i.e. header information) manner, where each request information will include gray header information (i.e. reference request identifier) configured in the gray release routing rule, the Sidecar captures the corresponding request information and then performs an analysis, and if the header (i.e. header) of the request information includes the corresponding gray header information (i.e. reference request identifier), that is: the header of the request message contains the gray header information, that is: the information (namely the appointed request identification) of the request information head is matched with the gray-scale header information (namely the reference request identification), and the request information head is routed to the current service serving as the gray-scale publishing service, so that the normal flow is not affected, and the gray-scale publishing capability is realized under the condition that the normal user request is not interfered by the production environment. If the QA team tests pass, in step S110, the gray release service will be replaced to overlay the existing stable release service. If not, the program is updated, and the gray scale distribution service is released again.

In addition to the above description, if the determination result of step S101 is no, then: if the gray release instruction is not acquired, then: the subsequent processing can be processed by referring to the service deployment and release mode which is already or improved in the field.

In a specific example, if the gray scale issue indication is not obtained, the following process may be implemented:

the template command based on the palm is used for rendering a resource list of the corresponding service to a standard output, then the standard output is captured and directly submitted to an API corresponding to K8s APIServer in a POST request mode, and the K8s creates the corresponding service (which can also be understood as creating the corresponding resource) based on the submitted list.

Referring to fig. 4, an embodiment of the present invention further provides a processing apparatus 2 for code development, including;

a judging module 201, configured to judge whether a gray release instruction is obtained;

a rule determining module 202, configured to obtain the gray scale issuing instruction if the gray scale issuing instruction is obtained; determining a gray-scale publication routing rule for the created target service; the grey scale publication routing rules define the traffic that can access the target service; the target service represents a corresponding code set of one version;

a publishing module 203, configured to publish the target service based on the gray-scale publishing routing rule, and enable: traffic that satisfies the gray scale publication routing rule can access the target service.

Optionally, the rule determining module 202 is specifically configured to:

generating the gray scale release routing rule and forming a routing resource list describing the gray scale release routing rule;

submitting the routing resource list to an interface service layer of a container arrangement management system to configure a corresponding proxy component to be able to fulfill the gray-scale publication routing rule; wherein traffic is proxied to the service via the proxy component.

Optionally, referring to fig. 5, the processing apparatus 2 for code development further includes:

a rule changing module 207, configured to update the changed routing rule to the proxy component so that the proxy component uses the changed routing rule as a new gray-scale distribution routing rule when the gray-scale distribution routing rule is changed.

Optionally, referring to fig. 5, the processing apparatus 2 for code development further includes:

a template forming module 204, configured to form a template resource list of the target service;

a service creation module 205, configured to submit the template resource list to an interface service layer of a container arrangement management system to create the target service.

Optionally, the service name of the target service carries an assigned identifier, where the assigned identifier represents: the target service is a gray scale distribution service with a gray scale distribution routing rule or a stable distribution service without the gray scale distribution routing rule.

Optionally, the agent component is Sidecar, the container orchestration management system is K8s, and the routing resource list is described in a CRD manner.

Optionally, the grayscale release routing rule is a preset default routing rule.

Optionally, the grayscale release routing rule is a routing rule based on a request identifier; a reference request identifier is defined in the routing rule based on the request identifier;

the issuing module 203 is specifically configured to:

acquiring request information sent by a request end; the request information carries a specified request identifier;

and if the specified request identifier is matched with the reference request identifier, routing the traffic of the request end to the target service.

Optionally, the request information is test request information; after the flow of the request end is routed to the target service, the test of the target service can be executed;

referring to fig. 5, the processing apparatus 2 for code development further includes:

a changing module 206, configured to determine that the target service is changed from a grayscale release service to a stable release service if the target service passes the test, and replace the stable release service of the previous version.

Referring to fig. 6, an electronic device 30 is provided, which includes:

a processor 31; and the number of the first and second groups,

a memory 32 for storing executable instructions of the processor;

wherein the processor 31 is configured to perform the above-mentioned method via execution of the executable instructions.

The processor 31 is capable of communicating with the memory 32 via a bus 33.

Embodiments of the present invention also provide a computer-readable storage medium, on which a computer program is stored, which when executed by a processor implements the above-mentioned method.

Those of ordinary skill in the art will understand that: all or a portion of the steps of implementing the above-described method embodiments may be performed by hardware associated with program instructions. The program may be stored in a computer-readable storage medium. When executed, the program performs steps comprising the method embodiments described above; and the aforementioned storage medium includes: various media that can store program codes, such as ROM, RAM, magnetic or optical disks.

Finally, it should be noted that: the above embodiments are only used to illustrate the technical solution of the present invention, and not to limit the same; while the invention has been described in detail and with reference to the foregoing embodiments, it will be understood by those skilled in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some or all of the technical features may be equivalently replaced; and the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present invention.

14页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:商业智能仪表盘生成方法、装置、电子设备及存储介质

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!