Resource query method and device, electronic equipment and storage medium

By constructing a syntax tree structure and converting it into an application programming interface request, the complexity of cross-resource type queries in existing technologies is solved, enabling cross-resource type joint queries and custom aggregations, reducing learning costs and query complexity.

CN122262162APending Publication Date: 2026-06-23SINA TECH (CHINA) CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SINA TECH (CHINA) CO LTD
Filing Date
2026-02-25
Publication Date
2026-06-23

Smart Images

  • Figure CN122262162A_ABST
    Figure CN122262162A_ABST
Patent Text Reader

Abstract

The application provides a resource query method and device, electronic equipment and storage medium; the method comprises the following steps: acquiring a query statement, wherein the query statement is used for querying at least one type of resource on a container orchestration platform; a syntax tree structure corresponding to the query statement is constructed, wherein a node in the syntax tree structure is used for representing a clause corresponding to the query statement; the syntax tree structure is converted into at least one application programming interface request; resource data associated with the at least one type of resource is acquired based on the at least one application programming interface request; and aggregation is performed on the resource data to obtain a query result corresponding to the query statement. Through the application, a unified query interface can be provided to access different types of data sources, thereby realizing joint query across resource types, reducing the complexity of resource query, and reducing the use threshold without the need to learn multiple tools.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to computer technology, and more particularly to a resource query method, apparatus, electronic device, and storage medium. Background Technology

[0002] Kubernetes is a container orchestration platform that automates the deployment, scaling, and management of containerized applications.

[0003] Querying resources on Kubernetes is usually done through the Kubernetes command-line tool (Kubernetescontrol, kubectl). kubectl can support filtering and querying of a single resource type, but it cannot perform complex logical combinations, its query method is not flexible enough, and it cannot support joint queries across resource types. Summary of the Invention

[0004] This application provides a resource query method, apparatus, electronic device, and storage medium that can provide a unified query interface to access different types of data sources, thereby enabling joint queries across resource types.

[0005] The technical solution of this application embodiment is implemented as follows:

[0006] This application provides a resource query method, comprising: obtaining a query statement, wherein the query statement is used to query at least one type of resource on a container orchestration platform; constructing a syntax tree structure corresponding to the query statement, wherein nodes in the syntax tree structure are used to represent clauses corresponding to the query statement; converting the syntax tree structure into at least one application programming interface (API) request; obtaining resource data associated with at least one type of resource based on the at least one API request; and performing aggregation on the resource data to obtain the query result corresponding to the query statement.

[0007] This application provides a resource query device, comprising: a first acquisition module for acquiring a query statement, wherein the query statement is used to query at least one type of resource on a container orchestration platform; a construction module for constructing a syntax tree structure corresponding to the query statement, wherein nodes in the syntax tree structure represent clauses corresponding to the query statement; a conversion module for converting the syntax tree structure into at least one application programming interface (API) request; a second acquisition module for acquiring resource data associated with at least one type of resource based on at least one API request; and an aggregation module for performing aggregation on the resource data to obtain query results corresponding to the query statement.

[0008] In some embodiments, the conversion module includes at least one of the following: a first generation unit, configured to generate a first application programming interface (API) request based on a first node in a syntax tree structure, wherein the first node represents a resource clause, the first API request is used to obtain first resource data corresponding to a first field included in the first node, and the first field represents a resource of a first type; a second generation unit, configured to generate a second API request based on a second node in a syntax tree structure, wherein the second node represents a resource join clause, the second API request is used to obtain second resource data corresponding to a second field included in the second node, and the second field represents a resource of a second type associated with the resource of the first type; a first conversion unit, configured to convert a third node in a syntax tree structure into a first filter parameter when the third node in the syntax tree structure includes a field associated with the first field, and use the first filter parameter as a query parameter of the first API request, wherein the third node represents a filter clause; and a second conversion unit, configured to convert a third node into a second filter parameter when the third node includes a field associated with the second field, and use the second filter parameter as a query parameter of the second API request.

[0009] In some embodiments, the first generation unit is configured to perform the following steps: obtain a first parameter associated with a first field; map the first field to a first target field corresponding to a container orchestration platform; and generate a first application programming interface request based on the first parameter and the first target field.

[0010] In some embodiments, the second generation unit is configured to perform the following steps: obtain a second parameter associated with the second field; map the second field to a second target field corresponding to the container orchestration platform; and generate a second application programming interface request based on the second parameter and the second target field.

[0011] In some embodiments, the second acquisition module includes: an acquisition unit, configured to acquire first resource data according to a first application programming interface request and acquire second resource data according to a second application programming interface request via the application programming interface of the container orchestration platform; and a matching unit, configured to perform association matching on the first resource data and the second resource data according to the association conditions in the second node to obtain third resource data that satisfies the association conditions.

[0012] In some embodiments, the matching unit is configured to perform the following steps: converting the association conditions in the second node into an association matching strategy corresponding to the container orchestration platform; and performing association matching on the first resource data and the second resource data based on the association matching strategy.

[0013] In some embodiments, the apparatus further includes a checking module, configured to perform a validity check on the resource type corresponding to at least one node in the syntax tree structure and the fields associated with the resource type after constructing the syntax tree structure corresponding to the query statement; and a determining module, configured to determine that the syntax tree structure passes the validity check if the resource type corresponding to at least one node is valid and the fields associated with the resource type are valid.

[0014] In some embodiments, the inspection module is configured to perform the following steps: matching the resource type corresponding to at least one node with the resource types included in the cluster of the container orchestration platform to determine whether the resource type corresponding to at least one node is valid; matching the fields associated with the resource type corresponding to at least one node with the fields associated with the resource types included in the cluster of the container orchestration platform to determine whether the fields associated with the resource type corresponding to at least one node are valid; and performing logical verification on at least two fields associated with the resource type included in the association conditions of at least one node to determine whether the fields associated with the resource type are valid.

[0015] In some embodiments, the construction module is configured to perform the following steps: perform lexical analysis on the query statement to obtain the tag sequence corresponding to the query statement; and convert the tag sequence into a syntax tree structure according to the syntax rules.

[0016] In some embodiments, aggregation includes at least one of summation, counting, averaging, finding the maximum value, finding the minimum value, and grouping.

[0017] This application provides an electronic device, including: a processor; and a memory for storing computer programs or instructions; wherein the processor executes the computer programs or instructions to implement the steps in any of the methods provided in this application.

[0018] This application provides a computer-readable storage medium storing a computer program or instructions thereon, which, when executed by a processor, implements the steps of any method provided in this application.

[0019] This application provides a computer program product, including a computer program or instructions, which, when executed by a processor, implement the steps of any method provided in this application.

[0020] The technical solutions provided by the embodiments of this application may include the following beneficial effects:

[0021] The process involves obtaining the query statement, parsing it to construct a syntax tree structure corresponding to the query statement, traversing the syntax tree structure, and converting it into at least one application programming interface (API) request to adapt to different data sources. Based on these API requests, resource data associated with at least one type of resource is retrieved. Aggregation operations are then performed on the retrieved resource data to obtain the query results corresponding to the query statement. In this way, by converting the query statement into API requests to obtain resource data, a unified query interface can be provided to access different types of data sources, thereby enabling cross-resource type joint queries, reducing the complexity of resource queries, and lowering the barrier to entry, eliminating the need to learn multiple tools.

[0022] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and do not limit this application. Attached Figure Description

[0023] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0024] Figure 1 This is a flowchart illustrating a resource query method according to an exemplary embodiment.

