A simple deployment method for K8s resources

By creating CRDs and using Kubebuilder tools, the creation and management of K8s resources are automatically completed, and the complexity of K8s resource deployment in the existing technology is solved, and simple deployment and efficient operation and maintenance are achieved.

CN118860424BActive Publication Date: 2025-02-28SHANDONG INSPUR SCI RES INST CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411346785.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-26
Publication Date
2025-02-28
Estimated Expiration
2044-09-26

AI Technical Summary

Technical Problem

In the prior art, the deployment of K8s resources is complex, and users need to manually write multiple YAML files, which leads to cumbersome deployment and error-prone, increasing the deployment complexity and possibility of errors.

Method used

By creating CRDs, the creation of K8s resources is automatically completed, including automated management of resources such as Deployment, Service, VirtualService and Ingress, and the deployment process is simplified by using Kubebuilder and Make tools.

Benefits of technology

It realizes simple deployment of K8s resources, reduces the need to manually write configuration files, reduces the possibility of deployment errors, improves operation and maintenance efficiency, and supports automated creation and management of K8s resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 00000000_0000_ABST
    Figure 00000000_0000_ABST
Patent Text Reader

Abstract

The present invention discloses a simple deployment method of K8s resources, which relates to the technical field of resource deployment, including: installing and configuring Golang and Make tools, selecting and decompressing Kubebuilder to a specified directory; creating a project and initializing Kubebuilder, defining AutoDeploySpec and AutoDeploy structures; implementing the Reconcile method to coordinate K8s resources; querying CRD objects, creating or updating K8s resources and updating status; configuring SetupWithManager to register a controller and listen to AutoDeploy resources; generating a CRD resource list and applying it to a cluster; building a Docker image and deploying it to a K8s cluster to achieve automatic resource management. The present invention can achieve automatic creation and management of K8s resources.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of resource deployment, and in particular to a simple deployment method for K8s resources. Background Art

[0002] Kubernetes (K8s) is an open source platform for automating the deployment, expansion, and management of containerized applications. K8s provides a variety of resource objects, such as Deployment, Service, VirtualService, and Ingress, for managing the lifecycle of containerized applications. However, in actual applications, users often need to manually write multiple YAML files to define and create these resource objects, which is cumbersome and error-prone.

[0003] CRD (Custom Resource Definition) is an extension mechanism in Kubernetes. It allows users to define their own resource types that do not exist in the Kubernetes API server, but users can use them just like built-in resources (such as Pod, Service, etc.). CRD enables Kubernetes to support more application scenarios and requirements.

[0004] In the traditional method, developers need to write multiple resource definition files for each application and apply these files separately to complete the deployment of the application. This method requires users to have an in-depth understanding of K8s resources and have certain configuration management capabilities, which increases the complexity of deployment and the possibility of errors. Kubernetes provides a powerful container orchestration function, allowing users to define and manage application resources through YAML or JSON configuration files. However, as the scale of applications expands, the number of Kubernetes resources required also increases dramatically, resulting in numerous configuration files and difficult management. At the same time, due to the complex dependencies between resources, omissions or errors are prone to occur during manual deployment, increasing maintenance costs and deployment risks. Therefore, it is of great significance to propose a method and device that can simplify K8s resource deployment. Summary of the invention

[0005] In order to solve the deployment complexity problem existing in the prior art, the present invention provides a simple deployment method for K8s resources.

[0006] The present invention provides a simple deployment method for K8s resources, and the technical solution adopted to solve the above technical problems is as follows:

[0007] A simple deployment method for K8s resources. This method automatically completes the creation of K8s resources by creating CRD. The method specifically includes the following operations:

[0008] S1. Install and configure the Golang environment and the Make tool under Linux, then select the Kubebuilder version according to the operating system version and CPU architecture, and download and decompress it to the specified directory;

[0009] S2. Create a project directory and initialize the Kubebuilder project; create an AutoDeploySpec structure to represent the definition information required when creating the autodeploy CRD; assemble the AutoDeploy structure to describe the data structure of the autodeploy CRD;

