-
Notifications
You must be signed in to change notification settings - Fork 0
Feat: virtual workspace #282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 6 commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
6aa4dac
feat: virtual ws support
vertex451 22fe7a4
Merge branch 'main' of github.com:openmfp/kubernetes-graphql-gateway …
vertex451 e386bf1
/{virtual-ws-name}/clusters/{cluster-name}/api/v1
vertex451 4f370c6
virtual ws works in the gateway
vertex451 d964753
normal ws works
vertex451 5c33b08
pass kubeconfig via metadata
vertex451 fba3b4e
first iteration of improvements
vertex451 57d3b7c
tests for extractClusterName
vertex451 9f12a03
added pattern matching
vertex451 0d2e5cc
removed overlaped tests cases
vertex451 7f20b65
imporved kcp/apibinding_controller.go
vertex451 e711fd7
moved metadata injector to common package
vertex451 8d3644b
improved virtual worksapce code
vertex451 51fe783
moved url params to the config
vertex451 164a3e6
fix test
vertex451 861a3e0
pass context to watcher from the very top
vertex451 0b4d447
removed Close() method
vertex451 8936333
fixed tests
vertex451 28a19c5
more coverage
vertex451 fe6fdff
watcher test
vertex451 baa7339
listener/reconciler/kcp/virtual_workspace_test.go
vertex451 513d338
fix tests
vertex451 969a712
linter
vertex451 8bf176f
adjusted sleep time
vertex451 acf4135
one more fix
vertex451 97ac6b8
fixed tests
vertex451 e5ee282
removed redundnat test
vertex451 675663a
increse coverage
vertex451 d123a8d
linter
vertex451 bc4a0c4
more tests
vertex451 9001fa7
tests for listener/reconciler/clusteraccess/metadata_injector_test.go
vertex451 cd170fe
fixed unnecessary extract auth data call in inject metadata
vertex451 2a02c2f
pass ctx from top
vertex451 4f3cd2c
extractAuthDataForMetadata test
vertex451 55ca379
reduced complexity at metadata_injector
vertex451 141ce82
return error if no watching path
vertex451 a2815de
adjust tests
vertex451 7cc1136
WalkDir
vertex451 2c4f965
used constants for timeout
vertex451 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
# Virtual Workspaces | ||
|
||
Virtual workspaces allow the listener to connect to external KCP workspaces or API exports without them being part of the main KCP cluster hierarchy. This enables accessing remote services and APIs through the GraphQL gateway. | ||
|
||
## Configuration | ||
|
||
Virtual workspaces are configured through a YAML configuration file that is mounted to the listener. The path to this file is specified using the `virtual-workspaces-config-path` configuration option. | ||
|
||
### Configuration File Format | ||
|
||
```yaml | ||
virtualWorkspaces: | ||
- name: example | ||
url: https://192.168.1.118:6443/services/apiexport/root/configmaps-view | ||
- name: another-service | ||
url: https://your-kcp-server:6443/services/apiexport/root/your-export | ||
``` | ||
|
||
### Configuration Options | ||
|
||
- `virtualWorkspaces`: Array of virtual workspace definitions | ||
- `name`: Unique identifier for the virtual workspace (used in URL paths) | ||
- `url`: Full URL to the virtual workspace or API export | ||
|
||
## Environment Variables | ||
|
||
Set the configuration path using: | ||
|
||
```bash | ||
export VIRTUAL_WORKSPACES_CONFIG_PATH="/etc/config/virtual-workspaces.yaml" | ||
``` | ||
|
||
Or use the default path: `/etc/config/virtual-workspaces.yaml` | ||
|
||
## URL Pattern | ||
|
||
Virtual workspaces are accessible through the gateway using the following URL pattern: | ||
|
||
``` | ||
/kubernetes-graphql-gateway/virtualworkspace/{name}/query | ||
``` | ||
|
||
For example: | ||
- Normal workspace: `/kubernetes-graphql-gateway/root:abc:abc/query` | ||
- Virtual workspace: `/kubernetes-graphql-gateway/virtualworkspace/example/query` | ||
|
||
## How It Works | ||
|
||
1. **Configuration Watching**: The listener watches the virtual workspaces configuration file for changes | ||
2. **Schema Generation**: For each virtual workspace, the listener: | ||
- Creates a discovery client pointing to the virtual workspace URL | ||
- Generates OpenAPI schemas for the available resources | ||
- Stores the schema in a file at `virtualworkspace/{name}` | ||
3. **Gateway Integration**: The gateway watches the schema files and exposes virtual workspaces as GraphQL endpoints | ||
|
||
## File System Layout | ||
|
||
Schema files for virtual workspaces are stored in the definitions directory with the following structure: | ||
|
||
``` | ||
./bin/definitions/ | ||
├── root:workspace1:workspace2 # Regular KCP workspace | ||
├── root:workspace3 # Regular KCP workspace | ||
└── virtualworkspace/ | ||
├── example # Virtual workspace schema | ||
└── another-service # Virtual workspace schema | ||
``` | ||
|
||
## Example Usage | ||
|
||
1. Create a configuration file: | ||
|
||
```yaml | ||
# /etc/config/virtual-workspaces.yaml | ||
virtualWorkspaces: | ||
- name: configmaps-view | ||
url: https://192.168.1.118:6443/services/apiexport/root/configmaps-view | ||
``` | ||
|
||
2. Start the listener with the configuration: | ||
|
||
```bash | ||
export VIRTUAL_WORKSPACES_CONFIG_PATH="/etc/config/virtual-workspaces.yaml" | ||
export KUBECONFIG=/path/to/your/kcp/admin.kubeconfig | ||
go run main.go listener | ||
``` | ||
|
||
3. The virtual workspace will be available at: | ||
- GraphQL endpoint: `/kubernetes-graphql-gateway/virtualworkspace/configmaps-view/query` | ||
|
||
## Updating Configuration | ||
|
||
The configuration file is watched for changes. When the file is modified: | ||
- New virtual workspaces are automatically discovered and schema files generated | ||
- Updated URLs trigger schema regeneration | ||
- Removed virtual workspaces have their schema files deleted | ||
|
||
## Troubleshooting | ||
|
||
### Common Issues | ||
|
||
1. **Invalid URL Format**: Ensure URLs are properly formatted and accessible | ||
2. **Network Connectivity**: Verify the listener can reach the virtual workspace URLs | ||
3. **Authentication**: Virtual workspaces use the same authentication as the base KCP connection | ||
|
||
### Logs | ||
|
||
Check listener logs for virtual workspace processing: | ||
|
||
```bash | ||
# Look for log entries with virtual workspace information | ||
kubectl logs <listener-pod> | grep "virtual workspace" | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.