Skip to content

Commit 992d26e

Browse files
committed
feat: design index policy API
Introduces a new API design document we can use for the search service. It includes the API design for the new Index Policy API we will use to configure which resources in the platform are indexed and made available for searching.
1 parent 74c6c73 commit 992d26e

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed

docs/api-design.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# API Design
2+
3+
The Search service provides APIs for searching resources and managing the
4+
resources available to search. Platform operators can quickly use this service
5+
to search for resources they need across the platform.
6+
7+
## Motivation
8+
9+
The platform supports quick and easy registration of resources though Custom
10+
Resource Definitions and API aggregation. Given this, it's important our search
11+
service can adjust dynamically at runtime to resources being indexed and
12+
searchable so it doesn't require software changes to index new resources.
13+
14+
## Goals
15+
16+
- Introduce a dynamic method of configuring which resources in the platform
17+
should be indexed and searchable
18+
- Enable platform operators to quickly search across resource types while also
19+
allowing field based selection to narrow the scope of the search
20+
- Support full-text search capabilities configurable through dynamic index
21+
policies
22+
23+
24+
## Proposal
25+
26+
The Search API will initially offer these new API resources to end-users:
27+
28+
- **ResourceIndexPolicy** configures which resources in the platform should be
29+
indexed and which fields within the resource are applicable to indexing
30+
- **ResourceSearchQuery** allows users to execute field filtering and full-text
31+
searching capabilities across all indexed resources
32+
33+
## Design Details
34+
35+
### Resource index policies
36+
37+
The `ResourceIndexPolicy` resource will be managed by platform operators to
38+
control which resources in the platform are made available to users. The search
39+
service will begin indexing a policies immediately after a policy is created.
40+
41+
> [!IMPORTANT]
42+
>
43+
> The system does not support AuthZ based policies to ensure users have access
44+
> to results returned by search queries. This API should only be used for
45+
> non-sensitive resources and for internal-use only.
46+
>
47+
> This service will be made multi-tenant friendly in the future.
48+
49+
The resource index policy will allow users to define the resource applicable to
50+
the index policy and filter resources using CEL expressions. Index policies will
51+
also allow users to configure which fields from the resource are indexed and how
52+
they're indexed (field filtering, full-text search, etc.)
53+
54+
Here's an example index policy that would configure search service to index all
55+
active organizations.
56+
57+
```yaml
58+
apiVersion: search.miloapis.com/v1alpha1
59+
kind: ResourceIndexPolicy
60+
metadata:
61+
name: organizations
62+
spec:
63+
targetResource:
64+
group: resourcemanager.miloapis.com
65+
version: v1alpha1
66+
kind: Organization
67+
conditions:
68+
# Only index organizations that are active
69+
- name: ready-only
70+
expression: status.conditions.exists(c, c.type == 'Ready' && c.status == 'True')
71+
fields:
72+
# Index the resource name
73+
- path: metadata.name
74+
searchable: true
75+
filterable: true
76+
# Index the description of the resource
77+
- path: metadata.annotations["kubernetes.io/description"]
78+
searchable: true
79+
filterable: true
80+
```
81+
82+
The index policy will used a versioned reference to resources since the field
83+
paths for resources may be different between versions. The system should monitor
84+
for deprecated resource versions being referenced in index policies.

0 commit comments

Comments
 (0)