Skip to content

Commit 3037f91

Browse files
authored
Merge pull request #3382 from mjudeikis/mjudeikis/cache.api
Add Cache API
2 parents 37664a9 + 4a07406 commit 3037f91

File tree

98 files changed

+7558
-20
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+7558
-20
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ ifdef SUITES
281281
SUITES_ARG = --suites $(SUITES)
282282
COMPLETE_SUITES_ARG = -args $(SUITES_ARG)
283283
endif
284-
TEST_FEATURE_GATES ?= WorkspaceMounts=true
284+
TEST_FEATURE_GATES ?= WorkspaceMounts=true,CacheAPIs=true
285285

286286
.PHONY: test-e2e
287287
ifdef USE_GOTESTSUM
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
apiVersion: apiextensions.k8s.io/v1
3+
kind: CustomResourceDefinition
4+
metadata:
5+
annotations:
6+
controller-gen.kubebuilder.io/version: v0.17.3
7+
name: cachedobjects.cache.kcp.io
8+
spec:
9+
group: cache.kcp.io
10+
names:
11+
categories:
12+
- kcp
13+
kind: CachedObject
14+
listKind: CachedObjectList
15+
plural: cachedobjects
16+
singular: cachedobject
17+
scope: Cluster
18+
versions:
19+
- additionalPrinterColumns:
20+
- jsonPath: .metadata.creationTimestamp
21+
name: Age
22+
type: date
23+
name: v1alpha1
24+
schema:
25+
openAPIV3Schema:
26+
description: CachedObject defines a resource that is cached in the cache.
27+
properties:
28+
apiVersion:
29+
description: |-
30+
APIVersion defines the versioned schema of this representation of an object.
31+
Servers should convert recognized schemas to the latest internal value, and
32+
may reject unrecognized values.
33+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
34+
type: string
35+
kind:
36+
description: |-
37+
Kind is a string value representing the REST resource this object represents.
38+
Servers may infer this from the endpoint the client submits requests to.
39+
Cannot be updated.
40+
In CamelCase.
41+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
42+
type: string
43+
metadata:
44+
type: object
45+
spec:
46+
description: CachedObjectSpec defines the desired state of CachedObject.
47+
properties:
48+
raw:
49+
type: object
50+
x-kubernetes-preserve-unknown-fields: true
51+
required:
52+
- raw
53+
type: object
54+
required:
55+
- spec
56+
type: object
57+
served: true
58+
storage: true
59+
subresources:
60+
status: {}
Lines changed: 226 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,226 @@
1+
---
2+
apiVersion: apiextensions.k8s.io/v1
3+
kind: CustomResourceDefinition
4+
metadata:
5+
annotations:
6+
controller-gen.kubebuilder.io/version: v0.17.3
7+
name: cachedresources.cache.kcp.io
8+
spec:
9+
group: cache.kcp.io
10+
names:
11+
categories:
12+
- kcp
13+
kind: CachedResource
14+
listKind: CachedResourceList
15+
plural: cachedresources
16+
singular: cachedresource
17+
scope: Cluster
18+
versions:
19+
- additionalPrinterColumns:
20+
- description: Resource type being published
21+
jsonPath: .spec.resource
22+
name: Resource
23+
type: string
24+
- jsonPath: .metadata.creationTimestamp
25+
name: Age
26+
type: date
27+
name: v1alpha1
28+
schema:
29+
openAPIV3Schema:
30+
description: CachedResource defines a resource that should be published to
31+
other workspaces
32+
properties:
33+
apiVersion:
34+
description: |-
35+
APIVersion defines the versioned schema of this representation of an object.
36+
Servers should convert recognized schemas to the latest internal value, and
37+
may reject unrecognized values.
38+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
39+
type: string
40+
kind:
41+
description: |-
42+
Kind is a string value representing the REST resource this object represents.
43+
Servers may infer this from the endpoint the client submits requests to.
44+
Cannot be updated.
45+
In CamelCase.
46+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
47+
type: string
48+
metadata:
49+
type: object
50+
spec:
51+
description: CachedResourceSpec defines the desired state of CachedResource.
52+
properties:
53+
group:
54+
description: |-
55+
group is the name of an API group.
56+
For core groups this is the empty string '""'.
57+
pattern: ^(|[a-z0-9]([-a-z0-9]*[a-z0-9](\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*)?)$
58+
type: string
59+
identity:
60+
description: |-
61+
identity points to a secret that contains the API identity in the 'key' file.
62+
The API identity allows access to CachedResource's resources via the APIExport.
63+
64+
Different CachedResource in a workspace can share a common identity, or have different
65+
ones. The identity (the secret) can also be transferred to another workspace
66+
when the ublishedResource is moved.
67+
68+
The identity is defaulted. A secret with the name of the CachedResource is automatically
69+
created.
70+
properties:
71+
secretRef:
72+
description: secretRef is a reference to a secret that contains
73+
the API identity in the 'key' file.
74+
properties:
75+
name:
76+
description: name is unique within a namespace to reference
77+
a secret resource.
78+
type: string
79+
namespace:
80+
description: namespace defines the space within which the
81+
secret name must be unique.
82+
type: string
83+
type: object
84+
x-kubernetes-map-type: atomic
85+
type: object
86+
labelSelector:
87+
description: LabelSelector is used to filter which resources should
88+
be published
89+
properties:
90+
matchExpressions:
91+
description: matchExpressions is a list of label selector requirements.
92+
The requirements are ANDed.
93+
items:
94+
description: |-
95+
A label selector requirement is a selector that contains values, a key, and an operator that
96+
relates the key and values.
97+
properties:
98+
key:
99+
description: key is the label key that the selector applies
100+
to.
101+
type: string
102+
operator:
103+
description: |-
104+
operator represents a key's relationship to a set of values.
105+
Valid operators are In, NotIn, Exists and DoesNotExist.
106+
type: string
107+
values:
108+
description: |-
109+
values is an array of string values. If the operator is In or NotIn,
110+
the values array must be non-empty. If the operator is Exists or DoesNotExist,
111+
the values array must be empty. This array is replaced during a strategic
112+
merge patch.
113+
items:
114+
type: string
115+
type: array
116+
x-kubernetes-list-type: atomic
117+
required:
118+
- key
119+
- operator
120+
type: object
121+
type: array
122+
x-kubernetes-list-type: atomic
123+
matchLabels:
124+
additionalProperties:
125+
type: string
126+
description: |-
127+
matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels
128+
map is equivalent to an element of matchExpressions, whose key field is "key", the
129+
operator is "In", and the values array contains only "value". The requirements are ANDed.
130+
type: object
131+
type: object
132+
x-kubernetes-map-type: atomic
133+
resource:
134+
description: |-
135+
resource is the name of the resource.
136+
Note: it is worth noting that you can not ask for permissions for resource provided by a CRD
137+
not provided by an api export.
138+
pattern: ^[a-z][-a-z0-9]*[a-z0-9]$
139+
type: string
140+
version:
141+
description: version is the version of the resource.
142+
type: string
143+
required:
144+
- resource
145+
type: object
146+
status:
147+
description: CachedResourceStatus defines the observed state of CachedResource.
148+
properties:
149+
conditions:
150+
description: Current processing state of the Workspace.
151+
items:
152+
description: Condition defines an observation of a object operational
153+
state.
154+
properties:
155+
lastTransitionTime:
156+
description: |-
157+
Last time the condition transitioned from one status to another.
158+
This should be when the underlying condition changed. If that is not known, then using the time when
159+
the API field changed is acceptable.
160+
format: date-time
161+
type: string
162+
message:
163+
description: |-
164+
A human readable message indicating details about the transition.
165+
This field may be empty.
166+
type: string
167+
reason:
168+
description: |-
169+
The reason for the condition's last transition in CamelCase.
170+
The specific API may choose whether or not this field is considered a guaranteed API.
171+
This field may not be empty.
172+
type: string
173+
severity:
174+
description: |-
175+
Severity provides an explicit classification of Reason code, so the users or machines can immediately
176+
understand the current situation and act accordingly.
177+
The Severity field MUST be set only when Status=False.
178+
type: string
179+
status:
180+
description: Status of the condition, one of True, False, Unknown.
181+
type: string
182+
type:
183+
description: |-
184+
Type of condition in CamelCase or in foo.example.com/CamelCase.
185+
Many .condition.type values are consistent across resources like Available, but because arbitrary conditions
186+
can be useful (see .node.status.conditions), the ability to deconflict is important.
187+
type: string
188+
required:
189+
- lastTransitionTime
190+
- status
191+
- type
192+
type: object
193+
type: array
194+
identityHash:
195+
description: IdentityHash is a hash of the identity configuration
196+
type: string
197+
phase:
198+
default: Initializing
199+
description: Phase of the workspace (Initializing, Ready, Unavailable).
200+
enum:
201+
- Scheduling
202+
- Initializing
203+
- Ready
204+
- Deleting
205+
- Deleted
206+
type: string
207+
resourceCounts:
208+
description: ResourceCount is the number of resources that match the
209+
label selector
210+
properties:
211+
cache:
212+
type: integer
213+
local:
214+
type: integer
215+
required:
216+
- cache
217+
- local
218+
type: object
219+
type: object
220+
required:
221+
- spec
222+
type: object
223+
served: true
224+
storage: true
225+
subresources:
226+
status: {}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: cache.kcp.io/v1alpha1
2+
kind: CachedResource
3+
metadata:
4+
name: instances
5+
spec:
6+
resource: instances
7+
group: machines.svm.io
8+
version: v1alpha1
9+
labelSelector:
10+
matchLabels:
11+
app.kubernetes.io/part-of: instances
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
apiVersion: apiextensions.k8s.io/v1
2+
kind: CustomResourceDefinition
3+
metadata:
4+
name: instances.machines.svm.io
5+
spec:
6+
group: machines.svm.io
7+
names:
8+
kind: Instance
9+
listKind: InstanceList
10+
plural: instances
11+
singular: instance
12+
shortNames:
13+
- inst
14+
scope: Cluster
15+
versions:
16+
- name: v1alpha1
17+
served: true
18+
storage: true
19+
schema:
20+
openAPIV3Schema:
21+
type: object
22+
properties:
23+
spec:
24+
type: object
25+
required:
26+
- instanceType
27+
- name
28+
- tier
29+
properties:
30+
instanceType:
31+
type: string
32+
description: The type of the instance (e.g. small, medium, large)
33+
name:
34+
type: string
35+
description: The name of the instance
36+
tier:
37+
type: string
38+
description: The tier of the instance (e.g. basic, premium)
39+
enum:
40+
- basic
41+
- premium
42+
- enterprise
43+
status:
44+
type: object
45+
properties:
46+
phase:
47+
type: string
48+
description: The current phase of the instance
49+
enum:
50+
- Pending
51+
- Running
52+
- Terminated
53+
conditions:
54+
type: array
55+
items:
56+
type: object
57+
properties:
58+
type:
59+
type: string
60+
status:
61+
type: string
62+
lastTransitionTime:
63+
type: string
64+
format: date-time
65+
reason:
66+
type: string
67+
message:
68+
type: string

0 commit comments

Comments
 (0)