[0025] Figure 2 This is an architecture diagram of a system for implementing a resource query method, according to an exemplary embodiment.

[0026] Figure 3 This is a block diagram illustrating a resource query apparatus according to an exemplary embodiment.

[0027] Figure 4 This is a structural block diagram of an electronic device according to an exemplary embodiment.

[0028] Figure 5 This is a block diagram illustrating a server according to an exemplary embodiment. Detailed Implementation

[0029] To make the objectives, technical solutions, and advantages of this application clearer, the application will be further described in detail below with reference to the accompanying drawings. The described embodiments should not be regarded as limitations on this application. All other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0030] In the following description, references are made to “some embodiments,” which describe a subset of all possible embodiments. However, it is understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.

[0031] In the following description, the terms "first, second, third" are used merely to distinguish similar objects and do not represent a specific ordering of objects. It is understood that "first, second, third" may be interchanged in a specific order or sequence where permitted, so that the embodiments of this application described herein can be implemented in an order other than that illustrated or described herein.

[0032] In the embodiments of this application, the terms "module" or "unit" refer to a computer program or part of a computer program that has a predetermined function and works with other related parts to achieve a predetermined goal, and can be implemented wholly or partially using software, hardware (such as processing circuitry or memory), or a combination thereof. Similarly, a processor (or multiple processors or memory) can be used to implement one or more modules or units. Furthermore, each module or unit can be part of an overall module or unit that includes the functionality of that module or unit.

[0033] Unless otherwise defined, all technical and scientific terms used in the embodiments of this application have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used in the embodiments of this application is for the purpose of describing the embodiments of this application only and is not intended to limit this application.

[0034] Before providing a further detailed description of the embodiments of this application, the nouns and terms involved in the embodiments of this application will be explained, and the nouns and terms involved in the embodiments of this application shall be interpreted as follows.

[0035] I. Kubernetes

[0036] In some embodiments, Kubernetes may be referred to simply as K8s. It is an open-source container orchestration platform that can be used to automate the deployment, scaling, and management of containerized applications.

[0037] In some embodiments, a container is a virtualization technology that allows multiple user-space instances (i.e., containers) to run independently and in isolation on a single host operating system.

[0038] In some embodiments, a container can package application code, runtime environment, system tools, system libraries, and settings together to form a single, portable software unit. In some embodiments, each container has its own independent file system, network, and process space.

[0039] 2. kubectl

[0040] In some embodiments, kubectl can be a client tool that can be installed on a local computer or maintenance workstation and can communicate with the Kubernetes application programming interface server (API Server).

[0041] III. Label Selector

[0042] In some embodiments, a label selector is a query mechanism in Kubernetes used to filter and select resource objects with specific labels.

[0043] IV. JavaScript Object Representation Path

[0044] In some embodiments, JavaScript object notation path (JSONPath) is a query language used to extract specific data from a JSON document.

[0045] V. JSON Query Tool

[0046] In some embodiments, the JSON query tool can be jq, a lightweight and flexible command-line JSON processor that can be used to parse, filter, transform, and format JSON data.

[0047] VI. Standard Structured Query Language

[0048] In some embodiments, the standard structured query language may be the American National Standards Institute Structured Query Language (ANSI SQL).

[0049] In some embodiments, ANSI SQL is a relational database standard query language jointly developed by the American National Standards Institute and the International Organization for Standardization (ISO).

[0050] VII. Kubernetes Resource Types

[0051] In some embodiments, Kubernetes resource types may include, but are not limited to, the following: pods, services, deployments, and custom resource definitions (CRDs).

[0052] In some embodiments, a pod can be the smallest and most basic unit of scheduling and management in Kubernetes, used to host and manage one or more containers.

[0053] In some embodiments, a service defines a logical set of pods and a strategy for accessing that logical set. It serves as the access point for pods and can provide service discovery and load balancing.

[0054] In some embodiments, a deployment can be a pod lifecycle manager, responsible for deployment, scaling up, scaling down, and self-healing; it can manage pod replica sets.

[0055] In some embodiments, the terms "pod" and "Pod" can be used interchangeably.

[0056] In some embodiments, the terms "service" and "Service" can be used interchangeably.

[0057] In some embodiments, the terms “deployment” and “Deployment” can be used interchangeably.

[0058] In some embodiments, CRD can be an extension mechanism for Kubernetes used to define and manage new resource types, which can be user-defined resource types that differ from Kubernetes resource types.

[0059] In related technologies, resources on Kubernetes are usually queried using the basic resource query function provided by kubectl. kubectl can support simple filtering based on tag selectors and JSONPath, but it lacks flexible resource query capabilities.

[0060] In some embodiments, the integration of the syntax of Structured Query Language (SQL) with Kubernetes resource queries has not yet been implemented. That is, the syntax of Structured Query Language cannot be directly used for Kubernetes resource queries, making it difficult to write complex queries, and thus the related technologies cannot support joint queries across resource types.

[0061] In some embodiments, the related technology has the following problems:

[0062] 1. Complex syntax: Combined queries require the use of tools such as kubectl, JSONPath, or jq, which requires learning multiple tools and has a high learning cost.

[0063] 2. Functional limitations: It does not support cross-resource type related queries. For example, the related query of Pod and Service cannot be achieved through kubectl.

[0064] 3. Poor scalability: It cannot customize aggregate calculations; for example, it cannot calculate the total resource consumption of namespaces.

[0065] 4. Non-standardized interface: Difficult to integrate with the structured query language ecosystem toolchain.

[0066] 5. Fragmented query syntax: It requires learning the syntax of various tools (such as JSONPath, tag selectors, jq, etc.).

[0067] 6. Low efficiency: Complex queries require writing scripts or making multiple calls to Kubernetes application programming interfaces.

[0068] This application provides a resource query method, apparatus, electronic device, and storage medium, which can solve the problems of related technologies not supporting cross-resource type association queries and requiring the learning of multiple tools.

[0069] In this embodiment, a query statement is obtained, parsed to construct a syntax tree structure corresponding to the query statement transformation, and then the syntax tree structure is traversed to convert it into at least one application programming interface (API) request to adapt to different data sources. Based on the at least one API request, resource data associated with at least one type of resource is obtained. Aggregation operations are performed on the obtained resource data to obtain the query result corresponding to the query statement. Thus, by converting the query statement into an API request to obtain resource data, a unified query interface can be provided to access different types of data sources, thereby enabling cross-resource type joint queries, reducing the complexity of resource queries, and lowering the barrier to entry, eliminating the need to learn multiple tools.

[0070] In some embodiments, the resource query method provided in this application can be implemented by a terminal, a server, or a combination of a terminal and a server, and this application does not specifically limit this.

[0071] In some embodiments, the terminal and server can implement the resource query method provided in this application by running a computer program. In one embodiment, the computer program can be a native program or software module in the operating system; it can be a local application (APP), that is, a program that needs to be installed in the operating system to run, such as an instant messaging APP; it can also be a mini-program, that is, a program that only needs to be downloaded to the browser environment to run; or it can be a mini-program that can be embedded in any APP. In short, the above-mentioned computer program can be any form of application, module or plug-in, and this application does not limit it.

[0072] In some embodiments, the terminal may be a smartphone, tablet, laptop, desktop computer, smart speaker, smartwatch, etc., but is not limited to these. The server may be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, and big data and artificial intelligence platforms. The terminal and the server may be directly or indirectly connected via wired or wireless communication, which is not limited in the embodiments of this application.

[0073] Figure 1 This is a flowchart illustrating a resource query method according to an exemplary embodiment. For example... Figure 1 As shown, this method can be implemented by a terminal, a server, or a combination of both. The method mainly includes the following steps:

[0074] In step 101, the query statement is obtained.

[0075] In step 102, a syntax tree structure corresponding to the query statement is constructed.

[0076] In step 103, the syntax tree structure is converted into at least one application programming interface request.

[0077] In step 104, resource data associated with at least one type of resource is requested based on at least one application programming interface.

[0078] In step 105, the resource data is aggregated to obtain the query results corresponding to the query statement.

[0079] In some embodiments, for step 101, the query statement can be written based on a database language. A database language is a computer language used to define, manipulate, query, and manage databases. In some embodiments, the database may include a structured query database, a document database, a graph database, etc. For example, the database language corresponding to a structured query database may be SQL. For example, the database language corresponding to a document database may be a first query language (nicknamefor1 (number one) query language, N1QL). For example, the database language corresponding to a graph database may be Cypher. It is understood that the query statement can also be written using other database languages, or even other types of languages, and this application embodiment does not limit this.

[0080] In some embodiments, for step 101, the query statement can be user-inputted or pre-set. For example, the terminal or server can obtain the user-inputted query language through a user interface. Alternatively, the query language can be obtained through other means, which are not limited in this embodiment.

[0081] In some embodiments, the query statement may include, but is not limited to, at least one of the following: a select statement, a resource statement, a resource join statement, a filter statement, and a grouping and aggregation statement. A select statement is used to select which fields to view; a resource statement is used to specify the resources to be queried; a resource join statement is used to associate other resources through join conditions; a filter statement is used to filter based on conditions; and a grouping and aggregation statement is used to group and aggregate the retrieved data. In some embodiments, the filter statement may include a pre-grouping filter statement and a post-grouping filter statement. In some embodiments, a pre-grouping filter statement is used to conditionally filter the results before grouping; a post-grouping filter statement is used to conditionally filter the results after grouping. In some embodiments, other resources may be resources different from the resources specified in the resource statement query.

[0082] In some embodiments, the selection statement may include SELECT column_list. This statement can be used to select which fields to view and specify the columns of data to return.

[0083] In some embodiments, a resource statement may include a source statement, such as FROM resource. This statement can be used to specify the resource to be queried.

[0084] In some embodiments, a resource join statement may include a link statement, such as JOIN resource ONcondition. This statement can be used to associate other resources through a join condition.

[0085] In some embodiments, the pre-grouping filtering statement may include a WHERE condition. This statement can be used to filter based on conditions before grouping.

[0086] In some embodiments, a grouping aggregation statement may include GROUP BY column_list. This statement can be used for grouping aggregation, that is, performing aggregation calculations by grouping columns according to specified columns.

[0087] In some embodiments, the post-grouping filtering statement may include a HAVING condition. This statement is used to filter the grouped results based on certain conditions.

[0088] In some embodiments, the query statement for step 101 can be a SELECT statement structure, which may include:

[0089] SELECT <field list>

[0090] FROM <resource type>

[0091] [JOIN<Resource Type> ON<Association Condition>]

[0092] [WHERE <filter criteria>];

[0093] In one example, the query statement could be:

[0094] SELECT pods.name, services.cluster_ip / / Select the name of the Pod and the cluster Internet Protocol (IP) address column of the Service;

[0095] FROM pods / / Query from container group;

[0096] JOIN services ON pods.labels.app = services.selector.app / / Associate services with the service resource. Connection condition: The pod's app label value is equal to the service's selector app value.

[0097] WHERE pods.status.phase = "Running"; / / Filter condition: Select Pods with a status of "Running".

[0098] Understandably, the above query statement serves to: query all Pods in the "running" state, find the Services associated with them, and return the name of the Pod and the cluster IP address of the corresponding Service.

[0099] In one example, the query statement could be:

[0100] SELECT Pods.name, Deployments.replicas / / Select the name of the Pod and the number of replicas of the Deployment;

[0101] FROM Pods / / Query from container group;

[0102] JOIN Deployments ON Pods.label_app = Deployments.spec_template_label_app / / Associates and connects to Deployment resources. Connection condition: The app label value of the Pod is equal to the app label value in the Deployment template;

[0103] WHERE Pods.namespace = 'production'; / / Filter condition: Query Pods with namespace 'production' (production environment).

[0104] Understandably, the above query statement serves to: query all Pods and their associated Deployments in the production environment namespace, and return the name of the Pod and the number of replicas of the corresponding Deployment.

[0105] In some embodiments, the query statement in step 101 can be used to query at least one type of resource on a container orchestration platform. In some embodiments, the container orchestration platform can be Kubernetes or other platforms, and this application embodiment does not limit this.

[0106] In some embodiments, the syntax tree structure in step 102 is a structured representation of the query statement, which can convert the query statement into a tree-like hierarchical structure to clearly show the logical relationship and execution order of the query.

[0107] In some embodiments, for step 102, the query statement can be converted into a corresponding syntax tree structure through steps such as lexical analysis, syntax analysis, and building tree nodes.

[0108] In some embodiments, for the syntax tree structure in step 102, the nodes in the syntax tree structure are used to represent clauses corresponding to the query statement.

[0109] In some embodiments, the node types of the syntax tree structure in step 102 may include root nodes and child nodes. In one embodiment, the root node may be used to represent a query, and the child nodes may be used to represent clauses included in the query statement.

[0110] In some embodiments, the clauses represented by child nodes may include, but are not limited to, at least one of the following: selection clauses, resource clauses, resource join clauses, filtering clauses, and grouping aggregation clauses. Selection clauses are used to select which fields to view; resource clauses are used to specify the resources to be queried; resource join clauses are used to associate other resources through join conditions; filtering clauses are used to filter based on conditions; and grouping aggregation clauses are used to group and aggregate the retrieved data. In some embodiments, filtering clauses may also be called conditional clauses, which may include pre-grouping filtering clauses and post-grouping filtering clauses. In some embodiments, pre-grouping filtering statements are used to conditionally filter the results before grouping; post-grouping filtering clauses are used to conditionally filter the results after grouping.

[0111] In some embodiments, the selection clause can be a SelectClause, which may contain a list of fields, such as Pods.name;

[0112] In some embodiments, the resource clause can be a source clause, such as FromClause, which can specify the primary resource type, such as Pods;

[0113] In some embodiments, the resource join clause can be a join clause, such as JoinClause, which can define associated resources and conditions, such as Deployments ON Pods.label_app = Deployments.spec_template_label_app;

[0114] In some embodiments, the pre-grouping filtering clause can be WhereClause, which can define filtering conditions for conditionally filtering the results before grouping, such as Pods.namespace='production'.

[0115] In some embodiments, the post-grouping filtering clause can be a HAVING Clause, in which filtering conditions can be defined for conditionally filtering the post-grouping results.

[0116] In some embodiments, for step 103, after constructing the syntax tree structure corresponding to the query statement, the application programming interface converter of the container orchestration platform can map the logic of the syntax tree structure to the parameter structure of the application programming interface, and serialize the parameter structure of the application programming interface into a specific request format, such as JSON, graph query language (GraphQL), representational state transfer (REST) ​​parameters, etc., so as to obtain at least one application programming interface request corresponding to the syntax tree structure.

[0117] In some embodiments, an application programming interface (API) converter can convert a syntax tree structure into at least one API request.

[0118] In some embodiments, for step 104, after receiving at least one application programming interface (API) request, the API server associated with Kubernetes is accessed through the container orchestration platform's API, based on the API request, to obtain resource data associated with at least one type of resource to be queried by the query statement.

