VirtualResources Example
This example shows usage of virtual resources, together with ClusterCachedResources. The goal of ClusterCachedResources is to distribute static, read-only resources to multiple clusters in a scalable way.
Setup
-
Start kcp with sharded setup:
make test-run-sharded-server -
Create a provider workspace, where we will create the resources to be distributed:
export KUBECONFIG=.kcp/admin.kubeconfig kubectl ws create provider --enter kubectl create -f config/examples/virtualresources/crd-instances.yaml # for 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/cluster-cached-resource-instances.yaml -
Create an APIResourceSchema for actual virtual machines to be distributed, which will be using instance types.
kubectl create -f config/examples/virtualresources/apiresourceschema-virtualmachine.yaml -
Create an APIExport for the virtual machines and the ClusterCachedResourceEndpointSlice that references it:
kubectl create -f config/examples/virtualresources/apiexport.yaml kubectl create -f config/examples/virtualresources/cluster-cached-resource-instances-endpointslice.yaml -
Create a consumer workspace, where we will consume the virtual machines:
kubectl ws use :root kubectl ws create consumer --enter kubectl kcp bind apiexport root:provider:virtualmachines virtualmachines -
Now check if we can see instances in the consumer workspace:
kubectl get instances.machines.svm.io