Skip to content

Commit

Permalink
docs and setup: updating Makefile to work
Browse files Browse the repository at this point in the history
Signed-off-by: Boekhorst <[email protected]>
  • Loading branch information
boekhorstb1 committed Sep 4, 2024
1 parent 987a5ef commit 8eb59fc
Show file tree
Hide file tree
Showing 8 changed files with 114 additions and 25 deletions.
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
unset SSH_AUTH_SOCK
44 changes: 20 additions & 24 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,8 @@ COLOUR_BLUE=\033[0;34m
COLOUR_END=\033[0m

.DEFAULT_GOAL:=help
SHELL := /bin/bash
SHELL:=/bin/bash

# Get needed paths and information from locally installed librados
export RADOSLIB_VERSION := 2.0.0
export GENERAL_LIB_LOCATION := ${shell pip show rados | grep -oP "(?<=Location: ).*"}
export RADOSLIB_INSTALLED_VERSION := ${shell pip show rados | grep Version | awk '{print $$2}'}

## checking if docker, or podman should be used. Podman is preferred.
ifeq ($(shell command -v podman 2> /dev/null),)
Expand All @@ -19,7 +15,7 @@ else
endif

## Export default rookify version
export ROOKIFY_VERSION ?= "0.0.0.dev1"
export ROOKIFY_VERSION?=0.0.0.dev1

.PHONY: help
help: ## Display this help message
Expand Down Expand Up @@ -50,33 +46,33 @@ update-requirements: ## Update the requirements.txt with newer versions of pip p
pip freeze -l > requirements.txt

.PHONY: check-radoslib
export RADOSLIB_VERSION:=2.0.0
check-radoslib: ## Checks if radoslib is installed and if it contains the right version
@if [ -z "${GENERAL_LIB_LOCATION}" ]; then \
echo -e "${COLOUR_RED}ERROR: 'rados' library not found. Please make sure it's installed.${COLOUR_END}"; \
exit 1; \
else \
echo -e "GENERAL_LIB_LOCATION: $(GENERAL_LIB_LOCATION)"; \
fi
@if [ "${RADOSLIB_INSTALLED_VERSION}" != "${RADOSLIB_VERSION}" ]; then \
echo -e "${COLOUR_RED}ERROR: Incorrect version of 'rados' library found. Expected version $(RADOSLIB_VERSION), found $$RADOSLIB_INSTALLED_VERSION.${COLOUR_END}"; \
exit 1; \
else \
echo -e "RADOSLIB_INSTALLED_VERSION: $(RADOSLIB_INSTALLED_VERSION)"; \
fi
# Get needed paths and information from locally installed librados
./scripts/check_local_rados_lib_installation.sh ${RADOSLIB_VERSION}

.PHONY: build-local-rookify
build-local-rookify: ## This builds rookify into .venv/bin/rookify
./scripts/build_local_rookify.sh

.PHONY: build-container
build-container: ## Build container from Dockerfile, add e.g. ROOKIFY_VERSION=0.0.1 to specify the version. Default value is 0.0.0.dev1
${CONTAINERCMD} build --build-arg ROOKIFY_VERSION=$(ROOKIFY_VERSION) --target rookify -t rookify:latest -f Dockerfile .

.PHONY: run-local-rookify
run-local-rookify: ## Runs rookify in the local development environment (requires setup-venv)
$(eval PYTHONPATH="${PYTHONPATH}:$(pwd)/src")
source ./.venv/bin/activate && \
cd src && python -m rookify
if [ ! -f ./.venv/bin/rookify ]; then \
${MAKE} build-local-rookify; \
fi; \
.venv/bin/rookify

.PHONY: run-rookify
run-rookify: ## Runs rookify in the container
docker exec -it rookify-dev /app/rookify/.venv/bin/rookify

.PHONY: build-container
build-container: ## Build container from Dockerfile, add e.g. ROOKIFY_VERSION=0.0.1 to specify the version. Default value is 0.0.0.dev1
${CONTAINERCMD} build --build-arg ROOKIFY_VERSION=$(ROOKIFY_VERSION) --target rookify -t rookify:latest -f Dockerfile .
.PHONY: get-testbed-configs-for-rookify-testing
get-testbed-configs-for-rookify-testing: ## Gets the needed config (like .kube, /etc/ceph and so on) from the testbed
bash ./scripts/get_configs_from_testbed.sh

.PHONY: run-tests-locally
run-tests-locally: ## Runs the tests in the tests directory. NB: check that your local setup is connected through vpn to the testbed!
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ __TODO__

Type `make` to get a list of available development specific commands.

## Troubleshooting

### OSISM Testbed

- ssh-issues: make sure the id-rsa keys are "clean" and do not contain unexpected strings like "\<\<EOF"

## Support
For issues, questions, or contributions, please open an issue or pull request in the GitHub repository. We welcome community feedback and contributions to enhance rookify.

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ cachetools==5.3.2
certifi==2024.2.2
cffi==1.16.0
charset-normalizer==3.3.2
cryptography==42.0.4
cryptography!=40.0.0,!=40.0.1,<42,>=38.0.0
dill==0.3.8
decorator==5.1.1
Deprecated==1.2.14
Expand Down
1 change: 1 addition & 0 deletions scripts/build_local_rookify.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
source .venv/bin/activate && pip install -e .
29 changes: 29 additions & 0 deletions scripts/check_local_rados_lib_installation.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/env bash

# Check if a version argument is provided
if [ $# -eq 1 ]; then
RADOSLIB_VERSION="$1"
else
# Default version if no argument is provided
RADOSLIB_VERSION="2.0.0"
fi

# Get the location of the installed rados library
GENERAL_LIB_LOCATION=$(pip show rados | grep -oP "(?<=Location: ).*")

# Get the installed version of the rados library
RADOSLIB_INSTALLED_VERSION=$(pip show rados | grep Version | awk '{print $2}')

# Check if the rados library is installed
if [ -z "$GENERAL_LIB_LOCATION" ]; then
echo -e "\033[0;31mERROR: 'rados' library not found. Please make sure it's installed.\033[0m"
exit 1
fi

# Check if the installed version matches the expected version
if [ "$RADOSLIB_INSTALLED_VERSION" != "$RADOSLIB_VERSION" ]; then
echo -e "\033[0;31mERROR: 'rados' library version $RADOSLIB_INSTALLED_VERSION does not match the expected version $RADOSLIB_VERSION.\033[0m"
exit 1
else
echo -e "\033[0;32m'rados' library version $RADOSLIB_INSTALLED_VERSION is correct.\033[0m"
fi
28 changes: 28 additions & 0 deletions scripts/get_configs_from_testbed.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Helperscript: Gets configs from testbed
#
# NOTE: this is for test purposes and specific for the OISISM testbed
# it requires .ssh/config to be set accordingly, e.g.:
#
# Host testbed-*
# StrictHostKeyChecking no
# IdentityFile <id_rsa of testbed>
# IdentitiesOnly yes
# user dragon
#
# Host testbed-manager
# Hostname <ip of manager of testbed>
#
# Host testbed-node-0
# Hostname 192.168.16.10
#
# Host testbed-node-1
# Hostname 192.168.16.11
# Host testbed-node-2
# Hostname 192.168.16.12
#

# copy .kube to ./.k8s
scp -r testbed-manager:.kube ./.k8s

# copy /etc/ceph/ from node1 to ./.k8s
ssh testbed-manager "docker cp cephclient:/etc/ceph /tmp/cephclientconfig" && scp -r testbed-manager:/tmp/cephclientconfig ./.ceph && ssh testbed-manager "rm -rf /tmp/cephclientconfig"
28 changes: 28 additions & 0 deletions scripts/reset_k3s.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Helperscript: Reset the k3s cluster of the OSISM testbed
#
# NOTE: this is for test purposes and specific for the OISISM testbed
# it requires .ssh/config to be set accordingly, e.g.:
#
# Host testbed-*
# StrictHostKeyChecking no
# IdentityFile <id_rsa of testbed>
# IdentitiesOnly yes
# user dragon
#
# Host testbed-manager
# Hostname <ip of manager of testbed>
#
# Host testbed-node-0
# Hostname 192.168.16.10
#
# Host testbed-node-1
# Hostname 192.168.16.11
# Host testbed-node-2
# Hostname 192.168.16.12
#

ssh testbed-node-0 "sudo rm -rf /var/lib/rancher/k3s/server/db/"
ssh testbed-node-1 "sudo rm -rf /var/lib/rancher/k3s/server/db/"
ssh testbed-node-2 "sudo rm -rf /var/lib/rancher/k3s/server/db/"
ssh testbed-manager "nohup /opt/configuration/scripts/deploy/005-kubernetes.sh > ~/005-kubernetes.log 2>&1 &"
ssh testbed-manager "tail -f ~/005-kubernetes.log"

0 comments on commit 8eb59fc

Please sign in to comment.