[0119] In some embodiments, for step 105, resource data can be processed using a pipeline pattern before performing aggregation.

[0120] In some embodiments, the pipeline pattern can be a data processing pattern that decomposes complex data processing tasks into independent processing stages, with each processing stage handling one task, and finally merging the results obtained from the tasks processed by each processing stage.

[0121] In some embodiments, for step 105, the result aggregation engine can perform aggregation on the resource data. In some embodiments, for step 105, performing aggregation on the resource data can be achieved by the result aggregation engine performing calculations through aggregation functions, obtaining calculation results, and formatting the calculation results for output, thereby obtaining the query results corresponding to the query statement.

[0122] In some embodiments, aggregation functions may include, but are not limited to, the following: summation (Sum) function, counting (COUNT) function, average (AVG) function, maximum (MAX) function, minimum (MIN) function, and grouping (GROUP BY) function.

[0123] In some embodiments, formatted output can be a process of converting aggregated results into a standard format suitable for reading or machine processing. It does not change the value of the data itself, but rather changes the way the data is presented.

[0124] In this embodiment, a query statement is obtained, parsed to construct a syntax tree structure corresponding to the query statement, and then traversed to convert the syntax tree structure into at least one application programming interface (API) request to adapt to different data sources. Based on the at least one API request, resource data associated with at least one type of resource is obtained. Aggregation operations are performed on the obtained resource data to obtain the query result corresponding to the query statement. Thus, by converting the query statement into an API request to obtain resource data, a unified query interface can be provided to access different types of data sources, thereby enabling cross-resource type joint queries. This reduces the complexity of resource queries and lowers the barrier to entry, eliminating the need to learn multiple tools.

[0125] In some embodiments, when the query statement is written based on a structured query language, the declarative query syntax of the structured query language can lower the barrier to entry, and the query statement written based on the structured query language can provide a unified query interface. The structured query language syntax can reduce the learning cost, eliminating the need to learn multiple tools, so that the resource query process implemented based on steps 101 to 105 above can support cross-resource joint query operations, support built-in aggregate functions, and be compatible with the standard syntax of ANSI SQL.

[0126] In some embodiments, step 102 may include: performing lexical analysis on the query statement to obtain the tag sequence corresponding to the query statement; and converting the tag sequence into a syntax tree structure according to syntax rules.

[0127] In some embodiments, the token sequence can be a meaningful sequence obtained by splitting the query statement through lexical analysis. A token in the token sequence can represent a lexical unit, such as SELECT, FROM, WHERE, SUM, ORDER BY, etc. In some embodiments, the token sequence may include keywords, fields corresponding to the keywords, identifiers, operators, literals, statement terminators, etc. In some embodiments, lexical analysis can be implemented using regular expressions or state machines, or in other ways; this application does not limit the specific implementation.

[0128] In some embodiments, the token sequence can be obtained by converting the string in the query statement using a syntax parser.

[0129] In one example, the query statement is:

[0130] SELECT Pods.name, Deployments.replicas

[0131] FROM Pods

[0132] JOIN Deployments ON Pods.label_app = Deployments.spec_template_label_app

[0133] WHERE Pods.namespace = 'production';

[0134] Lexical analysis of the above query statement yields the following token sequence:

[0135] ["SELECT", / / keyword]

[0136] "Pods.name", / / Resource field

[0137] ", / / Separator

[0138] "Deployments.replicas", / / Resource field

[0139] "FROM", / / keyword

[0140] "Pods", / / Resource type

[0141] "JOIN", / / keyword

[0142] "Deployments", / / Resource type

[0143] "ON", / / keyword

[0144] "Pods.label_app", / / Join condition

[0145] "=", / / Operator

[0146] "Deployments.spec_template_label_app", / / Associated condition

[0147] "WHERE", / / keyword

[0148] "Pods.namespace", / / identifier

[0149] "=", / / Operator

[0150] "'production'", / / literal

[0151] ";" / / Statement terminator

[0152] ].

[0153] In some embodiments, the syntax tree can be an abstract syntax tree (AST).

[0154] In some embodiments, the syntax tree can extract information related to resource management from the token sequence, such as extracting resource types from resource clauses; extracting filtering conditions from conditional clauses (filter clauses); and extracting cross-resource association logic from resource join clauses.

[0155] In some embodiments, after obtaining the token sequence, a syntax analysis is performed on the token sequence. That is, according to the syntax rules associated with the syntax tree, the tokens included in the token sequence are transformed according to the syntax rules to obtain the syntax tree structure. In this way, the syntax tree structure can reflect the hierarchy and subordinate relationships of each part of the query statement, and the syntax tree structure is easy to analyze and optimize, and can accurately represent the query intent corresponding to the query statement.

[0156] In some embodiments, parsing can be implemented by a parser, such as a recursive descent parser, a left-to-right rightmost derivation (LR) parser, or by other means, which are not limited in this application.

[0157] In some embodiments, the aggregation in step 105 may include at least one of summation, counting, averaging, finding the maximum value, finding the minimum value, and grouping. Thus, these aggregations enable corresponding operations to be performed on the data resources to obtain query results.

[0158] In some embodiments, the aggregation in step 105 can also be a custom aggregation calculation, such as calculating the sum of resources requested by the central processing unit (CPU) of each namespace.

[0159] In one example, the following query can retrieve the total CPU resource requests for each namespace:

[0160] SELECT namespace, / / Select the namespace column;

[0161] SUM(containers.resources.requests.cpu) / / Calculates the total number of CPU resource requests;

[0162] FROM pods / / Query from container group;

[0163] GROUP BY namespace; / / Group statistics by namespace.

[0164] In some embodiments, step 103 may include at least one of the following: step a, generating a first application programming interface (API) request based on a first node in the syntax tree structure; step b, generating a second API request based on a second node in the syntax tree structure; step c, if a third node in the syntax tree structure includes a field associated with a first field, converting the third node into a first filter parameter and using the first filter parameter as a query parameter of the first API request; step d, if a third node in the syntax tree structure includes a field associated with a second field, converting the third node into a second filter parameter and using the second filter parameter as a query parameter of the second API request.

[0165] In some embodiments, the first application programming interface request in step a can be used to obtain first resource data corresponding to the first field included in the first node, where the first field is used to characterize a resource of a first type. In some embodiments, the first node can be used to represent a resource clause in a query statement. In one embodiment, the resource clause can be a FromClause clause. In one embodiment, the resource clause can be other clauses used to specify the resource being queried, and this application embodiment does not limit this.

[0166] In some embodiments, for step a, the first field included in the first node of the syntax tree structure is mapped to the resource type of the container orchestration platform. Based on the resource type, the order, parameters and associated logic of the application programming interface (API) calls are determined. The order, parameters and associated logic of the API calls are assembled to generate a first API request.

[0167] In some embodiments, the second application programming interface request in step b can be used to obtain second resource data corresponding to the second field included in the second node, where the second field represents a second type of resource associated with the first type of resource. In some embodiments, the second type of resource and the first type of resource can be two different types of resources on a container orchestration platform. In some embodiments, the second node can be used to represent a resource join clause in a query statement. In one embodiment, the resource join clause can be a join clause, which can define associated resources and conditions. In one embodiment, the resource join clause can be other clauses used to associate other resources through join conditions, which is not limited in this application embodiment. In some embodiments, other resources can be resources associated with the resource represented by the first field in the resource clause, for example, other resources can be resources associated with the first type of resource.

