Skip to content

Latest commit

 

History

History
169 lines (117 loc) · 4.79 KB

DEVEL.md

File metadata and controls

169 lines (117 loc) · 4.79 KB

Development Setup

The following is done on a Fedora Desktop to run a minikube rootless setup. For setting it up you need administrative rights.

Prepare the system

First install the required network component slirp4netns

sudo dnf install slirp4netns

Now map additional UIDs and GIDs for your user, to be able to use the users IDs from inside the containers.

Map additional UID/GID for your user:

sudo usermod --add-subuids 10000-75535 USERNAME
sudo usermod --add-subgids 10000-75535 USERNAME

So this was the only parts where root priviledges are needed.

Prepare minicube

Now install and setup minikube with the calico network driver. Assuming you have ~/bin in your $PATH environment variable.

wget https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 -O ~/bin/minikube
chmod 755 ~/bin/minikube

minikube config set rootless true
minikube config set driver podman
minikube config set container-runtime containerd

minikube start --cni calico

Now you have a running cluster on your machine.

Minikube comes with a integrated kubectl command. So you can run kubectl commands, without downloaded kubectl binary:

minikube kubectl -- get pods -A

But for using helm and our convenience, we install kubectl alongside minikube:

wget "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" -O ~/bin/kubectl

Finally we install helm, into ~/bin:

export HELM_INSTALL_DIR=~/bin; export USE_SUDO=false; curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash

Setup wger

You can install wger without any changes to the values.yaml, this will run wger in development mode.

First clone the wger-helm-charts repository and optionally create your_values.yaml file:

git clone https://github.com/wger-project/helm-charts.git
cd helm-charts
vi your_values.yaml

The following is a example of your_values.yaml:

app:
  environment:
      # x-real-ip - remote ip - x-forward-for  -
    - name: GUNICORN_CMD_ARGS
      value: "--timeout 240 --workers=2 --access-logformat '%({x-real-ip}i)s %(l)s %(h)s %(l)s %({x-forwarded-for}i)s %(l)s %(t)s \"%(r)s\" %(s)s %(b)s \"%(f)s\" \"%(a)s\"' --access-logfile - --error-logfile -"
  nginx:
    enabled: true
  axes:
    enabled: true
celery:
  enabled: true
  flower:
    enabled: true

Deploy the helm chart from the cloned git repo. Omit -f ../../your_values.yaml when you don't have the file:

cd helm-charts/charts/wger
helm dependency update
helm upgrade --install wger . -n wger --create-namespace -f ../../your_values.yaml

To access the webinterface, you can port forward 8000 from the wger app to a port on your machine, be aware you need a high port number, which doesn't require root priviledges.

export POD=$(kubectl get pods -n wger -l "app.kubernetes.io/name=wger-app" -o jsonpath="{.items[0].metadata.name}")
echo "wger runs on: http://localhost:10001"; kubectl -n wger port-forward ${POD} 10001:8000

Go to http://localhost:10001 and login as admin adminadmin ;-)

Advanced Setup

When you activated nginx persistent storage will be automatically activated as a requirement. You can see the volumes (pv) and it's claims (pvc):

kubectl get pv
kubectl get pvc -n wger

@todo sorry but, mounting with rootless podman and minikube doesn't work yet

There is a special claim code which will not be created but will overload the wger django code, this can be used to mount your local development code into the setup.

First checkout the code to in the example i use $HOME/test/wger.

As minikube is running in a VM we first need to mount the local files into the minikube VM to make it available for the kubernetes cluster. You can login to the minikube VM with minikube ssh.

Now mount the folder into the minikube system, i use /wger-code here.

minikube stop
minikube start --cni calico --mount-string="$HOME/test/wger:/wger-code"
# or
minikube mount $HOME/test/wger:/wger-code

Add the following to your_values.yaml.

app:
  persistence:
    existingClaim:
      code: wger-code

Manually create a volume and claim for your local wger code. For this add a new file wger-code.yaml and apply it to the cluster:

TBD
kubectl create ns wger
kubectl apply -n wger -f ../../wger-code-volume.yaml

Activate the new values with the wger-code volume in the containers:

helm upgrade --install wger . -n wger --create-namespace -f ../../your_values.yaml

Uninstall wger

To uninstall:

helm -n wger uninstall wger
kubectl -n wger delete -f ../../wger-code-volume.yaml
kubectl delete ns wger