Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions config/crds/apis.kcp.io_apiexports.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,8 @@ spec:
oneOf:
- required:
- crd
- required:
- virtual
properties:
crd:
description: |-
Expand All @@ -478,7 +480,48 @@ spec:
Like in vanilla Kubernetes, users can then create, update and delete
custom resources.
type: object
virtual:
description: |-
Virtual storage defines that this APIResourceSchema is exposed as
a projection of the referenced resource inside the workspaces that
bind to the APIExport.
properties:
identityHash:
description: IdentityHash is the identity of the virtual
resource.
type: string
reference:
description: |-
Reference points to another object that has a URL to a virtual workspace
in a "url" field in its status. The object can be of any kind.
properties:
apiGroup:
description: |-
APIGroup is the group for the resource being referenced.
If APIGroup is not specified, the specified Kind must be in the core API group.
For any other third-party types, APIGroup is required.
type: string
kind:
description: Kind is the type of resource being
referenced
type: string
name:
description: Name is the name of resource being
referenced
type: string
required:
- kind
- name
type: object
x-kubernetes-map-type: atomic
required:
- identityHash
- reference
type: object
type: object
x-kubernetes-validations:
- message: Exactly one of crd or virtual must be set
rule: has(self.crd) != has(self.virtual)
required:
- group
- name
Expand Down
1 change: 1 addition & 0 deletions config/crds/apis.kcp.io_apiexports.yaml-patch
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
path: /spec/versions/name=v1alpha2/schema/openAPIV3Schema/properties/spec/properties/resources/items/properties/storage/oneOf
value:
- required: ["crd"]
- required: ["virtual"]

# conversion for core resources does not happen via webhooks, but is short-circuited to the
# schema's Convert functions directly, but the CRD still needs to define a conversion.
Expand Down
57 changes: 57 additions & 0 deletions config/crds/cache.kcp.io_cachedresourceendpointslices.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ spec:
x-kubernetes-validations:
- message: CachedResource reference must not be changed
rule: self == oldSelf
partition:
description: |-
partition points to a partition that is used for filtering the endpoints
of the CachedResource part of the slice.
type: string
required:
- cachedResource
type: object
Expand All @@ -73,6 +78,52 @@ spec:
status communicates the observed state:
the filtered list of endpoints for the Replication service.
properties:
conditions:
description: conditions is a list of conditions that apply to the
CachedResourceEndpointSlice.
items:
description: Condition defines an observation of a object operational
state.
properties:
lastTransitionTime:
description: |-
Last time the condition transitioned from one status to another.
This should be when the underlying condition changed. If that is not known, then using the time when
the API field changed is acceptable.
format: date-time
type: string
message:
description: |-
A human readable message indicating details about the transition.
This field may be empty.
type: string
reason:
description: |-
The reason for the condition's last transition in CamelCase.
The specific API may choose whether or not this field is considered a guaranteed API.
This field may not be empty.
type: string
severity:
description: |-
Severity provides an explicit classification of Reason code, so the users or machines can immediately
understand the current situation and act accordingly.
The Severity field MUST be set only when Status=False.
type: string
status:
description: Status of the condition, one of True, False, Unknown.
type: string
type:
description: |-
Type of condition in CamelCase or in foo.example.com/CamelCase.
Many .condition.type values are consistent across resources like Available, but because arbitrary conditions
can be useful (see .node.status.conditions), the ability to deconflict is important.
type: string
required:
- lastTransitionTime
- status
- type
type: object
type: array
endpoints:
description: endpoints contains all the URLs of the Replication service.
items:
Expand All @@ -90,6 +141,12 @@ spec:
x-kubernetes-list-map-keys:
- url
x-kubernetes-list-type: map
shardSelector:
description: |-
shardSelector is the selector used to filter the shards. It is used to filter the shards
when determining partition scope when deriving the endpoints. This is set by owning shard,
and is used by follower shards to determine if its inscope or not.
type: string
type: object
type: object
served: true
Expand Down
36 changes: 0 additions & 36 deletions config/crds/cache.kcp.io_cachedresources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -216,42 +216,6 @@ spec:
- cache
- local
type: object
resourceSchemaSource:
description: ResourceSchemaSource is a reference to the schema object
of the cached resource.
properties:
apiResourceSchema:
description: APIResourceSchema defines an APIResourceSchema as
the source of the schema.
properties:
clusterName:
description: ClusterName is the name of the cluster where
the APIResourceSchema is defined.
minLength: 1
type: string
name:
description: Name is the APIResourceSchema name.
minLength: 1
type: string
required:
- clusterName
- name
type: object
crd:
description: CRD defines a CRD as the source of the schema.
properties:
name:
description: Name is the CRD name.
minLength: 1
type: string
resourceVersion:
description: ResourceVersion is the resource version of the
source CRD object.
type: string
required:
- name
type: object
type: object
type: object
required:
- spec
Expand Down
55 changes: 55 additions & 0 deletions config/examples/virtualresources/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# VirtualResources Example