[0168] In some embodiments, for step b, the second field included in the second node of the syntax tree structure is mapped to the resource type of the container orchestration platform. Based on the resource type, the order, parameters, and associated logic of the application programming interface (API) calls are determined. The order, parameters, and associated logic of the API calls are assembled to generate a second API request.

[0169] In some embodiments, the third node in step c can be used to represent a filter clause (also known as a conditional clause) in a query statement; the first filter parameter can be a parameter associated with a first application programming interface request. In one embodiment, the first filter parameter can be associated with a resource of a first type.

[0170] In some embodiments, for step c, if the third node in the syntax tree structure includes a field associated with the first field, the field associated with the first field included in the third node in the syntax tree structure can be converted into a first filter parameter usable by the Kubernetes application programming interface (API) using at least one of a tag selector, a field selector, and an owner reference. This first filter parameter is then used as a query parameter in the first API request. Thus, the generated first API request includes the first filter parameter, enabling the rapid retrieval of the first resource data subsequently through the first filter parameter.

[0171] In some embodiments, the second filtering parameter in step d can be a parameter associated with a second application programming interface request. In one embodiment, the second filtering parameter can be associated with a resource of the first type.

[0172] In some embodiments, for step d, if the third node in the syntax tree structure includes a field associated with the second field, the field associated with the second field included in the third node in the syntax tree structure can be converted into a second filter parameter usable by the Kubernetes application programming interface (API) using at least one of a tag selector, a field selector, or an owner reference. This second filter parameter is then used as a query parameter in the second API request. Thus, this query parameter ensures that the generated second API request includes the second filter parameter, enabling the rapid retrieval of the second resource data subsequently through the second filter parameter.

[0173] In some embodiments, if the third node in the syntax tree structure includes a field associated with the first field and a field associated with the second field, steps c and d above can be performed simultaneously.

[0174] In some embodiments, steps a to d above can be implemented individually or in combination, and this application embodiment does not limit this. For example, step a can be implemented individually. For example, step b can be implemented individually. For example, steps a and b can be combined. For example, steps a and c can be combined. For example, steps b and d can be combined. For example, steps a, b, and c can be combined. For example, steps a, b, c, and d can be combined, but are not limited thereto.

[0175] In some embodiments, step a may include: obtaining a first parameter associated with a first field; mapping the first field to a first target field corresponding to a container orchestration platform; and generating a first application programming interface request based on the first parameter and the first target field.

[0176] Here, at least one node can be a third node or other nodes. The conditional expression corresponding to at least one node can be one or more conditional expressions associated with the first field included in a conditional clause or other clause. The first target field is used to characterize the first target resource type. The first target resource type can be the resource type obtained when mapping the resource of the first type to a resource type in Kubernetes based on the mapping relationship between the resource of the first type and the resource type in Kubernetes. The mapping relationship between the resource of the first type and the resource type in Kubernetes can be determined by a custom method or by other methods, and this embodiment of the application does not limit this.

[0177] In some embodiments, the first type of resource can be a resource indicated by a table name identifier in a syntax tree structure. For example, if one of the child nodes in the syntax tree structure includes a table name identifier called Pods, then the first type of resource is the container group indicated by Pods.

[0178] In some embodiments, the first target field can be a field corresponding to a resource type in Kubernetes. If the resource indicated by the first field is pods, and the resource type obtained when mapping pods to a resource type in Kubernetes is v1.Pod, then the first target field can be a field corresponding to v1.Pod.

[0179] In one example, the first node is used to represent the source clause in the query statement. After processing the source clause, the generated first application programming interface request can be: GET / api / v1 / namespaces / {namespace} / pods.

[0180] Understandably, by traversing each conditional expression in the conditional clause or other clauses, a predicate converter can identify the constituent elements of each conditional expression, such as the left-hand side field, operators, and right-hand side values. This allows the extraction of the first parameter associated with the first field from the conditional expression corresponding to at least one node in the syntax tree structure. Then, using a resource mapper, based on the mapping relationship between the first type of resource and resource types in Kubernetes, the first type of resource is mapped to the resource type in Kubernetes. The field corresponding to the Kubernetes resource type obtained after mapping is the first target field. Thus, the first target field corresponding to the container orchestration platform is obtained. Finally, by concatenating the first parameter and the first target field, the Uniform Resource Locator (URL) for the first application programming interface (API) request is obtained. Therefore, the first resource data can be obtained through the URL requested by the first API.

[0181] In some embodiments, step b may include: obtaining a second parameter associated with the second field; mapping the second field to a second target field corresponding to the container orchestration platform; and generating a second application programming interface request based on the second parameter and the second target field.

[0182] Here, the second target field is used to characterize the second target resource type. The second target resource type can be the resource type obtained when mapping the second type of resource to a resource type in Kubernetes based on the mapping relationship between the second type of resource and the resource type in Kubernetes. The mapping relationship between the second type of resource and the resource type in Kubernetes can be determined in a custom way or in other ways, and this embodiment of the application does not limit it.

[0183] In some embodiments, the second type of resource can be a resource indicated by a table name identifier in a syntax tree structure. For example, if one of the child nodes in the syntax tree structure includes a table name identifier called Deployments, then the second type of resource is a deployment indicated by Deployments.

[0184] Understandably, by traversing each conditional expression in the conditional clauses or other clauses, a predicate converter can identify the constituent elements of each conditional expression, such as the left-hand side field, operators, and right-hand side values. This allows the extraction of the second parameter associated with the second field from the conditional expression corresponding to at least one node in the syntax tree structure. Then, using a resource mapper, based on the mapping relationship between the second type of resource and resource types in Kubernetes, the second type of resource is mapped to the resource type in Kubernetes. The field corresponding to the Kubernetes resource type obtained after mapping is the second target field. Thus, the second target field corresponding to the container orchestration platform is obtained. Finally, by concatenating the second parameter and the second target field, the URL of the second application programming interface (API) request can be obtained. Therefore, the second resource data can be retrieved through the URL requested by the second API.

[0185] In some embodiments, the conditional clause is: WHERE Pods.namespace = 'production' AND Deployments.status_ready = true. Recognizing the conditional expression Pods.namespace = 'production' using a predicate converter yields the following JSON document:

[0186] {

[0187] "resource": "pods", / / Resource type: Pod resources

[0188] "field_path": "metadata.namespace", / / Field path: Namespace field in metadata (metadata.namespace)

[0189] "operator": "=", / / Operator: equals

[0190] "value": "production", / / Value: Production environment

[0191] "api_support": "fieldSelector" / / API supported type: field selector

[0192] }

[0193] In some embodiments, step 104 may include: step e, obtaining first resource data by requesting a first application programming interface and obtaining second resource data by requesting a second application programming interface through the application programming interface of the container orchestration platform; step f, matching the first resource data and the second resource data according to the association conditions in the second node to obtain third resource data that meets the association conditions.

[0194] Understandably, after receiving the first and second application programming interface (API) requests, the container orchestration platform's API, based on the first API request, accesses the API server associated with the container orchestration platform to obtain the first resource data corresponding to the first field. Similarly, the container orchestration platform's API, based on the second API request, accesses the API server associated with the container orchestration platform to obtain the second resource data corresponding to the second field. Then, based on the association conditions in the second node, an association matching strategy can be determined. Using this strategy, the first and second resource data are matched to obtain the third resource data that satisfies the association conditions. Thus, the above method allows for the rapid acquisition of resource data that meets the association conditions, improving the efficiency of resource querying.

[0195] In some embodiments, step f above may include: converting the association conditions in the second node into an association matching strategy corresponding to the container orchestration platform; and performing association matching on the first resource data and the second resource data based on the association matching strategy.

