Chapter 1. Search
Learn about the Red Hat Advanced Cluster Management Search service. Use Search to query resource data from your clusters. See the following documentation:
1.1. Search service Copy linkLink copied to clipboard!
For Red Hat Advanced Cluster Management for Kubernetes, search provides visibility into your Kubernetes resources across all of your clusters. Search also indexes the Kubernetes resources and the relationships to other resources.
Search is configured by default on the hub cluster. When you provision or manually import a managed cluster, the klusterlet-addon-search is enabled.
1.1.1. Search components Copy linkLink copied to clipboard!
The search architecture is composed of the following components:
| Component name | Metrics | Metric type | Description |
|---|---|---|---|
|
|
Watches the Kubernetes resources, collects the resource metadata, computes relationships for resources across all of your managed clusters, and sends the collected data to the | ||
|
Receives resource metadata from the collectors and writes to PostgreSQL database. The |
| Histogram | Time (seconds) the search indexer takes to process a request (from managed cluster). |
|
| Histogram | Total changes (add, update, delete) in the search indexer request (from managed cluster). | |
|
| Counter | Total requests received by the search indexer (from managed clusters). | |
|
| Gauge | Total requests the search indexer is processing at a given time. | |
|
Provides access to all cluster data in the |
| Histogram | Histogram of HTTP requests duration in seconds. |
|
| Histogram | Latency of database requests in seconds. | |
|
| Counter | The total number of database connection attempts that failed. | |
|
| Stores collected data from all managed clusters in an instance of the PostgreSQL database. |
1.1.2. Search operations and data types Copy linkLink copied to clipboard!
Specify your search query by using search operations as conditions. Characters such as >, >=, <, <=, != are supported. See the following search operation table:
| Default operation | Data type | Description |
|---|---|---|
|
| string, number | This is the default operation. |
|
| string, number | This represents the NOT operation, which means to exclude from the search results. |
|
| number | |
|
| date | Dates matching the last hour, day, week, month, and year. |
|
| string | Partial string match. |
1.1.3. Additional resources Copy linkLink copied to clipboard!
- For more topics about the Red Hat Advanced Cluster Management for Kubernetes console, see Web console.
- If you want to disable the Search service on your managed cluster, see Modifying the klusterlet add-ons settings of your cluster for more information.
1.2. Creating search configurable collection Copy linkLink copied to clipboard!
Define which Kubernetes resources are collected from the cluster by creating a search-collector-config config map for each managed cluster where you want to customize the resources that search collects.
Required access: Cluster administrator
Place the config map in the same namespace where the search add-on is deployed. The default namespace is open-cluster-management-agent-addon.
Complete the following steps:
Run the following command to create the
search-collector-configconfig map:oc apply -f <your-search-collector-config>.yaml
oc apply -f <your-search-collector-config>.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow List the resources in the allow (
data.AllowedResources) and deny list (data.DeniedResources) sections within the config map. Your config map might resemble the following YAML file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- The previous config map example displays
servicesandpodsto be collected from allapiGroups, while allowing all resources to be collected from theadmission.k8s.ioandauthentication.k8s.ioapiGroups. - 2
- The config map example also prevents the central collection of
secretsfrom allapiGroupswhile preventing the collection ofpolicies,iampolicies, andcertificatepoliciesfrom theapiGroupadmission.k8s.io.
Note: If you do not provide a config map, all resources are collected by default. If you only provide
AllowedResources, all resources not listed inAllowedResourcesare automatically excluded. Resources listed inAllowedResourcesandDeniedResourcesat the same time are also excluded.
1.3. Customizing the Search service Copy linkLink copied to clipboard!
Customize the Search service to set up persistent storage, to fine-tune for performance and scalability, or to modify certain behaviors through environment variables. Access the search configuration options from the search operator which watches the search-v2-operator custom resource, reconciles the changes, and updates active pods.
Required access: Cluster administrator
Prerequisites
-
You must have access to the
open-cluster-managementnamespace.
Procedure
Complete the following steps to customize the Search service:
Modify the default values in the
search-v2-operatorcustom resource.To view details of the custom resource, run the following command:
oc get search search-v2-operator -n <acm-namespace> -o yaml
oc get search search-v2-operator -n <acm-namespace> -o yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Configure a persistent volume claim for your clusters that are in production. If the empty directory size is limited for your PostgreSQL database, save your PostgreSQL data on a persistent volume claim to improve search performance.
Notes:
-
When you install Red Hat Advanced Cluster Management, the PostgreSQL database is configured to save the PostgreSQL data in an empty directory (
emptyDir) volume. -
When a persistent volume claim is not configured, the
SearchPVCNotPresentalert is displayed in the Status pane.
-
When you install Red Hat Advanced Cluster Management, the PostgreSQL database is configured to save the PostgreSQL data in an empty directory (
- To persist your search data, select a storage class from your Red Hat Advanced Cluster Management hub cluster.
-
For example, create a persistent volume claim if you select the
gp2storageclass and mount the claim to thesearch-postgrespod. Your configuration might resemble the following example:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Modify the storage size if you need to. By default, the storage size is
10Gi. For example,20Gimight be sufficient for about 200 managed clusters.
Optimize cost by tuning the pod memory or CPU requirements, replica count, and update log levels for any of the four search pods:
indexer,database,queryapi, orcollector.-
Update the
deploymentsection of thesearch-v2-operatorcustom resource. There are four deployments managed by thesearch-v2-operator, which can be updated individually. -
Apply resources for the
indexer,database,queryapi, orcollectorpod. -
Add multiple environment variables in the
envVarsection to specify a value for each variable that you name. -
Specify a value for each variable that you name by adding multiple environment variables in the
envVarspecification. -
Add the
- -v=3argument for thequeryapispecification to control the log level verbosity for any of the four pods. Yoursearch-v2-operatorcustom resource might resemble the following file:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Update the
Apply memory resources for the
indexerpod. See the following example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Define the node placement for search pods.
-
Update the
Placementresource of search pods by using thenodeSelectorparameter, or thetolerationsparameter. View the following example configuration:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Update the
1.4. Customizing the console for Search Copy linkLink copied to clipboard!
Customize your console for Search to specify how you want data and search results to be displayed.
Required access: Cluster administrator
Prerequisites
-
You must have access to the
open-cluster-managementnamespace.
Procedure
Complete the following tasks to perform the customization:
Customize the search result limit from the OpenShift Container Platform console.
Update the
console-mce-configin themulticluster-enginenamespace. These settings apply to all users and might affect performance. View the following performance parameter descriptions:-
SAVED_SEARCH_LIMIT- The maximum amount of saved searches for each user. By default, there is a limit of ten saved searches for each user. The default value is10. To update the limit, add the following key value to theconsole-configconfig map:SAVED_SEARCH_LIMIT: x. -
SEARCH_RESULT_LIMIT- The maximum amount of search results displayed in the console. Default value is1000. To remove this limit set to-1. -
SEARCH_AUTOCOMPLETE_LIMIT- The maximum number of suggestions retrieved for the search bar typeahead. Default value is10,000. To remove this limit set to-1.
-
-
Change the search result to
100items by running the followingpatchcommand from the OpenShift Container Platform console:
oc patch configmap console-mce-config -n multicluster-engine --type merge -p '{"data":{"SEARCH_RESULT_LIMIT":"100"}}'oc patch configmap console-mce-config -n multicluster-engine --type merge -p '{"data":{"SEARCH_RESULT_LIMIT":"100"}}'Copy to Clipboard Copied! Toggle word wrap Toggle overflow To add, edit, or remove suggested searches, create a config map named
console-search-configand configure thesuggestedSearchessection. Suggested searches that are listed are also displayed from the console. It is required to have anid, name, and searchTextfor each search object.- Add the namespace where search is enabled. View the following config map example:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
1.4.1. Querying in the console Copy linkLink copied to clipboard!
You can type any text value in the Search box and results include anything with that value from any property, such as a name or namespace. Queries that contain an empty space are not supported.
As you search for resources, you receive other resources that are related to your original search result, which help you visualize how the resources interact with other resources in the system.
Required access: Cluster administrator
For more specific search results, include the property selector in your search. You can combine related values for the property for a more precise scope of your search. For example, search for cluster:dev red to receive results that match the string "red" in the dev cluster.
Procedure
Search returns and lists each cluster with the resource that you search. For resources in the hub cluster, the cluster name is displayed as local-cluster.
You can change the local-cluster name if the enabled field is set to false. You must use 34 or fewer characters for the <your-local-cluster-name> value. The local-cluster cannot be renamed if it is set as enabled: true.
Note: If you change the default name of your local-cluster to another value, the results appear within the changed local cluster name.
Your search results are grouped by kind, and each resource kind is grouped in a table. Search options depend on your cluster objects. Refine your results with specific labels.
Complete the following steps to make queries with search:
- Click Search in the navigation menu.
Type a word in the Search box, then Search finds your resources that contain that value.
Note: Search is case-sensitive when you query labels.
See the following examples that you can select for filtering:
name,namespace,status, and other resource fields. Auto-complete provides suggestions to refine your search. See the following example:-
Search for a single field, such as
kind:podto find all pod resources. Search for multiple fields, such as
kind:pod namespace:defaultto find the pods in the default namespace.Notes:
- When you search for more than one property selector with multiple values, the search returns either of the values that were queried. View the following examples:
-
When you search for
kind:Pod name:a, any pod namedais returned. -
When you search for
kind:Pod name:a,b, any pod namedaorbare returned. -
Search for
kind:pod status:!Runningto find all pod resources where the status is notRunning. -
Search for
kind:pod restarts:>1to find all pods that restarted at least twice.
-
Search for a single field, such as
- Specify your search query by selecting the Advanced search drop-down button to filter the Column, Operator, and Value options or add a search constraint.
- If you want to save your search, click the Save search icon.
- To download your search results, select the Export as CSV button.
1.5. Updating klusterlet-addon-search deployments Copy linkLink copied to clipboard!
To collect the Kubernetes objects from the managed clusters, the klusterlet-addon-search pod is run on all the managed clusters where search is enabled. This deployment is run in the open-cluster-management-agent-addon namespace. A managed cluster with a high number of resources might require more memory for the klusterlet-addon-search deployment to function.
Required access: Cluster administrator
Resource requirements for the klusterlet-addon-search pod in a managed cluster can be specified in the ManagedClusterAddon custom resource in your Red Hat Advanced Cluster Management hub cluster. There is a namespace for each managed cluster with the managed cluster name. Complete the following steps:
Edit the
ManagedClusterAddoncustom resource from the namespace matching the managed cluster name. Run the following command to update the resource requirement inxyzmanaged cluster:oc edit managedclusteraddon search-collector -n xyz
oc edit managedclusteraddon search-collector -n xyzCopy to Clipboard Copied! Toggle word wrap Toggle overflow Append the resource requirements as annotations. View the following example:
apiVersion: addon.open-cluster-management.io/v1alpha1 kind: ManagedClusterAddOn metadata: annotations: addon.open-cluster-management.io/search_memory_limit: 2048Mi addon.open-cluster-management.io/search_memory_request: 512Mi
apiVersion: addon.open-cluster-management.io/v1alpha1 kind: ManagedClusterAddOn metadata: annotations: addon.open-cluster-management.io/search_memory_limit: 2048Mi addon.open-cluster-management.io/search_memory_request: 512MiCopy to Clipboard Copied! Toggle word wrap Toggle overflow
The annotation overrides the resource requirements on the managed clusters and automatically restarts the pod with new resource requirements.
Note: You can discover all resources defined in your managed cluster by using the API Explorer in the console. Alternatively, you can discover all resources by running the following command: oc api-resources