Skip to content

Commit

Permalink
Merge 458e8c1 into a5b3f84
Browse files Browse the repository at this point in the history
  • Loading branch information
pulledtim authored Nov 6, 2024
2 parents a5b3f84 + 458e8c1 commit f58ff0c
Show file tree
Hide file tree
Showing 2 changed files with 118 additions and 0 deletions.
13 changes: 13 additions & 0 deletions doc/deployment-integration/local-deployment/LOCAL.MD
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,19 @@
In order to support development and exploration of the FIWARE Data Space Connector, a "Minimal Viable Dataspace" is
provided as part of this repo.

## Requirements

The local deployment tries to be as decoupled from the host system as possible to reduce the amount of requirements but stills needs the following programs:

- [Maven](https://maven.apache.org/)
- Java Development Kit (at least v17)
- [Docker](https://www.docker.com/)

To check if the tools are installed, can run and are able to spin up minimal kubernetes cluster without further FIWARE components, you should execute the prepared [script](checkRequirements.sh).

Issues revealed by the script are most likely due to incompatibility of your system or faulty installation of the required tools.


## Quick Start

> :warning: The local deployment uses [k3s](https://k3s.io/) and is currently only tested on linux.
Expand Down
105 changes: 105 additions & 0 deletions doc/deployment-integration/local-deployment/checkRequirements.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#!/bin/bash

# Script to check if the basic requirements for a local deployment of the Data Space Connector are met

# Command for starting a minimal k3s cluster
k3s_command="docker run --privileged --volume=k3stest:/var/lib/rancher/k3s/agent --detach --publish=6443:6443 docker.io/rancher/k3s:latest server --node-name=k3s --https-listen-port=6443 --disable-cloud-controller --disable-network-policy --disable=metrics-server --disable-helm-controller --disable=local-storage --disable=traefik"

check_tool() {
local tool_name=$1
local test_command=$2

# Check if the tool is installed
if ! command -v $tool_name &> /dev/null; then
echo "$tool_name is not installed."
exit 1
fi

# Run the test command and check for errors
if ! output=$($test_command 2>&1); then
echo "$tool_name is installed but failed to run."
echo "Error output:"
echo "$output"
exit 1
fi

echo "$tool_name is installed and works correctly."
return 0
}

wait_till_running() {
local containerId=$1
sleep 10

end=$((SECONDS+60))

while [ $SECONDS -lt $end ]; do
local state=$(docker inspect -f '{{.State.Status}}' $containerId)
if [[ "$state" = "running" || "$state" = "dead" ]]; then
break
else
echo "Waiting for Container, current state $(state). Checking again in 5 seconds..."
sleep 5
fi
done
}
echo "Testing system for requirements running the FIWARE Data Space Connector Local Deployment"

# Check if the script is running on Linux
if [[ "$(uname)" != "Linux" ]]; then
echo "Local Deployment is currently only tested on Linux."
exit 1
fi

# Check Maven
check_tool "mvn" "mvn --version"

# Check Docker
check_tool "docker" "docker --version"

# Check if k3s can be run
echo "Attempting to start a k3s container"
containerId=""
if output=$($k3s_command 2>&1); then
containerId=$output
echo "k3s container starting with ID: $containerId"
else
echo "Failed to start k3s container."
echo "Error output:"
echo "$output"
exit 1
fi

wait_till_running $containerId

if [ "$(docker inspect -f '{{.State.Status}}' $containerId)" = "running" ]; then
echo "Container is running."
else
echo "Container is not running."
if docker logs $containerId 2>&1 | grep -q 'inotify_init: too many open files'; then
echo "inotify limit is to low, check your inotify.max_user_instances config and set to a higher value"
exit 1
else
echo "Check logs for error hints:"
docker logs $containerId | tail -n20
exit 1
fi
fi

# Copy kubeconfig file from container
docker cp $containerId:/etc/rancher/k3s/k3s.yaml .

# Let kubectl use copied config
export KUBECONFIG=$(pwd)/k3s.yaml

# Check Kubectl
check_tool "kubectl" "kubectl get nodes"
echo "Kubectl is able to access the local kubernetes cluster successfully!"


# cleanup
docker stop $containerId
docker rm $containerId

echo "Test complete"
exit 0

0 comments on commit f58ff0c

Please sign in to comment.