Skip to content

Commit ab9a92c

Browse files
authored
Merge pull request #66 from FIWARE/update-reqs
requirements
2 parents 17c3aa3 + 518e948 commit ab9a92c

File tree

3 files changed

+67
-99
lines changed

3 files changed

+67
-99
lines changed

.github/workflows/test.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ jobs:
1414
java-version: '17'
1515
java-package: jdk
1616

17+
- name: Ensure br_netfilter is enabled.
18+
run: |
19+
sudo modprobe br_netfilter
20+
1721
- name: Execute tests
1822
id: test
1923
run: |
20-
mvn clean integration-test -Ptest
24+
mvn clean integration-test -Ptest

doc/deployment-integration/local-deployment/LOCAL.MD

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,21 @@ An alternative deployment guide, based on [MicroK8s](https://microk8s.io/) can b
66

77
## Requirements
88

9+
Since the local deployment installs 2 connector instances and a trust-anchor, its recommended to use a strong enough machine. While 16Gb Ram might be enough, its recommended to have >24Gb available. The deployment is build and tested on Ubuntu, most other Linux distributions should work as well.
10+
911
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:
1012

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

17+
In order to interact with the system, the following tools are also helpful:
18+
19+
- [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/)
20+
- [curl](https://curl.se/download.html)
21+
- [jq](https://stedolan.github.io/jq/download/)
22+
- [yq](https://mikefarah.gitbook.io/yq/)
23+
1524
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).
1625

1726
Issues revealed by the script are most likely due to incompatibility of your system or faulty installation of the required tools.
Lines changed: 53 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -1,105 +1,60 @@
11
#!/bin/bash
22

3-
# Script to check if the basic requirements for a local deployment of the Data Space Connector are met
4-
5-
# Command for starting a minimal k3s cluster
6-
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"
7-
8-
check_tool() {
9-
local tool_name=$1
10-
local test_command=$2
11-
12-
# Check if the tool is installed
13-
if ! command -v $tool_name &> /dev/null; then
14-
echo "$tool_name is not installed."
15-
exit 1
16-
fi
17-
18-
# Run the test command and check for errors
19-
if ! output=$($test_command 2>&1); then
20-
echo "$tool_name is installed but failed to run."
21-
echo "Error output:"
22-
echo "$output"
23-
exit 1
24-
fi
25-
26-
echo "$tool_name is installed and works correctly."
27-
return 0
3+
# Define required versions
4+
declare -A required_versions
5+
required_versions=(
6+
[docker]="27.0.0"
7+
[kubectl]="1.31.0"
8+
[curl]="7.81.0"
9+
[jq]="1.6"
10+
[yq]="4.45.0"
11+
[mvn]="3.6.3"
12+
)
13+
14+
# Define installation links
15+
declare -A install_links
16+
install_links=(
17+
[docker]="https://docs.docker.com/get-docker/"
18+
[kubectl]="https://kubernetes.io/docs/tasks/tools/install-kubectl/"
19+
[curl]="https://curl.se/download.html"
20+
[jq]="https://stedolan.github.io/jq/download/"
21+
[yq]="https://mikefarah.gitbook.io/yq/"
22+
[mvn]="https://maven.apache.org/install.html"
23+
)
24+
25+
# Function to compare versions
26+
version_ge() {
27+
printf '%s\n%s\n' "$2" "$1" | sort -V | head -n1 | grep -q "$2"
2828
}
2929

30-
wait_till_running() {
31-
local containerId=$1
32-
sleep 10
33-
34-
end=$((SECONDS+60))
35-
36-
while [ $SECONDS -lt $end ]; do
37-
local state=$(docker inspect -f '{{.State.Status}}' $containerId)
38-
if [[ "$state" = "running" || "$state" = "dead" ]]; then
39-
break
40-
else
41-
echo "Waiting for Container, current state $(state). Checking again in 5 seconds..."
42-
sleep 5
43-
fi
44-
done
45-
}
46-
echo "Testing system for requirements running the FIWARE Data Space Connector Local Deployment"
47-
48-
# Check if the script is running on Linux
49-
if [[ "$(uname)" != "Linux" ]]; then
50-
echo "Local Deployment is currently only tested on Linux."
51-
exit 1
52-
fi
53-
54-
# Check Maven
55-
check_tool "mvn" "mvn --version"
56-
57-
# Check Docker
58-
check_tool "docker" "docker --version"
59-
60-
# Check if k3s can be run
61-
echo "Attempting to start a k3s container"
62-
containerId=""
63-
if output=$($k3s_command 2>&1); then
64-
containerId=$output
65-
echo "k3s container starting with ID: $containerId"
66-
else
67-
echo "Failed to start k3s container."
68-
echo "Error output:"
69-
echo "$output"
70-
exit 1
71-
fi
72-
73-
wait_till_running $containerId
74-
75-
if [ "$(docker inspect -f '{{.State.Status}}' $containerId)" = "running" ]; then
76-
echo "Container is running."
77-
else
78-
echo "Container is not running."
79-
if docker logs $containerId 2>&1 | grep -q 'inotify_init: too many open files'; then
80-
echo "inotify limit is to low, check your inotify.max_user_instances config and set to a higher value"
81-
exit 1
30+
# Check tools
31+
for tool in "${!required_versions[@]}"; do
32+
if ! command -v "$tool" &>/dev/null; then
33+
echo "$tool is not installed. Install it here: ${install_links[$tool]}"
8234
else
83-
echo "Check logs for error hints:"
84-
docker logs $containerId | tail -n20
85-
exit 1
35+
case $tool in
36+
kubectl)
37+
current_version=$(kubectl version --client 2>/dev/null | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -n1)
38+
;;
39+
jq)
40+
current_version=$(jq --version 2>/dev/null | grep -oE '[0-9]+\.[0-9]+' | head -n1)
41+
;;
42+
*)
43+
current_version=$($tool --version 2>/dev/null | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -n1)
44+
;;
45+
esac
46+
47+
if [ -z "$current_version" ]; then
48+
echo "Could not determine version for $tool. Install or update it: ${install_links[$tool]}"
49+
elif ! version_ge "$current_version" "${required_versions[$tool]}"; then
50+
echo "$tool version $current_version is installed but ${required_versions[$tool]} or higher is required. Update it here: ${install_links[$tool]}"
51+
fi
8652
fi
87-
fi
53+
done
8854

89-
# Copy kubeconfig file from container
90-
docker cp $containerId:/etc/rancher/k3s/k3s.yaml .
91-
92-
# Let kubectl use copied config
93-
export KUBECONFIG=$(pwd)/k3s.yaml
94-
95-
# Check Kubectl
96-
check_tool "kubectl" "kubectl get nodes"
97-
echo "Kubectl is able to access the local kubernetes cluster successfully!"
98-
99-
100-
# cleanup
101-
docker stop $containerId
102-
docker rm $containerId
103-
104-
echo "Test complete"
105-
exit 0
55+
# Check if br_netfilter module is enabled
56+
if lsmod | grep -q br_netfilter; then
57+
echo
58+
else
59+
echo "br_netfilter module is not enabled, but required for k3s networking. Enable it using: sudo modprobe br_netfilter"
60+
fi

0 commit comments

Comments
 (0)