[0010] S3. Implement the Reconcile method to coordinate various resources in k8s to achieve the desired state of the system;

[0011] S4. Check whether the CRD object exists, create or update the relevant K8s resources, and update the CRD resource status according to the deployment status;

[0012] S5. Configure the SetupWithManager method to register the controller with the Manager and set the monitoring of the AutoDeploy resource to trigger the implementation logic of the Reconcile method.

[0013] S6. Execute the make manifests command in the project directory to generate a resource list for autodeployCRD, and use the k8s client to apply the generated CRD resource list to the k8s cluster;

[0014] S7. Build a Docker image and deploy it to the k8s cluster to ultimately achieve the function of automatic resource management.

[0015] Optionally, execute step S2 to create a project directory and initialize the Kubebuilder project. The specific process is as follows:

[0016] S2.1.1. Create and enter the project directory;

[0017] S2.1.2. Call kubebuilder and execute the kubebuilder init command, passing in parameters including the custom domain name domain and project name repo;

[0018] S2.1.3. Call kubebuilder and execute the kubebuilder create api command, passing in parameters including the group of the specified CRD, the version of the specified CRD, and the kind of the specified CRD.

[0019] Optionally, when executing step S2 to create a project directory and initialize the Kubebuilder project, the parameters passed in are as follows:

[0020] The custom domain name is com.wyb, and the project name repo is com.wyb / autodeploy;

[0021] Specify the CRD group as webapp, the CRD version as v1, and the CRD kind as autodeploy.

[0022] Further optionally, step S2 is performed, and the created AutoDeploySpec structure specifically includes the following fields:

[0023] (a) A DeploymentApplyConfiguration object or an image field, where: a DeploymentApplyConfiguration object is used to define a complete deployment, or the image field is used to specify the image address to be deployed;

[0024] (b) The Port field, targetPort field, and nodePort field used for Service configuration, where: the Port field is used to indicate the address exposed by the Service created by cascading. If the Port field is empty, port 80 is used by default; the targetPort field is used to indicate the service address exposed by the POD of the Service proxy, which is a required field; the nodePort field is used to indicate whether the service is created in nodePort mode and to indicate the node port to be exposed, and the node port to be exposed must be greater than 30000;

[0025] (c) A VirtualService object or IstioHost field, where: a VirtualService object is used for a complete IstioVirtualService definition, or a VirtualService hostname matching route is set using a specific IstioHost field;

[0026] (d) IngressApplyConfiguration object or IngressHost field, where: Use the IngressApplyConfiguration object to complete the Ingress definition, or use the specified IngressHost field to set the Ingress domain name routing rules.

[0027] Further optionally, step S2 is performed, and the assembled AutoDeploy structure includes an AutoDeploySpec object, a TypeMeta object, an ObjectMeta object, and a status object that expresses the service status.

[0028] Further optionally, the Reconcile method involved in step S3 adopts the controller mode to manage k8s resources in a declarative event-driven manner. The specific implementation process includes:

[0029] Get the current state of the object resources, compare the current state with the expected state, and decide whether to create, update, or delete resources other than the current object, or modify the state of its own resources based on the comparison results.

[0030] Further optionally, the step S4 specifically includes the following operations:

[0031] S4.1. Use the k8s client to query whether the custom autodeploy CRD object exists in the namespace. If it exists, perform subsequent operations. If it does not exist, it means that the resource has been deleted and returns directly.

[0032] S4.2. Query the existence of Deployment resources based on the name and namespace fields of the ObjectMeta object, and create or update Deployment resources as needed:

[0033] If the Deployment resource does not exist, the objects required to create the k8s Deploy resource are assembled according to the DeploymentApplyConfiguration object and the image field. In this process: a) If the DeploymentApplyConfiguration object is not empty, the Deployment resource is created directly using the DeploymentApplyConfiguration object; b) If the DeploymentApplyConfiguration is empty, a DeploymentApplyConfiguration object is constructed, label:autodeploy-app: AutoDeploy.name is added, the container name is the AutoDeploy name, the container image is the image field value, and the AutoDeploy object is set as the owner of the Deployment object;

