https://github.com/appscode-cloud/vcluster-plugin
https://github.com/appscode-cloud/vcluster-plugin
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/appscode-cloud/vcluster-plugin
- Owner: appscode-cloud
- License: apache-2.0
- Created: 2024-07-26T03:09:35.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2024-12-28T04:45:13.000Z (over 1 year ago)
- Last Synced: 2025-02-14T11:05:31.002Z (over 1 year ago)
- Language: Go
- Size: 18.9 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## vCluster Plugin
This [vCluster](https://github.com/loft-sh/vcluster) plugin syncs [CAProviderClass](https://github.com/kubeops/csi-driver-cacerts) crds from the vcluster into the host cluster.
This plugin has been forked from [loft-sh/vcluster-plugin-example](https://github.com/loft-sh/vcluster-plugin-example). For more information how to develop plugins in vcluster and a complete walk through, please refer to the [official vcluster docs](https://www.vcluster.com/docs/v0.19/advanced-topics/plugins-overview). You can find additional examples [here](https://github.com/loft-sh/vcluster-sdk/tree/main/examples).
### Using the Plugin
To use the plugin, create a new vcluster with the `plugin.yaml`:
```
# Install csi-driver-cacerts in host cluster
helm upgrade -i cert-manager-csi-driver-cacerts \
oci://ghcr.io/appscode-charts/cert-manager-csi-driver-cacerts \
--version v2024.10.17 \
-n cert-manager --create-namespace --wait
# Use public plugin.yaml
vcluster create vcluster -n vcluster \
-f https://github.com/appscode-cloud/vcluster-plugin/raw/master/plugin.yaml
```
This will create a new vcluster with the plugin installed. After that, wait for vcluster to start up and check:
```
# Create a car in the virtual cluster
vcluster connect vcluster -n vcluster -- kubectl apply -f manifests/sample.yaml
# Check if the car was synced to the host cluster
kubectl get caproviderclass -n vcluster
```
```
# create a fake-reporting-secret in the host cluster
kubectl apply -f manifests/fake_reporting_secret.yaml
# create a pod in vcluster that uses the reporting secret
vcluster connect vcluster -n vcluster -- kubectl apply -f manifests/reporting_secret_pod.yaml
# check the pod is using the host secret directly
kubectl get pods -n vcluster agent-x-default-x-vcluster -o yaml
```
### Building the Plugin
To just build the plugin image and push it to the registry, run:
```
# Build
docker build --push -t ghcr.io/appscode/vcluster-plugin-ace:v0.0.3 .
# Multi-arch Build
## Ensure docker builder with multi platform support
docker buildx create \
--name container \
--driver=docker-container
## Build & push image
docker build --push \
--builder container --platform linux/amd64,linux/arm64 \
-t ghcr.io/appscode/vcluster-plugin-ace:v0.0.3 .
```
Then exchange the image in the `plugin.yaml`.
## Development
General vcluster plugin project structure:
```
.
├── go.mod # Go module definition
├── go.sum
├── devspace.yaml # Development environment definition
├── devspace_start.sh # Development entrypoint script
├── Dockerfile # Production Dockerfile
├── main.go # Go Entrypoint
├── plugin.yaml # Plugin Helm Values
├── syncers/ # Plugin Syncers
└── manifests/ # Additional plugin resources
```
Before starting to develop, make sure you have installed the following tools on your computer:
- [docker](https://docs.docker.com/)
- [kubectl](https://kubernetes.io/docs/tasks/tools/) with a valid kube context configured
- [helm](https://helm.sh/docs/intro/install/), which is used to deploy vcluster and the plugin
- [vcluster CLI](https://www.vcluster.com/docs/getting-started/setup) v0.6.0 or higher
- [DevSpace](https://devspace.sh/cli/docs/quickstart), which is used to spin up a development environment
- [Go](https://go.dev/dl/) programming language build tools
After successfully setting up the tools, start the development environment with:
```
devspace dev -n vcluster
```
After a while a terminal should show up with additional instructions. Enter the following command to start the plugin:
```
go build -mod vendor -o plugin main.go && /vcluster/syncer start
```
You can now change a file locally in your IDE and then restart the command in the terminal to apply the changes to the plugin.
Delete the development environment with:
```
devspace purge -n vcluster
```