[0196] In some embodiments, by processing the resource connection clause represented by the second node through the connection processor, an association matching strategy corresponding to the container orchestration platform can be obtained. This association matching strategy can realize the association matching between the first resource data and the second resource data. For example, it can be matched based on association relationships such as tag selectors and owner references.

[0197] In some embodiments, owner references can be used to establish associations between different types of resources, such as the association between a pod and a deployment. In some embodiments, tag selectors can also be used to establish associations between different types of resources, such as the association between a service and a pod, the association between a deployment and a pod, and the association between an ingress resource and a service.

[0198] In one embodiment, if the association matching strategy is tag-based association, when the association is tag selector-based matching, the tag values ​​of the first resource data and the second resource data can be extracted, and then the first resource data and the second resource data can be associated and matched based on their tag values ​​to obtain the third resource data that meets the association conditions.

[0199] In one embodiment, if the association matching strategy is ownership-based association, and the association is owner reference-based matching, the first resource data and the second resource data can be matched based on the association relationship between different types of resources established by the owner reference to obtain the third resource data that meets the association conditions.

[0200] In some embodiments, the association matching of the first resource data and the second resource data can be implemented by a hash join algorithm or other algorithms. In one embodiment, implementing the association matching of the first resource data and the second resource data based on the hash join algorithm may include: constructing a hash table in memory for the one with a smaller data volume, traversing the other with a larger data volume, searching the hash table using the join key, and merging the matching rows into the final result, which is the third resource data.

[0201] Understandably, processing the resource join clause represented by the second node transforms the association conditions within it into an association matching strategy corresponding to the container orchestration platform. This strategy, using a hash join algorithm or other algorithms, allows for the association matching of the first and second resource data. Thus, by performing association matching on the first and second resource data in this manner, third resource data that satisfies the association conditions can be obtained, enabling the retrieval of query results across resource types.

[0202] In some embodiments, after step 102, the method may further include: step g, performing a validity check on the resource type corresponding to at least one node in the syntax tree structure and the fields associated with the resource type; step h, determining that the syntax tree structure passes the validity check if the resource type corresponding to at least one node is valid and the fields associated with the resource type are valid.

[0203] Understandably, after constructing the syntax tree structure corresponding to the query statement, to ensure the semantic validity of the syntax tree structure, it is necessary to perform a validity check on the resource type corresponding to at least one node in the syntax tree structure and the fields associated with the resource type. Specifically, this involves determining whether the resource type corresponding to at least one node is a resource type existing in the container orchestration platform cluster, whether the fields associated with the resource type corresponding to at least one node are fields associated with resource types included in the container orchestration platform cluster, and whether at least two fields associated with the resource type included in the association conditions of at least one node are related. If it is determined that the resource type corresponding to at least one node is a resource type existing in the container orchestration platform cluster, the fields associated with the resource type corresponding to at least one node are fields associated with resource types included in the container orchestration platform cluster, and at least two fields associated with the resource type included in the association conditions of at least one node are related, then the resource type corresponding to at least one node is valid, and the fields associated with the resource type are valid. At this point, the syntax tree structure can be determined to have passed the validity check. Thus, through the above process, the semantic validity of the syntax tree structure can be ensured, preventing subsequent converted application programming interface requests from being invalid.

[0204] In some embodiments, if at least one of the resource type corresponding to at least one node, or at least one of the fields associated with the resource type, is invalid, it indicates that the syntax tree structure has failed the validity check. In this case, an error message can be displayed in the code to prompt the user to check or correct the query statement.

[0205] In some embodiments, step g may include: matching the resource type corresponding to at least one node with the resource types included in the cluster of the container orchestration platform to determine whether the resource type corresponding to at least one node is valid; matching the fields associated with the resource type corresponding to at least one node with the fields associated with the resource types included in the cluster of the container orchestration platform to determine whether the fields associated with the resource type corresponding to at least one node are valid; and performing logical verification on at least two fields associated with the resource type included in the association conditions of at least one node to determine whether the fields associated with the resource type are valid.

[0206] Understandably, by matching the resource type corresponding to at least one node with the resource types included in the container orchestration platform cluster, it can be determined whether the resource type corresponding to at least one node is a resource type existing in the container orchestration platform cluster, thereby determining whether the resource type corresponding to at least one node is valid. If the resource type corresponding to at least one node is a resource type existing in the container orchestration platform cluster, then the resource type corresponding to at least one node is valid; if the resource type corresponding to at least one node is not a resource type existing in the container orchestration platform cluster, then the resource type corresponding to at least one node is invalid. In this way, resource types can be validated to ensure their validity.

[0207] In one embodiment, the validity of the resource type corresponding to the resource clause and resource join clause can be determined by checking whether the resource type (such as Pods or Deployments) exists in the Kubernetes cluster.

[0208] Understandably, by matching the fields associated with the resource type of at least one node with the fields associated with resource types included in the container orchestration platform cluster, it can be determined whether the fields associated with the resource type of at least one node are the same as those associated with resource types included in the container orchestration platform cluster, thus determining whether the fields associated with the resource type of at least one node are valid. If the fields associated with the resource type of at least one node are the same as those associated with resource types included in the container orchestration platform cluster, then the fields associated with the resource type of at least one node are valid; if the fields associated with the resource type of at least one node are not the same as those associated with resource types included in the container orchestration platform cluster, then the fields associated with the resource type of at least one node are invalid. In this way, the existence of fields can be verified, ensuring the validity of the fields.

[0209] In some embodiments, the fields associated with resource types included in the cluster of the container orchestration platform can be obtained through the interface of the container orchestration platform.

[0210] In one embodiment, the fields associated with resource types included in the Kubernetes cluster can be obtained through the Kubernetes interface. Then, the fields in the selection clause and conditional clause, such as Pods.name and Deployments.spec_template_label_app, can be verified to see if they are fields associated with resource types included in the Kubernetes cluster. In this way, it can be determined whether the above fields belong to the API objects of resources in the Kubernetes cluster.

[0211] Understandably, by performing logical validation on at least two fields associated with resource types included in the association conditions of at least one node, it is possible to determine whether these at least two fields are associated with resource types, and thus whether they are valid. If at least two fields associated with resource types in the association conditions of at least one node are associated, then these at least two fields are valid; if they are not associated, then these at least two fields are invalid. In this way, validation of fields associated with resource types can ensure that these fields are associated.

[0212] In one embodiment, by examining the fields in the resource join clause that are associated with the resource type, it can be determined whether these fields are associated. Thus, it can be determined whether the fields associated with the resource type conform to the association logic.

[0213] The system used to implement the above resource query method is described below.

[0214] Figure 2 This is an architecture diagram of a system for implementing a resource query method, according to an exemplary embodiment. For example... Figure 2 As shown, mainly for Figure 1 The components involved in the resource query process in the embodiments are described.

[0215] In some embodiments, Figure 2 The system may include, but is not limited to, the following components: a syntax parser 201, a predicate converter 202, a connection processor 203, a resource mapper 204, an API converter 205, an API server 206, and a result aggregation engine 207.

[0216] In some embodiments, the syntax parser 201 can convert the string in the query statement into a sequence of tokens. In some embodiments, the predicate converter 202 can identify the components of each conditional expression and convert the conditional expressions into resource fields in Kubernetes. In some embodiments, the join processor 203 can implement the association logic between different types of resources. In some embodiments, the resource mapper 204 can map resources (such as resources of a first type, resources of a second type) associated with at least one node in the syntax tree structure to resource types in Kubernetes. In some embodiments, the API converter 205 can convert the syntax tree structure into at least one application programming interface request. In some embodiments, resource data associated with at least one type of resource to be queried in the query statement can be obtained through the API server 206. In some embodiments, the result aggregation engine 207 can perform aggregation on the resource data to obtain the query results corresponding to the query statement.