[0034] If the Deployment resource exists, the update operation is performed according to the DeploymentApplyConfiguration object;

[0035] S4.3. Query the existence of Service resources based on the name and namespace fields of the ObjectMeta object, and create or update Service resources as needed:

[0036] If the Service resource does not exist, a Service object is constructed based on the specific information of the Port field, targetPort field, and nodePort field, label:autodeploy-app: AutoDeploy.name is added, the Service name is the AutoDeploy name, and the AutoDeploy object is set as the owner of the Service object;

[0037] If the Service resource exists, create a Service object and perform the update operation;

[0038] S4.4. Query the existence of Istio VirtualService resources based on the name and namespace fields of the ObjectMeta object, and create or update Istio VirtualService resources as needed:

[0039] If the Istio VirtualService resource does not exist, a VirtualService object is constructed based on the VirtualService object and IstioHost fields, label:autodeploy-app: AutoDeploy.name is added, the VirtualService name is the AutoDeploy name, and the AutoDeploy object is set as the owner of the VirtualService object;

[0040] If the Istio VirtualService resource exists, create a VirtualService object and perform an update operation;

[0041] S4.5. Query the existence of Ingress resources based on the name and namespace fields of the ObjectMeta object, and create or update Ingress resources as needed:

[0042] If the Ingress resource does not exist, build an IngressApplyConfiguration object based on the VirtualService object and IstioHost fields, add label:autodeploy-app: AutoDeploy.name, the Ingress name is the AutoDeploy name, and set the AutoDeploy object as the owner of the Ingress object;

[0043] If the Ingress resource exists, create an Ingress object and perform an update operation;

[0044] S4.6. Determine whether the deployment is successful based on the number of available copies of the Deployment resource: if the number of available copies is greater than 0, it means that the deployment is successful; if the number of available copies is equal to 0, it means that the deployment fails; then update the status of the autodeploy resource based on the deployment status.

[0045] Further optionally, step S5 is executed, and the SetupWithManager method binds the coordinated resource type to autodeploy through the controller manager, and coordinates the owner resource types to Deployment, Service, VirtualService and Ingress to respond to create events, delete events or update events.

[0046] Further optionally, the step S7 involved specifically includes:

[0047] Run make docker-build docker-push IMG= <some-registry> / <project-name>:tag command, build the controller code into a Docker image and push it to the specified image repository;

[0048] Run make deploy IMG= <some-registry> / <project-name>:tag command to deploy the controller image to the k8s cluster;

[0049] Write the resource manifest file of autodeployCRD, deploy it to the k8s cluster, and observe the creation, update, and deletion events of Deployment resources, Service resources, VirtualService resources, and Ingress resources.

[0050] The simple deployment method of K8s resources of the present invention has the following beneficial effects compared with the prior art:

[0051] 1. By creating CRD, the present invention can automatically complete the creation of K8s resources such as Deployment, Service, VirtualService and Ingress, thereby greatly simplifying the deployment process of K8s resources;

[0052] 2. The present invention realizes the automatic creation and management of K8s resources through the combination of CRD and controller. Users do not need to manually write complex YAML files, which simplifies the deployment process. The controller automatically reconciles the resource status to ensure that the resources in the K8s cluster are always consistent with the CRD definition, reducing the need for manual intervention and improving operation and maintenance efficiency. The load-balanced CRD constructed by UN can be expanded according to user needs, supporting more types of K8s resources and adapting to different application scenarios. Through the automated process, deployment errors caused by manual operations are significantly reduced, and the stability of the system is improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0053] Attached Figure 1 It is a flow chart of the method of the present invention. DETAILED DESCRIPTION

[0054] In order to make the technical solution, the technical problem solved and the technical effect of the present invention more clearly understood, the technical solution of the present invention is clearly and completely described below in conjunction with specific embodiments.

[0055] Embodiment 1: Combining with Figure 1 This embodiment proposes a simple deployment method for K8s resources. The method automatically completes the creation of K8s resources by creating CRD, which specifically includes the following operations:

