Skip to content

Commit b3743f1

Browse files
feat: deploy ClusterProfile kind (#66)
* feat: deploy `ClusterProfile` kind * docs: revamp readme * fix(Taskfile): remove nested module (not used) * feat: release v0.0.12
1 parent 755e7ed commit b3743f1

File tree

4 files changed

+121
-49
lines changed

4 files changed

+121
-49
lines changed

README.md

Lines changed: 93 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -10,94 +10,139 @@ A cluster provider for [OpenMCP](https://github.com/openmcp-project/openmcp-oper
1010
- **E2E Testing**: Automated testing of multi-cluster applications and operators
1111
- **CI/CD Pipelines**: Lightweight cluster provisioning for testing environments
1212

13-
## Prerequisites
13+
## 🧪 Prerequisites
1414

1515
Before using this cluster provider, ensure you have:
1616

1717
- **Docker**: Running Docker daemon with socket accessible
1818
- **kind**: [kind CLI tool](https://kind.sigs.k8s.io/docs/user/quick-start/) installed
1919
- **kubectl**: For interacting with Kubernetes clusters
2020

21-
## Installation
21+
## 🏗️ Installation
2222

23-
### Production Deployment
23+
### Local Development
2424

25-
In combination with the [OpenMCP Operator](https://github.com/openmcp-project/openmcp-operator), this operator can be deployed via a simple Kubernetes resource:
25+
To run the cluster-provider-kind on your local machine, you need to first bootstrap an openMCP environment by using [openmcp-operator](https://github.com/openmcp-project/openmcp-operator). A comprehensive guide will follow soon.
26+
27+
In order to run the cluster-provider-kind properly, it is necessary to configure the openMCP Platform cluster with the Docker socket mounted into the nodes. Please use the following kind cluster configuration:
28+
```yaml
29+
apiVersion: kind.x-k8s.io/v1alpha4
30+
kind: Cluster
31+
nodes:
32+
- role: control-plane
33+
extraMounts:
34+
- hostPath: /var/run/docker.sock
35+
containerPath: /var/run/host-docker.sock
36+
```
37+
38+
You can create the Platform cluster using the above configuration by running:
39+
40+
```shell
41+
kind create cluster --name platform --config ./path/to/config
42+
kubectl config use-context kind-platform
43+
```
44+
45+
For current testing reasons, it is recommended to test and run the cluster-provider-kind in the cluster. To run the latest version of your changes in your local environment, you need to run:
46+
47+
```bash
48+
task build:img:build
49+
```
50+
51+
This will build the image of the cluster-provider-kind and push it to your local Docker registry.
52+
53+
```bash
54+
docker images ghcr.io/openmcp-project/images/cluster-provider-kind
55+
```
56+
57+
You can then apply the `ClusterProvider` resource to your openMCP Platform cluster:
2658

2759
```yaml
2860
apiVersion: openmcp.cloud/v1alpha1
2961
kind: ClusterProvider
3062
metadata:
3163
name: kind
3264
spec:
33-
image: "ghcr.io/openmcp-project/images/cluster-provider-kind:<latest-version>"
65+
image: ghcr.io/openmcp-project/images/cluster-provider-kind:... # latest local docker image build
66+
extraVolumeMounts:
67+
- mountPath: /var/run/docker.sock
68+
name: docker
69+
extraVolumes:
70+
- name: docker
71+
hostPath:
72+
path: /var/run/host-docker.sock
73+
type: Socket
3474
```
3575
36-
### Local Development
37-
38-
To run the operator locally for development:
76+
### Running Cluster Provider kind outside the cluster (not recommended)
77+
You can also run the cluster-provider-kind outside the cluster, but this is not recommended at the moment, since the operator might not work as expected due to some IP address issues with your Docker network access.
3978
40-
1. **Start a platform kind cluster**:
41-
```shell
42-
kind create cluster --name platform
43-
kubectl config use-context kind-platform
44-
```
45-
2. Install the Platform CRDs of the openmcp-operator:
46-
Apply the CRDs from the OpenMCP operator repository [here](https://github.com/openmcp-project/openmcp-operator/tree/main/api/crds/manifests).
47-
48-
3. **Initialize the CRDs**:
49-
```shell
79+
The following steps will help you to run the cluster-provider-kind outside the cluster:
80+
1. Initialize the CRDs:
81+
```bash
5082
go run ./cmd/cluster-provider-kind/main.go init
5183
```
5284

53-
4. **Run the operator**:
54-
```shell
85+
2. Run the operator:
86+
```bash
5587
KIND_ON_LOCAL_HOST=true go run ./cmd/cluster-provider-kind/main.go run
5688
```
5789

5890
> **Note**: When running the operator outside the cluster (locally), you must set the `KIND_ON_LOCAL_HOST` environment variable to `true`. This tells the operator to use the local Docker socket configuration instead of the in-cluster configuration.
5991
60-
## Usage Examples
92+
## 📖 Usage
6193

62-
### Creating a Cluster
94+
### Creating a `Cluster` via `ClusterRequest`
6395

64-
Create a new kind cluster by applying a Cluster resource:
96+
Create a new kind cluster by applying a `ClusterRequest` resource:
6597

6698
```yaml
6799
apiVersion: clusters.openmcp.cloud/v1alpha1
68-
kind: Cluster
100+
kind: ClusterRequest
69101
metadata:
70-
name: my-managedcontrolplane
102+
name: mcp
71103
namespace: default
72104
spec:
73-
profile: kind # This tells the kind provider to handle this cluster
74-
tenancy: Exclusive
105+
purpose: mcp
75106
```
76107
77108
```shell
78-
kubectl apply -f cluster.yaml
109+
kubectl apply -f clusterrequest.yaml
79110
```
80111

81-
### Requesting Access to a Cluster
112+
## 🧑‍💻 Development
82113

83-
Create an AccessRequest to get kubeconfig for a cluster:
114+
### Building the binary locally
84115

85-
```yaml
86-
apiVersion: clusters.openmcp.cloud/v1alpha1
87-
kind: AccessRequest
88-
metadata:
89-
name: my-access
90-
namespace: default
91-
spec:
92-
clusterRef:
93-
name: my-managedcontrolplane
94-
namespace: default
95-
permissions: []
116+
To build the binary locally, you can use the following command:
117+
118+
```bash
119+
task build
96120
```
97121

98-
The kubeconfig will be stored in a Secret in the same namespace as the `AccessRequest`.
122+
### Build the image locally
99123

100-
## How it works
124+
To build the image locally, you can use the following command:
125+
126+
```bash
127+
task build:img:build
128+
```
129+
130+
### Run unit tests locally
131+
132+
To run the unit tests locally, you can use the following command:
133+
134+
```bash
135+
task test
136+
```
137+
138+
### Generating the CRDs, DeepCopy functions etc.
139+
To generate the CRDs, DeepCopy functions, and other boilerplate code, you can use the following command:
140+
141+
```bash
142+
task generate
143+
```
144+
145+
## 🏋️ How it works
101146

102147
### Docker Socket Access
103148

@@ -199,17 +244,18 @@ platform
199244
test
200245
```
201246
202-
## Support, Feedback, Contributing
247+
## ❤️ Support, Feedback, Contributing
203248
204249
This project is open to feature requests/suggestions, bug reports etc. via [GitHub issues](https://github.com/openmcp-project/cluster-provider-kind/issues). Contribution and feedback are encouraged and always welcome. For more information about how to contribute, the project structure, as well as additional contribution information, see our [Contribution Guidelines](CONTRIBUTING.md).
205250
206-
## Security / Disclosure
251+
## 🔐 Security / Disclosure
252+
207253
If you find any bug that may be a security problem, please follow our instructions at [in our security policy](https://github.com/openmcp-project/cluster-provider-kind/security/policy) on how to report it. Please do not create GitHub issues for security-related doubts or problems.
208254
209-
## Code of Conduct
255+
## 🤝 Code of Conduct
210256
211257
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone. By participating in this project, you agree to abide by its [Code of Conduct](https://github.com/SAP/.github/blob/main/CODE_OF_CONDUCT.md) at all times.
212258
213-
## Licensing
259+
## 📋 Licensing
214260
215261
Copyright 2025 SAP SE or an SAP affiliate company and cluster-provider-kind contributors. Please see our [LICENSE](LICENSE) for copyright and license information. Detailed information including third-party components and their licensing/copyright information is available [via the REUSE tool](https://api.reuse.software/info/github.com/openmcp-project/cluster-provider-kind).

Taskfile.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ includes:
55
taskfile: hack/common/Taskfile_controller.yaml
66
flatten: true
77
vars:
8-
NESTED_MODULES: api
98
API_DIRS: '{{.ROOT_DIR}}/api/v1alpha1/...'
109
MANIFEST_OUT: '{{.ROOT_DIR}}/api/crds/manifests'
1110
CODE_DIRS: '{{.ROOT_DIR}}/cmd/... {{.ROOT_DIR}}/internal/... {{.ROOT_DIR}}/api/v1alpha1/... {{.ROOT_DIR}}/pkg/...'

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v0.0.11-dev
1+
v0.0.12

cmd/cluster-provider-kind/main.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"time"
2626

2727
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
28+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2829
"k8s.io/apimachinery/pkg/runtime"
2930
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
3031
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
@@ -39,6 +40,7 @@ import (
3940
"sigs.k8s.io/controller-runtime/pkg/webhook"
4041

4142
clustersv1alpha1 "github.com/openmcp-project/openmcp-operator/api/clusters/v1alpha1"
43+
"github.com/openmcp-project/openmcp-operator/api/common"
4244

4345
"github.com/openmcp-project/cluster-provider-kind/api/crds"
4446
kindv1alpha1 "github.com/openmcp-project/cluster-provider-kind/api/v1alpha1"
@@ -83,6 +85,31 @@ func runInit(setupClient client.Client) {
8385
os.Exit(1)
8486
}
8587
}
88+
89+
cp := &clustersv1alpha1.ClusterProfile{
90+
ObjectMeta: metav1.ObjectMeta{
91+
Name: "kind",
92+
},
93+
Spec: clustersv1alpha1.ClusterProfileSpec{
94+
ProviderRef: common.ObjectReference{
95+
Name: "kind",
96+
},
97+
ProviderConfigRef: common.ObjectReference{
98+
Name: "kind",
99+
},
100+
SupportedVersions: []clustersv1alpha1.SupportedK8sVersion{},
101+
},
102+
}
103+
104+
_, err = controllerutil.CreateOrUpdate(initContext, setupClient, cp, func() error {
105+
return nil
106+
})
107+
108+
if err != nil {
109+
setupLog.Error(err, "Failed to create/update ClusterProfile", "name", cp.Name)
110+
os.Exit(1)
111+
}
112+
86113
setupLog.Info("Init command completed successfully")
87114
}
88115

0 commit comments

Comments
 (0)