[0217] It should be noted that, Figure 2 The components included are for illustrative purposes only and are not intended to limit the scope of the invention.

[0218] Based on the same inventive concept, embodiments of this application provide a resource query device to execute the above-described resource query method. Figure 3 This is a block diagram illustrating a resource query apparatus according to an exemplary embodiment. Figure 3 As shown, the device mainly includes: a first acquisition module 301, used to acquire a query statement, wherein the query statement is used to query at least one type of resource on the container orchestration platform; a construction module 302, used to construct a syntax tree structure corresponding to the query statement, wherein the nodes in the syntax tree structure are used to represent the clauses corresponding to the query statement; a conversion module 303, used to convert the syntax tree structure into at least one application programming interface request; a second acquisition module 304, used to acquire resource data associated with at least one type of resource based on at least one application programming interface request; and an aggregation module 305, used to perform aggregation on the resource data to obtain the query result corresponding to the query statement.

[0219] In some embodiments, the conversion module 303 includes at least one of the following: a first generation unit, configured to generate a first application programming interface (API) request based on a first node in a syntax tree structure, wherein the first node represents a resource clause, the first API request is used to obtain first resource data corresponding to a first field included in the first node, and the first field represents a resource of a first type; a second generation unit, configured to generate a second API request based on a second node in a syntax tree structure, wherein the second node represents a resource join clause, the second API request is used to obtain second resource data corresponding to a second field included in the second node, and the second field represents a resource of a second type associated with the resource of the first type; a first conversion unit, configured to convert a third node in the syntax tree structure into a first filter parameter when the third node includes a field associated with the first field, and use the first filter parameter as a query parameter of the first API request, wherein the third node represents a filter clause; and a second conversion unit, configured to convert a third node into a second filter parameter when the third node includes a field associated with the second field, and use the second filter parameter as a query parameter of the second API request.

[0220] In some embodiments, the first generation unit is configured to perform the following steps: obtain a first parameter associated with a first field; map the first field to a first target field corresponding to a container orchestration platform; and generate a first application programming interface request based on the first parameter and the first target field.

[0221] In some embodiments, the second generation unit is configured to perform the following steps: obtain a second parameter associated with the second field; map the second field to a second target field corresponding to the container orchestration platform; and generate a second application programming interface request based on the second parameter and the second target field.

[0222] In some embodiments, the second acquisition module 304 includes: an acquisition unit, configured to acquire first resource data according to a first application programming interface request and acquire second resource data according to a second application programming interface request via the application programming interface of the container orchestration platform; and a matching unit, configured to perform association matching on the first resource data and the second resource data according to the association conditions in the second node to obtain third resource data that satisfies the association conditions.

[0223] In some embodiments, the matching unit is configured to perform the following steps: converting the association conditions in the second node into an association matching strategy corresponding to the container orchestration platform; and performing association matching on the first resource data and the second resource data based on the association matching strategy.

[0224] In some embodiments, the apparatus further includes a checking module, configured to perform a validity check on the resource type corresponding to at least one node in the syntax tree structure and the fields associated with the resource type after constructing the syntax tree structure corresponding to the query statement; and a determining module, configured to determine that the syntax tree structure passes the validity check if the resource type corresponding to at least one node is valid and the fields associated with the resource type are valid.

[0225] In some embodiments, the inspection module is configured to perform the following steps: matching the resource type corresponding to at least one node with the resource types included in the cluster of the container orchestration platform to determine whether the resource type corresponding to at least one node is valid; matching the fields associated with the resource type corresponding to at least one node with the fields associated with the resource types included in the cluster of the container orchestration platform to determine whether the fields associated with the resource type corresponding to at least one node are valid; and performing logical verification on at least two fields associated with the resource type included in the association conditions of at least one node to determine whether the fields associated with the resource type are valid.

[0226] In some embodiments, the construction module 302 is configured to perform the following steps: perform lexical analysis on the query statement to obtain the tag sequence corresponding to the query statement; and convert the tag sequence into a syntax tree structure according to the syntax rules.

[0227] In some embodiments, aggregation includes at least one of summation, counting, averaging, finding the maximum value, finding the minimum value, and grouping.

[0228] Regarding the apparatus in the above embodiments, the specific manner in which each module performs its operation has been described in detail in the embodiments related to the method, and will not be elaborated upon here.

[0229] Based on the same inventive concept, embodiments of this application provide an electronic device that can be used to implement the above-described resource query method. Figure 4 This is a structural block diagram illustrating an electronic device 400 according to an exemplary embodiment. For example, the electronic device 400 may be a mobile phone, computer, digital broadcasting terminal, messaging device, tablet device, medical device, fitness equipment, personal digital assistant, etc.

[0230] Reference Figure 4 The electronic device 400 may include one or more of the following components: processing component 402, memory 404, power supply component 406, multimedia component 408, audio component 410, input / output (I / O) interface 412, sensor component 414, and communication component 416.

[0231] Processing component 402 typically controls the overall operation of electronic device 400, such as operations associated with at least one of display, telephone call, data communication, camera operation, and recording operation. Processing component 402 may include one or more processors 420 to execute instructions to perform all or part of the steps of the methods described above. Furthermore, processing component 402 may include one or more modules to facilitate interaction between processing component 402 and other components. For example, processing component 402 may include a multimedia module to facilitate interaction between multimedia component 408 and processing component 402.

[0232] Memory 404 is configured to store various types of data to support operation on electronic device 400. Examples of such data include at least one of the following: instructions for any application or method operating on electronic device 400, contact data, phonebook data, messages, pictures, and videos. Memory 404 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk.

[0233] Power supply component 406 provides power to various components of electronic device 400. Power supply component 406 may include at least one of the following: a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to electronic device 400.

[0234] Multimedia component 408 includes a screen that provides an output interface between electronic device 400 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touchscreen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensors may sense not only the boundaries of touch or swipe actions but also the duration and pressure associated with the touch or swipe operation. In some embodiments, multimedia component 408 includes a front-facing camera and / or a rear-facing camera. When electronic device 400 is in an operating mode, such as a shooting mode or video mode, the front-facing camera and / or rear-facing camera may receive external multimedia data. Each front-facing camera and rear-facing camera may be a fixed optical lens system or have focal length and optical zoom capabilities.

[0235] Audio component 410 is configured to output and / or input audio signals. For example, audio component 410 includes a microphone (MIC) configured to receive external audio signals when electronic device 400 is in an operating mode, such as call mode, recording mode, and voice recognition mode. The received audio signals may be further stored in memory 404 or transmitted via communication component 416. In some embodiments, audio component 410 also includes a speaker for outputting audio signals.

[0236] I / O interface 412 provides an interface between processing component 402 and peripheral interface modules, such as keyboards, click wheels, and buttons. These buttons may include, but are not limited to, home buttons, volume buttons, power buttons, and lock buttons.

[0237] Sensor assembly 414 includes one or more sensors for providing state assessments of various aspects of electronic device 400. For example, sensor assembly 414 may detect the on / off state of electronic device 400, the relative positioning of components such as the display and keypad of electronic device 400, changes in position of electronic device 400 or one of its components, the presence or absence of user contact with electronic device 400, orientation or acceleration / deceleration of electronic device 400, and temperature changes of electronic device 400. Sensor assembly 414 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. Sensor assembly 414 may also include an optical sensor, such as a complementary metal oxide semiconductor (CMOS) or charge coupled device (CCD) image sensor, for use in imaging applications. In some embodiments, sensor assembly 414 may also include, but is not limited to, at least one of the following: an accelerometer, a gyroscope, a magnetometer, a pressure sensor, and a temperature sensor.