[0056] S1. Install and configure the golang environment;

[0057] In the Linux environment, install the Make command tool so that you can use Makefile to compile and build the source code;

[0058] According to the operating system version and CPU architecture, select the appropriate kubebuilder version to download and decompress it to the / usr / local / bin / directory.

[0059] S2. Create a project directory and initialize the Kubebuilder project. Create an AutoDeploySpec structure to represent the definition information required when creating the autodeploy CRD. Assemble the AutoDeploy structure to describe the data structure of the autodeploy CRD.

[0060] In this embodiment, the specific process of creating a project directory and initializing the Kubebuilder project is as follows:

[0061] S2.1.1. Create and enter the project directory;

[0062] S2.1.2. Call kubebuilder and execute the kubebuilder init command, passing in parameters including the custom domain name domain and the project name repo. Specifically, the custom domain name domain is com.wyb and the project name repo is com.wyb / autodeploy.

[0063] S2.1.3. Call kubebuilder and execute the kubebuilder create api command, passing in parameters including the group of the CRD, the version of the CRD, and the kind of the CRD. Specifically, specify the group of the CRD as webapp, the version of the CRD as v1, and the kind of the CRD as autodeploy.

[0064] In this embodiment, the created AutoDeploySpec structure specifically includes the following fields:

[0065] (a) A DeploymentApplyConfiguration object or an image field, where: a DeploymentApplyConfiguration object is used to define a complete deployment, or the image field is used to specify the image address to be deployed;

[0066] (b) The Port field, targetPort field, and nodePort field used for Service configuration, where: the Port field is used to indicate the address exposed by the Service created by cascading. If the Port field is empty, port 80 is used by default; the targetPort field is used to indicate the service address exposed by the POD of the Service proxy, which is a required field; the nodePort field is used to indicate whether the service is created in nodePort mode and to indicate the node port to be exposed, and the node port to be exposed must be greater than 30000;

[0067] (c) A VirtualService object or IstioHost field, where: a VirtualService object is used for a complete IstioVirtualService definition, or a VirtualService hostname matching route is set using a specific IstioHost field;

[0068] (d) IngressApplyConfiguration object or IngressHost field, where: Use the IngressApplyConfiguration object to complete the Ingress definition, or use the specified IngressHost field to set the Ingress domain name routing rules.

[0069] In this embodiment, the assembled AutoDeploy structure includes an AutoDeploySpec object, a TymeMeta object, and an ObjectMeta object, as well as a status object that expresses the service status. Among them: the AutoDeploySpec object contains the specification information of the user-defined CRD resource, that is, the state that the user expects the resource to achieve, including the DeploymentApplyConfiguration object or the image field, and the Port field, targetPort field, and nodePort field of the Service configuration, as well as the VirtualService object or the IstioHost field, and the IngressApplyConfiguration object or the IngressHost field; the TypeMeta object contains the type information of the CRD resource, such as the API version, Kind, etc.; the ObjectMeta object contains the metadata information of the CRD resource, such as the name, label, annotation, etc.; the Status object contains the current status information of the CRD resource; in the Reconcile method, the controller will update the status of the resource according to the specification information in the Spec, and store the result in the Status object.

[0070] S3. Implement the Reconcile method to coordinate various resources in k8s to achieve the desired state of the system.

[0071] The Reconcile method described in this step uses the controller mode to manage k8s resources in a declarative event-driven way. The specific implementation process includes:

[0072] Get the current state of the object resources, compare the current state with the expected state, and decide whether to create, update, or delete resources other than the current object, or modify the state of its own resources based on the comparison results.

[0073] S4. Check whether the CRD object exists, create or update the relevant K8s resources, and update the CRD resource status according to the deployment status. The specific operations include the following:

[0074] S4.1. Use the k8s client to query whether the custom autodeploy CRD object exists in the namespace. If it exists, perform subsequent operations. If it does not exist, it means that the resource has been deleted and returns directly.

[0075] S4.2. Query the existence of Deployment resources based on the name and namespace fields of the ObjectMeta object, and create or update Deployment resources as needed:

