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

docs: Installation Guide for ClusterLink #184

Merged
merged 6 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Here are the key steps for setting up your developer environment, making a chang
### How to setup and run ClusterLink

ClusterLink can be set up and run on different environments: local environment (Kind),
Bare-metal environment, or cloud environment.
Bare-metal environment, or cloud environment.For more details, refer to the [Installation Guide for ClusterLink](docs/Installation.md).
kfirtoledo marked this conversation as resolved.
Show resolved Hide resolved

#### Run ClusterLink in local environment (Kind)

Expand Down
93 changes: 93 additions & 0 deletions docs/Installation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Installation Guide for ClusterLink
kfirtoledo marked this conversation as resolved.
Show resolved Hide resolved
The ClusterLink gateway contains three main components: the control-plane, data-plane, and gwctl (more details can be found [here](../README.md#what-is-clusterlink)).
kfirtoledo marked this conversation as resolved.
Show resolved Hide resolved

ClusterLink can be deployed in a local environment (Kind) or any remote K8s cluster environment (GKE, EKS, IBM-K8S, etc.).
kfirtoledo marked this conversation as resolved.
Show resolved Hide resolved
kfirtoledo marked this conversation as resolved.
Show resolved Hide resolved

To deploy the ClusterLink gateway in a K8s cluster, follow these steps:

1. Create and deploy certificates and the ClusterLink Deployment file.
kfirtoledo marked this conversation as resolved.
Show resolved Hide resolved
2. Expose the ClusterLink deployment to a public IP.
3. Optionally, create a central gwctl component to control all gateways.
kfirtoledo marked this conversation as resolved.
Show resolved Hide resolved
kfirtoledo marked this conversation as resolved.
Show resolved Hide resolved

Before you begin, please clone and build the project according to the [instructions](../README.md#building-clustelink).
kfirtoledo marked this conversation as resolved.
Show resolved Hide resolved
### 1. ClusterLink Deployment and certificates.
kfirtoledo marked this conversation as resolved.
Show resolved Hide resolved
kfirtoledo marked this conversation as resolved.
Show resolved Hide resolved
In this step, we build the ClusterLink certificates and deployment files.
kfirtoledo marked this conversation as resolved.
Show resolved Hide resolved
kfirtoledo marked this conversation as resolved.
Show resolved Hide resolved

1) Create a folder (eg. TEST_DIR) for all deployments and yaml files:

export PROJECT_DIR=`git rev-parse --show-toplevel`
export TEST_DIR=$PROJECT_DIR/bin/test/
kfirtoledo marked this conversation as resolved.
Show resolved Hide resolved
mkdir -p $TEST_DIR
cd $TEST_DIR

2) Create Fabric certificates, including the Root CA certificate for all the clusters (This step needs to be done only once per fabric).:
kfirtoledo marked this conversation as resolved.
Show resolved Hide resolved
kfirtoledo marked this conversation as resolved.
Show resolved Hide resolved

$PROJECT_DIR/bin/cl-adm create fabric

kfirtoledo marked this conversation as resolved.
Show resolved Hide resolved
3) Create certificates and a deployment file for the cluster (e.g., peer1). This step needs to be performed for every K8s cluster.:
kfirtoledo marked this conversation as resolved.
Show resolved Hide resolved

$PROJECT_DIR/bin/cl-adm create peer --name peer1

Note: By default, the images are pulled from ghcr.io/clusterlink-net. To change the container registry, you can use the ```--container-registry``` flag.

4) Apply ClusterLink deployment:

kubectl apply -f $TEST_DIR/peer1/k8s.yaml


kfirtoledo marked this conversation as resolved.
Show resolved Hide resolved
5) Verify that all components (cl-controlplane, cl-dataplane, gwctl) are set up and ready.

kubectl get pods
kfirtoledo marked this conversation as resolved.
Show resolved Hide resolved

### 2. Expose the ClusterLink deployment to a public IP
Create public IP for accessing the ClusterLink gateway.
kfirtoledo marked this conversation as resolved.
Show resolved Hide resolved
For Local environment create a K8s nodeport service:
kfirtoledo marked this conversation as resolved.
Show resolved Hide resolved

kubectl apply -f $PROJECT_DIR/demos/utils/manifests/kind/cl-svc.yaml
kfirtoledo marked this conversation as resolved.
Show resolved Hide resolved
export PEER1_IP=`kubectl get nodes -o "jsonpath={.items[0].status.addresses[0].address}"`

For a remote environment:
kfirtoledo marked this conversation as resolved.
Show resolved Hide resolved

1. First, create a K8s LoadBalancer service:
```
kubectl expose deployment cl-dataplane --name=cl-dataplane-load-balancer --port=443 --target-port=443 --type=LoadBalancer
```

2. Retrieve the LoadBalancer IP when it is allocated:
```
export PEER1_IP=$(kubectl get svc -l app=cl-dataplane -o jsonpath="{.items[0].status.loadBalancer.ingress[0].ip}")
kfirtoledo marked this conversation as resolved.
Show resolved Hide resolved
```

Now, the ClusterLink gateway can be accessed through `$PEER1_IP` at port 443.
kfirtoledo marked this conversation as resolved.
Show resolved Hide resolved

### 3. Create central gwctl (optional)
kfirtoledo marked this conversation as resolved.
Show resolved Hide resolved
By default for each K8s cluster a gwctl pod is created that use REST APIs to send control messages to the
kfirtoledo marked this conversation as resolved.
Show resolved Hide resolved
kfirtoledo marked this conversation as resolved.
Show resolved Hide resolved
ClusterLink Gateway, using the command:
kfirtoledo marked this conversation as resolved.
Show resolved Hide resolved

kubectl exec -i <gwctl_pod> -- gwctl <the command>
kfirtoledo marked this conversation as resolved.
Show resolved Hide resolved

To create a single gwctl that controls all ClusterLink gateways, follow these steps:

1. Install the local control (gwctl):

```
sudo make install
kfirtoledo marked this conversation as resolved.
Show resolved Hide resolved
```

2. Initialize the gwctl CLI for the cluster (e.g., peer1):
```
gwctl init --id "peer1" --gwIP $PEER1_IP --gwPort 30443 --certca $TEST_DIR/cert.pem --cert $TEST_DIR/peer1/gwctl/cert.pem --key
kfirtoledo marked this conversation as resolved.
Show resolved Hide resolved
```

kfirtoledo marked this conversation as resolved.
Show resolved Hide resolved
## Additional Setup Modes
kfirtoledo marked this conversation as resolved.
Show resolved Hide resolved
### Debug mode
To run ClusterLink component in debug mode, use ```--log-level``` flag when creating the ClusterLink deployment
kfirtoledo marked this conversation as resolved.
Show resolved Hide resolved

$PROJECT_DIR/bin/cl-adm create peer --name peer1 --log-level debug
kfirtoledo marked this conversation as resolved.
Show resolved Hide resolved
### Local docker image
kfirtoledo marked this conversation as resolved.
Show resolved Hide resolved
To create and run a local image, first build the project's local images:

make docker-build
Change the container-registry in the peer deployment to use the local image:
kfirtoledo marked this conversation as resolved.
Show resolved Hide resolved

$PROJECT_DIR/bin/cl-adm create peer --name peer1 --container-registry=""
kfirtoledo marked this conversation as resolved.
Show resolved Hide resolved