Skip to content
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

Move provider examples to doc book #479

Merged
merged 1 commit into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/book/src/03_examples/00.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Examples

This section contains examples of how to use the CAPRKE2 with different cloud providers and platforms.

### Setting up the Management Cluster

Make sure you set up a Management Cluster to use with Cluster API, you can follow instructions from the Cluster API [book](https://cluster-api.sigs.k8s.io/user/quick-start.html).
14 changes: 5 additions & 9 deletions samples/aws/README.md → docs/book/src/03_examples/01_aws.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
# Using CAPI Provider RKE2 with AWS
This README focuses on using the RKE2 provider with the AWS Infrastructure provider.
# Cluster API AWS Infrastructure Provider

## Setting up the Management Cluster
Make sure your set up a Management Cluster to use with Cluster API, example [here in the main README](https://github.com/rancher/cluster-api-provider-rke2#management-cluster).

## Deploying the Cluster API AWS Infrastructure Provider
## Installing the AWS provider

Refer to the [Cluster API book](https://cluster-api.sigs.k8s.io/user/quick-start#initialization-for-common-providers) for configuring AWS credentials and setting up the AWS infrastructure provider.

Expand Down Expand Up @@ -36,7 +32,7 @@ export AWS_AMI_ID="ami-id"
Now, we can generate the YAML files from the templates using `clusterctl generate yaml` command:

```bash
clusterctl generate cluster --from https://github.com/rancher/cluster-api-provider-rke2/blob/main/samples/aws/cluster-template.yaml -n example-aws rke2-aws > aws-rke2-clusterctl.yaml
clusterctl generate cluster --from https://github.com/rancher/cluster-api-provider-rke2/blob/main/examples/aws/cluster-template.yaml -n example-aws rke2-aws > aws-rke2-clusterctl.yaml
```

After examining the result YAML file, you can apply to the management cluster using :
Expand All @@ -46,6 +42,7 @@ kubectl apply -f aws-rke2-clusterctl.yaml
```

## Checking the workload cluster

After a while you should be able to check functionality of the workload cluster using `clusterctl`:

```bash
Expand Down Expand Up @@ -94,6 +91,5 @@ export AWS_S3_BUCKET_NAME=<YOUR_AWS_S3_BUCKET_NAME>
Now you can generate manifests from the cluster template:

```bash
clusterctl generate cluster --from https://github.com/rancher/cluster-api-provider-rke2/blob/main/samples/aws/ignition/cluster-template-ignition.yaml -n example-aws rke2-aws > aws-rke2-clusterctl.yaml
clusterctl generate cluster --from https://github.com/rancher/cluster-api-provider-rke2/blob/main/examples/aws/ignition/cluster-template-ignition.yaml -n example-aws rke2-aws > aws-rke2-clusterctl.yaml
```

Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Example manifests
# Cluster API vSphere Infrastructure Provider

## Installing the vSphere provider and creating a workload cluster

This config includes a kubevip loadbalancer on the controlplane nodes. The VIP of the loadbalancer for the Kubernetes API is set by the CONTROL_PLANE_ENDPOINT_IP.

Expand Down Expand Up @@ -35,9 +37,10 @@ VSPHERE_SSH_AUTHORIZED_KEY: "ssh-rsa AAAAB3N..." # The public ssh a
Then run the following command to generate the RKE2 cluster manifests:

```bash
clusterctl generate cluster --from https://github.com/rancher/cluster-api-provider-rke2/blob/main/samples/vmware/cluster-template.yaml -n example-vsphere rke2-vsphere > vsphere-rke2-clusterctl.yaml
clusterctl generate cluster --from https://github.com/rancher/cluster-api-provider-rke2/blob/main/examples/vmware/cluster-template.yaml -n example-vsphere rke2-vsphere > vsphere-rke2-clusterctl.yaml
```

```bash
kubectl apply -f vsphere-rke2-clusterctl.yaml
```

30 changes: 30 additions & 0 deletions docs/book/src/03_examples/03_docker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Cluster API Docker Infrastructure Provider

This page focuses on using the RKE2 provider with the Docker Infrastructure provider.

## Setting up the Management Cluster

Make sure you set up a Management Cluster to use with Cluster API, you can follow instructions from the Cluster API [book](https://cluster-api.sigs.k8s.io/user/quick-start.html).

## Create a workload cluster

Before creating a workload clusters, it is required to set the following environment variables:

```bash
export CONTROL_PLANE_MACHINE_COUNT=3
export WORKER_MACHINE_COUNT=1
export RKE2_VERSION=v1.30.2+rke2r1
export KIND_IMAGE_VERSION=v1.30.0
```

Now, we can generate the YAML files from the templates using `clusterctl generate yaml` command:

```bash
clusterctl generate cluster --from https://github.com/rancher/cluster-api-provider-rke2/blob/main/examples/docker/online-default/cluster-template.yaml -n example-docker rke2-docker > docker-rke2-clusterctl.yaml
```

After examining the result YAML file, you can apply to the management cluster using:

```bash
kubectl apply -f docker-rke2-clusterctl.yaml
```
File renamed without changes.
File renamed without changes.
12 changes: 8 additions & 4 deletions docs/book/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
- [Air-gapped installation](./02_topics/01_air-gapped-installation.md)
- [Node registration methods](./02_topics/02_node-registration-methods.md)
- [CIS and PSA](./02_topics/03_cis-psa.md)
- [Developer Guide](./03_developer/00.md)
- [Development](./03_developer/01_development.md)
- [Releasing](./03_developer/02_releasing.md)
- [Reference](./04_reference/00.md)
- [Examples](./03_examples/00.md)
- [AWS](./03_examples/01_aws.md)
- [vSphere](./03_examples/02_vsphere.md)
- [Docker](./03_examples/03_docker.md)
- [Developer Guide](./04_developer/00.md)
- [Development](./04_developer/01_development.md)
- [Releasing](./04_developer/02_releasing.md)
- [Reference](./05_reference/00.md)
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
apiVersion: v1
kind: Namespace
metadata:
name: ${CABPR_NAMESPACE}
name: ${NAMESPACE}
---
apiVersion: cluster.x-k8s.io/v1beta1
kind: Cluster
metadata:
namespace: ${CABPR_NAMESPACE}
namespace: ${NAMESPACE}
name: ${CLUSTER_NAME}
spec:
clusterNetwork:
Expand All @@ -30,7 +30,7 @@ apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: DockerCluster
metadata:
name: ${CLUSTER_NAME}
namespace: ${CABPR_NAMESPACE}
namespace: ${NAMESPACE}
spec:
loadBalancer:
customHAProxyConfigTemplateRef:
Expand All @@ -40,10 +40,10 @@ apiVersion: controlplane.cluster.x-k8s.io/v1beta1
kind: RKE2ControlPlane
metadata:
name: ${CLUSTER_NAME}-control-plane
namespace: ${CABPR_NAMESPACE}
namespace: ${NAMESPACE}
spec:
replicas: ${CABPR_CP_REPLICAS}
version: ${KUBERNETES_VERSION}+rke2r1
replicas: ${CONTROL_PLANE_MACHINE_COUNT}
version: ${RKE2_VERSION}
registrationMethod: control-plane-endpoint
rolloutStrategy:
type: "RollingUpdate"
Expand All @@ -64,7 +64,7 @@ apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: DockerMachineTemplate
metadata:
name: controlplane
namespace: ${CABPR_NAMESPACE}
namespace: ${NAMESPACE}
spec:
template:
spec:
Expand All @@ -75,34 +75,34 @@ apiVersion: cluster.x-k8s.io/v1beta1
kind: MachineDeployment
metadata:
name: worker-md-0
namespace: ${CABPR_NAMESPACE}
namespace: ${NAMESPACE}
spec:
clusterName: ${CLUSTER_NAME}
replicas: ${CABPR_WK_REPLICAS}
replicas: ${WORKER_MACHINE_COUNT}
selector:
matchLabels:
cluster.x-k8s.io/cluster-name: ${CLUSTER_NAME}
template:
spec:
version: ${KUBERNETES_VERSION}+rke2r1
version: ${RKE2_VERSION}
clusterName: ${CLUSTER_NAME}
bootstrap:
configRef:
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
kind: RKE2ConfigTemplate
name: ${CLUSTER_NAME}-agent
namespace: ${CABPR_NAMESPACE}
namespace: ${NAMESPACE}
infrastructureRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: DockerMachineTemplate
name: worker
namespace: ${CABPR_NAMESPACE}
namespace: ${NAMESPACE}
---
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: DockerMachineTemplate
metadata:
name: worker
namespace: ${CABPR_NAMESPACE}
namespace: ${NAMESPACE}
spec:
template:
spec:
Expand All @@ -112,7 +112,7 @@ spec:
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
kind: RKE2ConfigTemplate
metadata:
namespace: ${CABPR_NAMESPACE}
namespace: ${NAMESPACE}
name: ${CLUSTER_NAME}-agent
spec:
template:
Expand All @@ -123,7 +123,7 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: ${CLUSTER_NAME}-lb-config
namespace: ${CABPR_NAMESPACE}
namespace: ${NAMESPACE}
data:
value: |-
# generated by kind
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
apiVersion: v1
kind: Namespace
metadata:
name: ${CABPR_NAMESPACE}
name: ${NAMESPACE}
---
apiVersion: cluster.x-k8s.io/v1beta1
kind: Cluster
metadata:
name: ${CLUSTER_NAME}
namespace: ${CABPR_NAMESPACE}
namespace: ${NAMESPACE}
spec:
clusterNetwork:
pods:
Expand All @@ -29,7 +29,7 @@ apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: Metal3Cluster
metadata:
name: ${CLUSTER_NAME}
namespace: ${CABPR_NAMESPACE}
namespace: ${NAMESPACE}
spec:
controlPlaneEndpoint:
host: ${CLUSTER_API_HOSTNAME}
Expand All @@ -40,7 +40,7 @@ apiVersion: ipam.metal3.io/v1alpha1
kind: IPPool
metadata:
name: provisioning-pool
namespace: ${CABPR_NAMESPACE}
namespace: ${NAMESPACE}
spec:
clusterName: ${CLUSTER_NAME}
gateway: ${PROVISIONING_NETWORK_GATEWAY}
Expand All @@ -54,7 +54,7 @@ apiVersion: ipam.metal3.io/v1alpha1
kind: IPPool
metadata:
name: public-pool
namespace: ${CABPR_NAMESPACE}
namespace: ${NAMESPACE}
spec:
clusterName: ${CLUSTER_NAME}
gateway: ${PUBLIC_NETWORK_GATEWAY}
Expand All @@ -68,7 +68,7 @@ apiVersion: controlplane.cluster.x-k8s.io/v1beta1
kind: RKE2ControlPlane
metadata:
name: ${CLUSTER_NAME}
namespace: ${CABPR_NAMESPACE}
namespace: ${NAMESPACE}
spec:
infrastructureRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
Expand All @@ -85,7 +85,7 @@ apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: Metal3MachineTemplate
metadata:
name: ${CLUSTER_NAME}-controlplane
namespace: ${CABPR_NAMESPACE}
namespace: ${NAMESPACE}
spec:
template:
spec:
Expand All @@ -104,7 +104,7 @@ apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: Metal3DataTemplate
metadata:
name: ${CLUSTER_NAME}-controlplane-template
namespace: ${CABPR_NAMESPACE}
namespace: ${NAMESPACE}
spec:
clusterName: ${CLUSTER_NAME}
metaData:
Expand Down Expand Up @@ -162,7 +162,7 @@ metadata:
cluster.x-k8s.io/cluster-name: ${CLUSTER_NAME}
nodepool: nodepool-0
name: ${CLUSTER_NAME}
namespace: ${CABPR_NAMESPACE}
namespace: ${NAMESPACE}
spec:
clusterName: ${CLUSTER_NAME}
replicas: 1
Expand Down Expand Up @@ -193,7 +193,7 @@ apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: Metal3MachineTemplate
metadata:
name: ${CLUSTER_NAME}-workers
namespace: ${CABPR_NAMESPACE}
namespace: ${NAMESPACE}
spec:
template:
spec:
Expand All @@ -212,7 +212,7 @@ apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: Metal3DataTemplate
metadata:
name: ${CLUSTER_NAME}-workers-template
namespace: ${CABPR_NAMESPACE}
namespace: ${NAMESPACE}
spec:
clusterName: ${CLUSTER_NAME}
metaData:
Expand Down Expand Up @@ -267,7 +267,7 @@ apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
kind: RKE2ConfigTemplate
metadata:
name: ${CLUSTER_NAME}-workers
namespace: ${CABPR_NAMESPACE}
namespace: ${NAMESPACE}
spec:
template:
spec:
Expand Down