[0238] Communication component 416 is configured to facilitate wired or wireless communication between electronic device 400 and other devices. Electronic device 400 can access wireless networks based on communication standards, such as Wi-Fi, 4G, 5G, or combinations thereof. In one exemplary embodiment, communication component 416 receives broadcast signals or broadcast-related information from an external broadcast management system via a broadcast channel. In one exemplary embodiment, communication component 416 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module may be implemented based on radio frequency identification (RFID), infrared data association (IrDA), ultra-wideband (UWB), Bluetooth (BT), and other technologies.

[0239] In an exemplary embodiment, the electronic device 400 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components.

[0240] This application provides a computer-readable storage medium storing a computer program or computer-executable instructions. When the computer program or executable instructions are executed by a processor, the processor performs the methods described in this application embodiment, for example... Figure 1 The resource query method is shown.

[0241] This application provides a computer program product comprising a computer program or computer-executable instructions stored in a computer-readable storage medium. A processor of an electronic device reads the computer program or executable instructions from the computer-readable storage medium and executes the computer program or executable instructions, causing the electronic device to perform the method described in this application.

[0242] In some embodiments, the computer-readable storage medium may be a memory such as RAM, ROM, PROM, EPROM, EEPROM, flash memory, magnetic surface memory, optical disc, or compact disc read-only memory (CD-ROM); or it may be a variety of devices including one or any combination of the above-mentioned memories.

[0243] In some embodiments, computer-executable instructions may take the form of programs, software, software modules, scripts, or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including as stand-alone programs or as modules, components, subroutines, or other units suitable for use in a computing environment.

[0244] As an example, computer-executable instructions may, but do not necessarily, correspond to files in a file system. They may be stored as part of a file that holds other programs or data, for example, in one or more scripts in a Hypertext Markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple co-located files (e.g., files that store one or more modules, subroutines, or code sections).

[0245] As an example, computer-executable instructions can be deployed to execute on a single computing device, or on multiple computing devices located in one location, or on multiple computing devices distributed across multiple locations and interconnected via a communication network.

[0246] Based on the same inventive concept, this application provides a server that can be used to implement the above-described resource query method. Figure 5 This is a block diagram illustrating a server 500 according to an exemplary embodiment. (Refer to...) Figure 5 Server 500 includes processing component 522, which further includes one or more processors, and memory resources represented by memory 532 for storing instructions, such as applications, that can be executed by processing component 522. The applications stored in memory 532 may include one or more modules, each corresponding to a set of instructions. Furthermore, processing component 522 is configured to execute instructions to perform any of the resource query methods described above.

[0247] Server 500 may also include a power supply component 526 configured to perform power management of server 500, a wired or wireless network interface 550 configured to connect server 500 to a network, and an input / output (I / O) interface 558. Server 500 can operate an operating system stored in memory 532, such as Windows Server™, Mac OSX™, Unix™ Linux™, FreeBSD™, or similar.

[0248] The above description is merely an embodiment of this application and is not intended to limit the scope of protection of this application. Any modifications, equivalent substitutions, and improvements made within the spirit and scope of this application are included within the scope of protection of this application.

[0249] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the embodiments disclosed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein. The specification and embodiments are to be considered exemplary only, and the true scope and spirit of this application are indicated by the claims.

[0250] It should be understood that this application is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this application is limited only by the appended claims.

Claims

1. A resource query method, characterized in that, The method includes: Obtain a query statement, wherein the query statement is used to query at least one type of resource on the container orchestration platform; Construct a syntax tree structure corresponding to the query statement, wherein the nodes in the syntax tree structure are used to represent the clauses corresponding to the query statement; Convert the syntax tree structure into at least one application programming interface request; Based on the at least one application programming interface, request to obtain resource data associated with the at least one type of resource; Aggregate the resource data to obtain the query results corresponding to the query statement.

2. The method according to claim 1, characterized in that, The step of converting the syntax tree structure into at least one application programming interface request includes at least one of the following: A first application programming interface request is generated based on the first node in the syntax tree structure, wherein the first node is used to represent a resource clause, and the first application programming interface request is used to obtain first resource data corresponding to the first field included in the first node, wherein the first field is used to characterize a first type of resource. A second application programming interface request is generated based on the second node in the syntax tree structure, wherein the second node is used to represent a resource join clause, and the second application programming interface request is used to obtain the second resource data corresponding to the second field included in the second node, wherein the second field is used to characterize the second type of resource associated with the first type of resource; If the third node in the syntax tree structure includes a field associated with the first field, the third node is converted into a first filter parameter, and the first filter parameter is used as a query parameter of the first application programming interface request, wherein the third node is used to represent a filter clause; If the third node includes a field associated with the second field, the third node is converted into a second filter parameter, and the second filter parameter is used as a query parameter for the second application programming interface request.

3. The method according to claim 2, characterized in that, The step of generating a first application programming interface request based on the first node in the syntax tree structure includes: Retrieve the first parameter associated with the first field; Map the first field to the first target field corresponding to the container orchestration platform; The first application programming interface request is generated based on the first parameter and the first target field.

4. The method according to claim 2, characterized in that, The step of generating a second application programming interface request based on the second node in the syntax tree structure includes: Retrieve the second parameter associated with the second field; Map the second field to the second target field corresponding to the container orchestration platform; The second application programming interface request is generated based on the second parameter and the second target field.

5. The method according to claim 2, characterized in that, The request to obtain resource data associated with the at least one type of resource based on the at least one application programming interface includes: The container orchestration platform uses its application programming interface (API) to request the first resource data and the second resource data according to the second API request. Based on the association conditions in the second node, the first resource data and the second resource data are associated and matched to obtain the third resource data that meets the association conditions.

6. The method according to claim 5, characterized in that, The step of associating and matching the first resource data and the second resource data according to the association conditions in the second node includes: The association conditions in the second node are converted into the association matching strategy corresponding to the container orchestration platform; Based on the association matching strategy, the first resource data and the second resource data are associated and matched.

7. The method according to claim 1, characterized in that, After constructing the syntax tree structure corresponding to the query statement, the method further includes: Perform a validity check on the resource type corresponding to at least one node in the syntax tree structure and the fields associated with the resource type; If the resource type corresponding to at least one node is valid and the fields associated with the resource type are valid, the syntax tree structure is determined to have passed the validity check.

8. A resource query device, characterized in that, The device includes: The first acquisition module is used to acquire a query statement, wherein the query statement is used to query at least one type of resource on the container orchestration platform; A construction module is used to construct a syntax tree structure corresponding to the query statement, wherein the nodes in the syntax tree structure are used to represent clauses corresponding to the query statement; A conversion module is used to convert the syntax tree structure into at least one application programming interface request; The second acquisition module is used to request and acquire resource data associated with the at least one type of resource based on the at least one application programming interface; The aggregation module is used to perform aggregation on the resource data to obtain the query results corresponding to the query statement.

9. An electronic device, characterized in that, include: processor; Memory used to store computer programs or instructions; The processor executes the computer program or instructions to implement the steps of the method according to any one of claims 1 to 7.

10. A computer-readable storage medium storing a computer program or instructions, characterized in that, When the computer program or instructions are executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.