[0076] If the Deployment resource does not exist, the objects required to create the k8s Deploy resource are assembled according to the DeploymentApplyConfiguration object and the image field. In this process: a) If the DeploymentApplyConfiguration object is not empty, the Deployment resource is created directly using the DeploymentApplyConfiguration object; b) If the DeploymentApplyConfiguration is empty, a DeploymentApplyConfiguration object is constructed, label:autodeploy-app: AutoDeploy.name is added, the container name is the AutoDeploy name, the container image is the image field value, and the AutoDeploy object is set as the owner of the Deployment object. This means that if the AutoDeploy object is deleted, Kubernetes will automatically delete the Deployment it owns. This is a cascading deletion mechanism;

[0077] If the Deployment resource exists, the update operation is performed according to the DeploymentApplyConfiguration object.

[0078] S4.3. Query the existence of Service resources based on the name and namespace fields of the ObjectMeta object, and create or update Service resources as needed:

[0079] If the Service resource does not exist, a Service object is constructed based on the specific information of the Port field, targetPort field, and nodePort field, label:autodeploy-app: AutoDeploy.name is added, and the Service name is the AutoDeploy name. The AutoDeploy object is set as the owner of the Service object to facilitate cascading resource deletion.

[0080] If the Service resource exists, create a Service object and perform an update operation.

[0081] S4.4. Query the existence of Istio VirtualService resources based on the name and namespace fields of the ObjectMeta object, and create or update Istio VirtualService resources as needed:

[0082] If the Istio VirtualService resource does not exist, a VirtualService object is constructed based on the VirtualService object and IstioHost fields, label:autodeploy-app: AutoDeploy.name is added, the VirtualService name is the AutoDeploy name, and the AutoDeploy object is set as the owner of the VirtualService object to facilitate cascading resource deletion.

[0083] If the Istio VirtualService resource exists, create a VirtualService object and perform an update operation.

[0084] S4.5. Query the existence of Ingress resources based on the name and namespace fields of the ObjectMeta object, and create or update Ingress resources as needed:

[0085] If the Ingress resource does not exist, construct an IngressApplyConfiguration object based on the VirtualService object and IstioHost fields, add label:autodeploy-app: AutoDeploy.name, the Ingress name is the AutoDeploy name, and set the AutoDeploy object as the owner of the Ingress object to facilitate cascading resource deletion.

[0086] If the Ingress resource exists, create an Ingress object and perform an update operation.

[0087] S4.6. Determine whether the deployment is successful based on the number of available copies of the Deployment resource: if the number of available copies is greater than 0, it means that the deployment is successful; if the number of available copies is equal to 0, it means that the deployment fails; then update the status of the autodeploy resource based on the deployment status.

[0088] S5. Configure the SetupWithManager method to register the controller with the Manager and set the monitoring of the AutoDeploy resource to trigger the implementation logic of the Reconcile method.

[0089] The SetupWithManager method described in this step binds the coordinated resource type to autodeploy through the controller manager, and coordinates the owner resource types to Deployment, Service, VirtualService, and Ingress in order to respond to create events, delete events, or update events.

[0090] It should be added that AutoDeploy resources refer to the autodeploy resource instances created through CRD.

[0091] S6. Execute the make manifests command in the project directory to generate a resource list for autodeployCRD, and use the k8s client to apply the generated CRD resource list to the k8s cluster.

[0092] S7. Build a Docker image and deploy it to the k8s cluster to achieve the function of automatic resource management, including:

[0093] Run make docker-build docker-push IMG= <some-registry> / <project-name>:tag command, build the controller code into a Docker image and push it to the specified image repository;

[0094] Run make deploy IMG= <some-registry> / <project-name>:tag command to deploy the controller image to the k8s cluster;

[0095] Write the resource manifest file of autodeployCRD, deploy it to the k8s cluster, and observe the creation, update, and deletion events of Deployment resources, Service resources, VirtualService resources, and Ingress resources.

[0096] In summary, by adopting the simple deployment method of K8s resources of the present invention, the automatic creation and management of K8s resources can be realized without the user manually writing complex YAML files, which not only reduces the need for manual intervention but also improves operation and maintenance efficiency.

