-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Jian Qiu <jqiu@redhat.com>
- Loading branch information
Showing
2 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,44 @@ | ||
# Work with cluster-api | ||
|
||
[Cluster API](https://cluster-api.sigs.k8s.io/) is a Kubernetes sub-project focused on providing declarative APIs and | ||
tooling to simplify provisioning, upgrading, and operating multiple Kubernetes clusters. This doc is a guideline on how | ||
to use `cluster-api` and `open-cluster-management` project together | ||
|
||
## Prerequisite | ||
Download and install [clusteradm](https://github.com/open-cluster-management-io/clusteradm/releases). For Linux OS, run the following commands: | ||
|
||
```shell | ||
wget -qO- https://github.com/open-cluster-management-io/clusteradm/releases/latest/download/clusteradm_linux_amd64.tar.gz | sudo tar -xvz -C /usr/local/bin/ | ||
|
||
sudo chmod +x /usr/local/bin/clusteradm | ||
``` | ||
|
||
Follow the instruction [here](https://cluster-api.sigs.k8s.io/user/quick-start.html) to install the `clusterctl` | ||
|
||
## Initialize the cluster api management plane and create cluster | ||
|
||
Before initilize the management plane, some feature gates should be enabled: | ||
|
||
```shell | ||
export CLUSTER_TOPOLOGY=true | ||
export EXP_CLUSTER_RESOURCE_SET=true | ||
``` | ||
|
||
Next initiate the cluster api management plane by following [this](https://cluster-api.sigs.k8s.io/user/quick-start.html#initialize-the-management-cluster) | ||
|
||
Then you can create a cluster on any cloud using cluster-api. Suppose the name of the cluster created is `capi-cluster` | ||
|
||
## Initialize the ocm hub and register the cluster created by cluster api | ||
|
||
ocm hub can run in the same cluster of cluster api management plane | ||
|
||
``` | ||
clusteradm init --use-bootstrap-token | ||
``` | ||
|
||
then run | ||
|
||
``` | ||
./capi-join.sh capi-cluster | ||
``` | ||
|
This file contains 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,27 @@ | ||
#!/bin/bash | ||
|
||
cd $(dirname ${BASH_SOURCE}) | ||
|
||
set -e | ||
|
||
echo "get bootstrap token from ocm hub cluster" | ||
joincmd=$(clusteradm get token --use-bootstrap-token | grep clusteradm) | ||
|
||
echo "Join $1 to hub" | ||
$(echo ${joincmd} --dry-run --output-file join.yaml | sed "s/<cluster_name>/$1/g") | ||
kubectl create secret generic import-secret-$1 --from-file=join.yaml --type=addons.cluster.x-k8s.io/resource-set | ||
|
||
cat << EOF | kubectl apply -f - | ||
apiVersion: addons.cluster.x-k8s.io/v1alpha3 | ||
kind: ClusterResourceSet | ||
metadata: | ||
name: import-$1 | ||
spec: | ||
strategy: "ApplyOnce" | ||
clusterSelector: | ||
matchLabels: | ||
cluster.x-k8s.io/cluster-name: $1 | ||
resources: | ||
- name: import-secret | ||
kind: Secret | ||
EOF |