This example shows usage of VirtualResources, together with CachedResources.
The goal of VirtualResources is to distribute static, read-only resources to multiple clusters
in a scalable way.

## Setup

1. Start kcp with sharded setup:

```bash
make test-run-sharded-server
```

2. Create a provider workspace, where we will create the resources to be distributed:

```bash
export KUBECONFIG=.kcp/admin.kubeconfig
kubectl ws create provider --enter

kubectl create -f config/examples/virtualresources/crd-instances.yaml
# this this to work we always require apiresource schema to be present
kubectl create -f config/examples/virtualresources/apiresourceschema-instances.yaml
kubectl create -f config/examples/virtualresources/instances.yaml

# create caching for the resources
kubectl create -f config/examples/virtualresources/cached-resource-instances.yaml
```

3. Create a an APIResourceSchema for actual virtual machines to be distributed,
which will be using instance types.

```bash
kubectl create -f config/examples/virtualresources/apiresourceschema-virtualmachine.yaml
```

4. Create an APIExport for the virtual machines:

```bash
kubectl create -f config/examples/virtualresources/apiexport.yaml
```

5. Create a consumer workspace, where we will consume the virtual machines:

```bash
kubectl ws use :root
kubectl ws create consumer --enter
kubectl kcp bind apiexport root:provider:virtualmachines virtualmachines
```

6. Now check if we can see instances in the consumer workspace:

```bash
kubectl get instances.machines.svm.io
```
21 changes: 21 additions & 0 deletions config/examples/virtualresources/apiexport.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: apis.kcp.io/v1alpha2
kind: APIExport
metadata:
name: virtualmachines
spec:
resources:
- name: instances
group: machines.svm.io
schema: today.instances.machines.svm.io
storage:
virtual:
reference:
apiGroup: cache.kcp.io
kind: CachedResourceEndpointSlice
name: instances
identityHash: 2857921554ab76ec50f25bf083b7aeb4f7808cd169fd2945b007429f426614ec
- name: virtualmachines
group: machines.svm.io
schema: today.virtualmachines.machines.svm.io
storage:
crd: {}
88 changes: 88 additions & 0 deletions config/examples/virtualresources/apiresourceschema-instances.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
apiVersion: apis.kcp.io/v1alpha1
kind: APIResourceSchema
metadata:
name: today.instances.machines.svm.io
spec:
group: machines.svm.io
names:
kind: Instance
listKind: InstanceList
plural: instances
singular: instance
shortNames:
- inst
scope: Cluster
versions:
- name: v1alpha1
schema:
description: Instance represents a virtual machine instance
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: InstanceSpec holds the desired state of the Instance.
properties:
instanceType:
description: The type of the instance (e.g. small, medium, large)
type: string
name:
description: The name of the instance
type: string
tier:
description: The tier of the instance (e.g. basic, premium)
type: string
enum:
- basic
- premium
- enterprise
required:
- instanceType
- name
- tier
type: object
status:
description: InstanceStatus communicates the observed state of the Instance.
properties:
phase:
description: The current phase of the instance
type: string
enum:
- Pending
- Running
- Terminated
conditions:
description: Current conditions of the instance
items:
properties:
type:
type: string
status:
type: string
lastTransitionTime:
type: string
format: date-time
reason:
type: string
message:
type: string
required:
- type
- status
type: object
type: array
type: object
type: object
served: true
storage: true
subresources:
status: {}
Loading