[0097] The above specific examples are used to explain the principles and implementation methods of the present invention in detail. These examples are only used to help understand the core technical content of the present invention. Based on the above specific embodiments of the present invention, any improvements and modifications made by technicians in this technical field without departing from the principles of the present invention should fall within the scope of patent protection of the present invention. < / some-registry> < / some-registry> < / some-registry> < / some-registry>

Claims

1. A simple deployment method for K8s resources, characterized in that: This method automatically creates K8s resources by creating CRD, which includes the following operations: S1. Install and configure the Golang environment and the Make tool under Linux, then select the Kubebuilder version according to the operating system version and CPU architecture, and download and decompress it to the specified directory; S2. Create a project directory and initialize the Kubebuilder project; create an AutoDeploySpec structure to represent the definition information required when creating the autodeploy CRD, where the AutoDeploySpec structure specifically includes the following fields: DeploymentApplyConfiguration object or image field, Port field, targetPort field and nodePort field for Service configuration, VirtualService object or IstioHost field, IngressApplyConfiguration object or IngressHost field; assemble the AutoDeploy structure to describe the data structure of the autodeploy CRD, where the AutoDeploy structure includes the AutoDeploySpec object, TymeMeta object and ObjectMeta object, and the status object that expresses the service status; S3. Implement the Reconcile method to coordinate various resources in k8s to achieve the desired state of the system; S4. Check whether the CRD object exists, create or update the relevant K8s resources, and update the CRD resource status according to the deployment status. The specific operations include the following: S4.

1. Use the k8s client to query whether the custom autodeploy CRD object exists in the namespace. If it exists, perform subsequent operations. If it does not exist, it means that the resource has been deleted and returns directly. S4.

2. Query the existence of Deployment resources based on the name and namespace fields of the ObjectMeta object, and create or update Deployment resources as needed: If the Deployment resource does not exist, the objects required to create the k8s Deploy resource are assembled according to the DeploymentApplyConfiguration object and the image field. In this process: a) If the DeploymentApplyConfiguration object is not empty, the Deployment resource is created directly using the DeploymentApplyConfiguration object; b) If the DeploymentApplyConfiguration is empty, a DeploymentApplyConfiguration object is constructed, label:autodeploy-app: AutoDeploy.name is added, the container name is the AutoDeploy name, the container image is the image field value, and the AutoDeploy object is set as the owner of the Deployment object; If the Deployment resource exists, the update operation is performed according to the DeploymentApplyConfiguration object; S4.

3. Query the existence of Service resources based on the name and namespace fields of the ObjectMeta object, and create or update Service resources as needed: If the Service resource does not exist, a Service object is constructed based on the specific information of the Port field, targetPort field, and nodePort field, label:autodeploy-app: AutoDeploy.name is added, the Service name is the AutoDeploy name, and the AutoDeploy object is set as the owner of the Service object; If the Service resource exists, create a Service object and perform the update operation; S4.

4. Query the existence of Istio VirtualService resources based on the name and namespace fields of the ObjectMeta object, and create or update Istio VirtualService resources as needed: If the Istio VirtualService resource does not exist, a VirtualService object is constructed based on the VirtualService object and IstioHost fields, label:autodeploy-app: AutoDeploy.name is added, the VirtualService name is the AutoDeploy name, and the AutoDeploy object is set as the owner of the VirtualService object; If the Istio VirtualService resource exists, create a VirtualService object and perform an update operation; S4.

5. Query the existence of Ingress resources based on the name and namespace fields of the ObjectMeta object, and create or update Ingress resources as needed: If the Ingress resource does not exist, build an IngressApplyConfiguration object based on the VirtualService object and IstioHost fields, add label:autodeploy-app: AutoDeploy.name, the Ingress name is the AutoDeploy name, and set the AutoDeploy object as the owner of the Ingress object; If the Ingress resource exists, create an Ingress object and perform an update operation; S4.

