Skip to content

Commit

Permalink
adding Contributing section (fluidos-project#82)
Browse files Browse the repository at this point in the history
bug fix: skip FLUIDOS Node & Liqo installation on a cluster not managed by the user

bug fix: adding more controls on dependencies' installation

remove verbosity and cluster-name flag from liqoctl install
  • Loading branch information
fracappa committed Jun 18, 2024
1 parent 34b64e7 commit fbb1ce5
Show file tree
Hide file tree
Showing 4 changed files with 138 additions and 62 deletions.
50 changes: 50 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Contributing to FLUIDOS Node #

First of all, thank you for your time!

This section provides guidelines and suggestions for the local development of FLUIDOS Node components.

## Local development ##

When developing a new feature, it is beneficial to test changes in a local environment and debug the code to identify potential issues. To facilitate this, you can use the provided setup.sh script for the quick start example. This script helps you create two development clusters using KinD and install FLUIDOS Node along with its dependencies on both clusters.

To get started, follow these steps:

1. Run the `/tools/scripts/setup.sh` script.
When prompted, choose the type of environment:
- Select option 1 for one consumer and one provider cluster.
- Select option 2 for an environment with multiple consumers and providers.
2. Confirm with "yes" when asked if you want to use local repositories.

## How to contribute ##

We welcome contributions to the project! To ensure a smooth process, please follow these steps:

1. ### Open a issue ###

When reporting a bug, requesting a new feature, or suggesting documentation improvements, please use the appropriate labels:
- **bug** for reporting a bug
- **enhancement** for a new feature
- **documentation** for documentation improvements

2. ### Fork the Repository ###

Create your own copy of the repository.

3. ### Create a New Branch ###

It is recommended to create a new branch in your fork to work on the requested modifications.

4. ### Merge Modifications ###

After making the necessary changes, merge them into your fork's main branch. Ensure you have rebased your branch from the remote upstream repository.

5. ### Test and Resolve Conflicts ###

Test your changes thoroughly and resolve any potential merge conflicts.

6. ### Open a Pull Request (PR) ###

Once your modifications are tested and conflicts are resolved, open a PR to the main repository. Remember to squash all your commits during the PR.

Thank you for your contributions!
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,7 @@ Want to know how to install a FLUIDOS Node? Check out the [**Installation**](./d
## License

This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details.

## How to Contribute

Please, refer to the [Contributing](CONTRIBUTING.md) guide on how to contribute.
124 changes: 73 additions & 51 deletions tools/scripts/installation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function install_components() {
local_resource_manager=$4

# Get the kubernetes clusters type from parameters
kubernetes_clusters=$5
installation_type=$5

helm repo add fluidos https://fluidos-project.github.io/node/

Expand Down Expand Up @@ -170,26 +170,33 @@ function install_components() {

echo "Providers IPs for cluster $cluster: ${providers_ips[$cluster]}"

# Get the kubeconfig file which depends on variable kubernetes_clusters
# Get the kubeconfig file which depends on variable installation_type
KUBECONFIG=$(jq -r '.kubeconfig' <<< "${clusters[$cluster]}")


echo "The KUBECONFIG is $KUBECONFIG"

# Check if metrics-server is installed
echo "Checking if metrics-server is installed"
if ! kubectl get deployment metrics-server -n kube-system --kubeconfig "$KUBECONFIG" &>/dev/null; then
echo "Metrics-server is not installed. Installing it..."
# Apply the metrics-server
kubectl apply -f "$SCRIPT_DIR"/../../quickstart/utils/metrics-server.yaml --kubeconfig "$KUBECONFIG"

# Wait for the metrics-server to be ready
echo "Waiting for metrics-server to be ready"
kubectl wait --for=condition=ready pod -l k8s-app=metrics-server -n kube-system --timeout=300s --kubeconfig "$KUBECONFIG"
# Skip the installation of the metrics-server if the cluster is a provider and its installation type is not kind
if [ "$(jq -r '.role' <<< "${clusters[$cluster]}")" == "provider" ] && [ "$installation_type" != "kind" ]; then
echo "Skipping metrics-server installation in provider cluster $cluster"
else
echo "Metrics-server is already installed"
# Check if metrics-server is installed
echo "Checking if metrics-server is installed"
if ! kubectl get deployment metrics-server -n kube-system --kubeconfig "$KUBECONFIG" &>/dev/null; then
echo "Metrics-server is not installed. Installing it..."
# Apply the metrics-server
kubectl apply -f "$SCRIPT_DIR"/../../quickstart/utils/metrics-server.yaml --kubeconfig "$KUBECONFIG"

# Wait for the metrics-server to be ready
echo "Waiting for metrics-server to be ready"
kubectl wait --for=condition=ready pod -l k8s-app=metrics-server -n kube-system --timeout=300s --kubeconfig "$KUBECONFIG"
else
echo "Metrics-server is already installed"
fi
fi



# Decide value file to use based on the role of the cluster
if [ "$(jq -r '.role' <<< "${clusters[$cluster]}")" == "consumer" ]; then
# Check if local resouce manager is enabled
Expand All @@ -203,52 +210,67 @@ function install_components() {
ip=$(jq -r '.ip' <<< "$ip_value")
port=$consumer_node_port
else
# Check if local resouce manager is enabled
if [ "$local_resource_manager" == "true" ]; then
value_file="$SCRIPT_DIR/../../quickstart/utils/provider-values.yaml"
# Skip this installation if the cluster is a provider and its installation type is not kind
if [ "$installation_type" != "kind" ]; then
echo "Skipping node installation in provider cluster $cluster"
return 0
else
value_file="$SCRIPT_DIR/../../quickstart/utils/provider-values-nolrm.yaml"
# Check if local resouce manager is enabled
if [ "$local_resource_manager" == "true" ]; then
value_file="$SCRIPT_DIR/../../quickstart/utils/provider-values.yaml"
else
value_file="$SCRIPT_DIR/../../quickstart/utils/provider-values-nolrm.yaml"
fi
# Get cluster IP and port
ip_value="${clusters[$cluster]}"
ip=$(jq -r '.ip' <<< "$ip_value")
port=$provider_node_port
fi
fi


# Skipping the installation of the node Helm chart if the cluster is a provider and its installation type is not kind
if [ "$(jq -r '.role' <<< "${clusters[$cluster]}")" == "provider" ] && [ "$installation_type" != "kind" ]; then
echo "Skipping node installation in provider cluster $cluster"
return 0
else
# Install the node Helm chart
# The installation set statically all the other nodes as providers and the current node as the consumer
echo "Installing node Helm chart in cluster $cluster"
# If the installation does not use remote repository, the image is used the one built locally
if [ "$local_repositories" == "true" ]; then
# If the installation does not use remote repository, the CRDs are applied
kubectl apply -f "$SCRIPT_DIR"/../../deployments/node/crds --kubeconfig "$KUBECONFIG"
echo "Installing local repositories in cluster $cluster with local resource manager"
# Execute command
# shellcheck disable=SC2086
helm upgrade --install node $SCRIPT_DIR/../../deployments/node \
-n fluidos --create-namespace -f $value_file $IMAGE_SET_STRING \
--set tag=$VERSION \
--set "networkManager.configMaps.nodeIdentity.ip=$ip:$port" \
--set "networkManager.configMaps.providers.local=${providers_ips[$cluster]}" \
--kubeconfig $KUBECONFIG
else
echo "Installing remote repositories in cluster $cluster with local resource manager"
helm upgrade --install node fluidos/node -n fluidos --create-namespace -f "$value_file" \
--set "networkManager.configMaps.nodeIdentity.ip=$ip:$port" \
--set 'networkManager.configMaps.providers.local'="${providers_ips[$cluster]}" \
--kubeconfig "$KUBECONFIG"
fi
# Get cluster IP and port
ip_value="${clusters[$cluster]}"
ip=$(jq -r '.ip' <<< "$ip_value")
port=$provider_node_port
fi

# Install the node Helm chart
# The installation set statically all the other nodes as providers and the current node as the consumer
echo "Installing node Helm chart in cluster $cluster"
# If the installation does not use remote repository, the image is used the one built locally
if [ "$local_repositories" == "true" ]; then
# If the installation does not use remote repository, the CRDs are applied
kubectl apply -f "$SCRIPT_DIR"/../../deployments/node/crds --kubeconfig "$KUBECONFIG"
echo "Installing local repositories in cluster $cluster with local resource manager"
# Execute command
# shellcheck disable=SC2086
helm upgrade --install node $SCRIPT_DIR/../../deployments/node \
-n fluidos --create-namespace -f $value_file $IMAGE_SET_STRING \
--set tag=$VERSION \
--set "networkManager.configMaps.nodeIdentity.ip=$ip:$port" \
--set "networkManager.configMaps.providers.local=${providers_ips[$cluster]}" \
--kubeconfig $KUBECONFIG
# Skip the installation of LIQO if the cluster is a provider and its installation type is not kind
if [ "$(jq -r '.role' <<< "${clusters[$cluster]}")" == "provider" ] && [ "$installation_type" != "kind" ]; then
echo "Skipping LIQO installation in provider cluster $cluster"
else
echo "Installing remote repositories in cluster $cluster with local resource manager"
helm upgrade --install node fluidos/node -n fluidos --create-namespace -f "$value_file" \
--set "networkManager.configMaps.nodeIdentity.ip=$ip:$port" \
--set 'networkManager.configMaps.providers.local'="${providers_ips[$cluster]}" \
echo "Installing LIQO in cluster $cluster"
echo "Cluster type is $installation_type"
liqoctl install "$installation_type" \
--set controllerManager.config.resourcePluginAddress=node-rear-controller-grpc.fluidos:2710 \
--set controllerManager.config.enableResourceEnforcement=true \
--kubeconfig "$KUBECONFIG"
fi

echo "Installing LIQO in cluster $cluster"
echo "Cluster type is $kubernetes_clusters"
liqoctl install "$kubernetes_clusters" \
--cluster-name "$cluster" \
--set controllerManager.config.resourcePluginAddress=node-rear-controller-grpc.fluidos:2710 \
--set controllerManager.config.enableResourceEnforcement=true \
--kubeconfig "$KUBECONFIG" \
--verbose
) &

# Save the PID of the process
pids+=($!)

Expand Down
22 changes: 11 additions & 11 deletions tools/scripts/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,12 @@ echo "All the tools are installed."
# Check if the input is 1, 2 or 3
if [ "$environment_type" -eq 1 ]; then
environment_type="customkind"
kubernetes_clusters="kind"
installation_type="kind"
# Call create_kind clusters with parameters and save return value into clusters variable
create_kind_clusters "$consumers_json" "$providers_json" $environment_type 1 1
elif [ "$environment_type" -eq 2 ]; then
environment_type="customkind"
kubernetes_clusters="kind"
installation_type="kind"
# Ask the user how many consumer and provider clusters they want
read -r -p "How many consumer clusters do you want? " consumer_clusters
read -r -p "How many provider clusters do you want? " provider_clusters
Expand All @@ -113,15 +113,15 @@ elif [ "$environment_type" -eq 2 ]; then
create_kind_clusters "$consumers_json" "$providers_json" $environment_type "$consumer_clusters" "$provider_clusters"
elif [ "$environment_type" -eq 3 ]; then
# Ask the user what Kubernetes clusters they want to use between kubeadm and k3s
read -r -p "What type of Kubernetes clusters do you want to use? /
1. kubeadm /
2. k3s /
read -r -p "What type of Kubernetes clusters do you want to use?
1. kubeadm
2. k3s
Please enter the number of the option you want to use:
" kubernetes_clusters
if [ "$kubernetes_clusters" -eq 1 ]; then
kubernetes_clusters="kubeadm"
elif [ "$kubernetes_clusters" -eq 2 ]; then
kubernetes_clusters="k3s"
" installation_type
if [ "$installation_type" -eq 1 ]; then
installation_type="kubeadm"
elif [ "$installation_type" -eq 2 ]; then
installation_type="k3s"
else
echo "Invalid option."
return 1
Expand All @@ -133,7 +133,7 @@ else
fi

# FLUIDOS node installation
install_components "$consumers_json" "$providers_json" $local_repositories $local_resource_manager $kubernetes_clusters
install_components "$consumers_json" "$providers_json" $local_repositories $local_resource_manager $installation_type

print_title "Installation completed successfully"

Expand Down

0 comments on commit fbb1ce5

Please sign in to comment.