Development document update and formatting

This commit is contained in:
Dharmit Shah 2025-02-05 16:26:06 +05:30
parent bedb8fd29a
commit 027fb31b3a
No known key found for this signature in database
GPG Key ID: 1086AC123836055B
2 changed files with 85 additions and 75 deletions

View File

@ -10,41 +10,41 @@ Cluster API Provider RKE2 is compliant with the `clusterctl` contract, which mea
## Management Cluster
In order to use this provider, you need to have a management cluster available to you and have your current KUBECONFIG context set to talk to that cluster. If you do not have a cluster available to you, you can create a `kind` cluster. These are the steps needed to achieve that:
1. Ensure kind is installed (https://kind.sigs.k8s.io/docs/user/quick-start/#installation)
1. Ensure [kind is installed](https://kind.sigs.k8s.io/docs/user/quick-start/#installation).
2. Create a special `kind` configuration file if you intend to use the Docker infrastructure provider:
```bash
cat > kind-cluster-with-extramounts.yaml <<EOF
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
name: capi-test
nodes:
- role: control-plane
extraMounts:
- hostPath: /var/run/docker.sock
containerPath: /var/run/docker.sock
EOF
```
```bash
cat > kind-cluster-with-extramounts.yaml <<EOF
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
name: capi-test
nodes:
- role: control-plane
extraMounts:
- hostPath: /var/run/docker.sock
containerPath: /var/run/docker.sock
EOF
```
3. Run the following command to create a local kind cluster:
```bash
kind create cluster --config kind-cluster-with-extramounts.yaml
```
```bash
kind create cluster --config kind-cluster-with-extramounts.yaml
```
4. Check your newly created `kind` cluster :
```bash
kubectl cluster-info
```
and get a similar result to this:
```bash
kubectl cluster-info
```
and get a similar result to this:
```
Kubernetes control plane is running at https://127.0.0.1:40819
CoreDNS is running at https://127.0.0.1:40819/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
```
```
Kubernetes control plane is running at https://127.0.0.1:40819
CoreDNS is running at https://127.0.0.1:40819/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
```
## Setting up clusterctl

View File

@ -4,71 +4,81 @@ The following instructions are for development purposes.
1. Clone the [Cluster API Repo](https://github.com/kubernetes-sigs/cluster-api) into the **GOPATH**
> **Why clone into the GOPATH?** There have been historic issues with code generation tools when they are run outside the go path
> **Why clone into the GOPATH?** There have been historic issues with code generation tools when they are run outside the go path
2. Fork the [Cluster API Provider RKE2](https://github.com/rancher/cluster-api-provider-rke2) repo
3. Clone your new repo into the **GOPATH** (i.e. `~/go/src/github.com/yourname/cluster-api-provider-rke2`)
4. Ensure **Tilt** and **kind** are installed
5. Create a `tilt-settings.json` file in the root of your forked/cloned `cluster-api` directory.
6. Add the following contents to the file (replace "yourname" with your github account name):
5. Create a `tilt-settings.json` file in the root of the directory where you cloned the Cluster API repo in step 1.
6. Add the following contents to the file (replace `/path/to/clone/of/` with appropriate file path and "yourname" with
your github account name):
```json
{
"default_registry": "ghcr.io/yourname",
"provider_repos": ["../../github.com/yourname/cluster-api-provider-rke2"],
"enable_providers": ["docker", "rke2-bootstrap", "rke2-control-plane"],
"kustomize_substitutions": {
"EXP_MACHINE_POOL": "true",
"EXP_CLUSTER_RESOURCE_SET": "true"
},
"extra_args": {
"rke2-bootstrap": ["--v=4"],
"rke2-control-plane": ["--v=4"],
"core": ["--v=4"]
},
"debug": {
"rke2-bootstrap": {
"continue": true,
"port": 30001
```json
{
"default_registry": "ghcr.io/yourname",
"provider_repos": ["/path/to/clone/of/github.com/yourname/cluster-api-provider-rke2"],
"enable_providers": ["docker", "rke2-bootstrap", "rke2-control-plane"],
"kustomize_substitutions": {
"EXP_MACHINE_POOL": "true",
"EXP_CLUSTER_RESOURCE_SET": "true"
},
"rke2-control-plane": {
"continue": true,
"port": 30002
"extra_args": {
"rke2-bootstrap": ["--v=4"],
"rke2-control-plane": ["--v=4"],
"core": ["--v=4"]
},
"debug": {
"rke2-bootstrap": {
"continue": true,
"port": 30001
},
"rke2-control-plane": {
"continue": true,
"port": 30002
}
}
}
}
```
> NOTE: Until this [bug](https://github.com/kubernetes-sigs/cluster-api/pull/7482) merged in CAPI you will have to make the changes locally to your clone of CAPI.
```
7. Open another terminal (or pane) and go to the `cluster-api` directory.
8. Run the following to create a configuration for kind:
```bash
cat > kind-cluster-with-extramounts.yaml <<EOF
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
name: capi-test
nodes:
- role: control-plane
extraMounts:
- hostPath: /var/run/docker.sock
containerPath: /var/run/docker.sock
EOF
```
```bash
cat > kind-cluster-with-extramounts.yaml <<EOF
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
name: capi-test
nodes:
- role: control-plane
extraMounts:
- hostPath: /var/run/docker.sock
containerPath: /var/run/docker.sock
EOF
```
> NOTE: if you are using Docker Desktop v4.13 or above then you will you will encounter issues from here. Until a permanent solution is found its recommended you use v4.12
> NOTE: if you are using Docker Desktop v4.13 or above then you will encounter issues from here. Until
> a permanent solution is found its recommended you use v4.12
9. Run the following command to create a local kind cluster:
```bash
kind create cluster --config kind-cluster-with-extramounts.yaml
```
```bash
kind create cluster --config kind-cluster-with-extramounts.yaml
```
10. Now start tilt by running the following:
10. Now start tilt by running the following command in the directory where you cloned Cluster API repo in step 1:
```bash
tilt up
```
```bash
tilt up
```
11. Press the **space** key to see the Tilt web ui and check that everything goes green.
11. Press the **space** key to see the Tilt web ui and check that everything goes green.
### Troubleshooting
Doing `tilt up` should install a bunch of resources in the underlying kind cluster. If you don't see anything there,
run `tilt logs` in a separate terminal without stopping the `tilt up` command that you originally started.
#### Common Issues
1. Make sure you run the `kind` and `tilt` commands mentioned above from correct directory.
2. A `go mod vendor` might be required in your clone of CAPI repo. `tilt logs` should make this obvious.