6. Determine whether the deployment is successful based on the number of available copies of the Deployment resource: if the number of available copies is greater than 0, it means that the deployment is successful; if the number of available copies is equal to 0, it means that the deployment fails; then update the status of the autodeploy resource based on the deployment status; S5. Configure the SetupWithManager method to register the controller with the Manager and set the monitoring of the AutoDeploy resource to trigger the implementation logic of the Reconcile method. S6. Execute the make manifests command in the project directory to generate a resource list for autodeployCRD, and use the k8s client to apply the generated CRD resource list to the k8s cluster; S7. Build a Docker image and deploy it to the k8s cluster to ultimately achieve the function of automatic resource management.

2. According to claim 1, a simple deployment method for K8s resources is characterized in that: Execute step S2 to create a project directory and initialize the Kubebuilder project. The specific process is as follows: S2.1.

1. Create and enter the project directory; S2.1.

2. Call kubebuilder and execute the kubebuilder init command, passing in parameters including the custom domain name domain and project name repo; S2.1.

3. Call kubebuilder and execute the kubebuilder create api command, passing in parameters including the group of the specified CRD, the version of the specified CRD, and the kind of the specified CRD.

3. According to claim 2, a simple deployment method for K8s resources is characterized in that: When executing step S2 to create a project directory and initialize the Kubebuilder project, the parameters passed in are as follows: The custom domain name is com.wyb, and the project name repo is com.wyb / autodeploy; Specify the CRD group as webapp, the CRD version as v1, and the CRD kind as autodeploy.

4. According to claim 3, a simple deployment method for K8s resources is characterized in that: Execute step S2. The AutoDeploySpec structure specifically includes the following fields: (a) A DeploymentApplyConfiguration object or an image field, where: a DeploymentApplyConfiguration object is used to define a complete deployment, or the image field is used to specify the image address to be deployed; (b) The Port field, targetPort field, and nodePort field used for Service configuration, where: the Port field is used to indicate the address exposed by the Service created by cascading. If the Port field is empty, port 80 is used by default; the targetPort field is used to indicate the service address exposed by the POD of the Service proxy, which is a required field; the nodePort field is used to indicate whether the service is created in nodePort mode and to indicate the node port to be exposed, and the node port to be exposed must be greater than 30000; (c) A VirtualService object or IstioHost field, where: a VirtualService object is used for a complete IstioVirtualService definition, or a VirtualService hostname matching route is set using a specific IstioHost field; (d) IngressApplyConfiguration object or IngressHost field, where: Use the IngressApplyConfiguration object to complete the Ingress definition, or use the specified IngressHost field to set the Ingress domain name routing rules.

5. According to claim 4, a simple deployment method for K8s resources is characterized in that: The Reconcile method in step S3 uses the controller mode to manage k8s resources in a declarative event-driven manner. The specific implementation process includes: Get the current state of the object resources, compare the current state with the expected state, and decide whether to create, update, or delete resources other than the current object, or modify the state of its own resources based on the comparison results.

6. According to claim 4, a simple deployment method for K8s resources is characterized in that: Execute step S5, the SetupWithManager method binds the coordinated resource type to autodeploy through the controller manager, and coordinates the owner resource types to Deployment, Service, VirtualService, and Ingress to respond to create events, delete events, or update events.

7. According to claim 6, a simple deployment method for K8s resources is characterized in that: The step S7 specifically includes: Run make docker-build docker-push IMG= <some-registry> / <project-name> :tag command, build the controller code into a Docker image and push it to the specified image repository; < / some-registry> Run make deploy IMG= <some-registry> / <project-name> :tag command to deploy the controller image to the k8s cluster; < / some-registry> Write the resource manifest file of autodeployCRD, deploy it to the k8s cluster, and observe the creation, update, and deletion events of Deployment resources, Service resources, VirtualService resources, and Ingress resources.

Citation Information

Patent Citations

  • Kubernetes-based dynamic management service governance rule configuration method and Kubernetes-based dynamic management service governance rule configuration system

    CN112000434A

  • Method for realizing container resource customized scheduling and deletion protection based on Webhook technology

    CN114595035A