c4k-keycloak/doc/Development.md

108 lines
2.8 KiB
Markdown
Raw Permalink Normal View History

2021-05-17 07:28:01 +00:00
# Project Setup
## clj setup
2021-05-17 17:23:36 +00:00
### install leiningen
2024-07-04 10:13:07 +00:00
```bash
2021-05-17 17:23:36 +00:00
sudo apt install leiningen
```
or manually using Instructions on https://leiningen.org/#install
### install vscode + extensions
2024-07-04 10:13:07 +00:00
```bash
2021-05-20 15:00:54 +00:00
sudo snap install code
2021-05-17 17:23:36 +00:00
```
or with packages from https://code.visualstudio.com/Download
install extension "Calva: Clojure & ClojureScript Interactive Programming"
2021-05-17 07:28:01 +00:00
## cljs / js-dev setup
2024-07-04 10:13:07 +00:00
```bash
2021-05-17 07:28:01 +00:00
sudo apt install npm
sudo npm install -g npx
# maybe
sudo npm install -g shadow-cljs
# in project root to retrieve all dependencies
npm install --ignore-scripts
npx shadow-cljs compile test
```
### create frontend script
2024-07-04 10:13:07 +00:00
```bash
2021-05-17 07:28:01 +00:00
npx shadow-cljs release frontend
```
## graalvm-setup
2024-07-04 10:13:07 +00:00
```bash
curl -LO https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-21.0.2/graalvm-community-jdk-21.0.2_linux-x64_bin.tar.gz
2021-05-17 07:28:01 +00:00
# unpack
2024-07-04 10:13:07 +00:00
tar -xzf graalvm-community-jdk-21.0.2_linux-x64_bin.tar.gz
2021-05-17 07:28:01 +00:00
2024-07-04 10:13:07 +00:00
sudo mv graalvm-community-openjdk-21.0.2+13.1 /usr/lib/jvm/
sudo ln -s /usr/lib/jvm/graalvm-community-openjdk-21.0.2+13.1 /usr/lib/jvm/graalvm-21
sudo ln -s /usr/lib/jvm/graalvm-21/bin/gu /usr/local/bin
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/graalvm-21/bin/java 2
2021-05-17 07:28:01 +00:00
sudo update-alternatives --config java
2024-07-04 10:13:07 +00:00
sudo ln -s /usr/lib/jvm/graalvm-21/bin/native-image /usr/local/bin
2021-05-17 07:28:01 +00:00
# deps
sudo apt-get install build-essential libz-dev zlib1g-dev
# build
2024-07-04 10:13:07 +00:00
cd ~/repo/c4k/c4k-keycloak
2021-05-17 07:28:01 +00:00
lein uberjar
mkdir -p target/graalvm
lein native
# execute
2024-07-04 10:13:07 +00:00
./target/graalvm/c4k-cloud -h
./target/graalvm/c4k-cloud src/test/resources/valid-config.edn src/test/resources/valid-auth.edn
./target/graalvm/c4k-cloud src/test/resources/invalid-config.edn src/test/resources/invalid-auth.edn
2021-05-17 07:28:01 +00:00
```
2021-06-05 15:27:42 +00:00
## c4k-setup
2021-05-17 07:28:01 +00:00
### install kubectl
2024-07-04 10:13:07 +00:00
```bash
2021-05-17 07:28:01 +00:00
sudo -i
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" \
| tee -a /etc/apt/sources.list.d/kubernetes.list
apt update && apt install kubectl
kubectl completion bash >> /etc/bash_completion.d/kubernetes
```
2021-05-28 15:03:40 +00:00
### install kubeconform
2021-05-17 07:28:01 +00:00
2024-07-04 10:13:07 +00:00
```bash
2021-05-28 15:03:40 +00:00
curl -Lo /tmp/kubeconform.tar.gz https://github.com/yannh/kubeconform/releases/download/v0.4.7/kubeconform-linux-amd64.tar.gz
tar -xf /tmp/kubeconform.tar.gz
sudo cp kubeconform /usr/local/bin
2021-05-17 07:28:01 +00:00
```
2021-06-05 15:27:42 +00:00
### remote access to c4k
2021-05-17 07:28:01 +00:00
2024-07-04 10:13:07 +00:00
```bash
2021-06-05 15:27:42 +00:00
scp -r root@devops.test.meissa-gmbh.de:/home/c4k/.kube ~/
2021-05-17 07:28:01 +00:00
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@devops.test.meissa-gmbh.de -L 8002:localhost:8002 -L 6443:192.168.5.1:6443
# add in /etc/hosts "127.0.0.1 kubernetes"
# change in ~/.kube/config 192.168.5.1 -> kubernetes
kubectl get pods
```
### deploy keycloak
2024-07-04 10:13:07 +00:00
```bash
2021-06-05 15:27:42 +00:00
java -jar target/uberjar/c4k-keycloak-standalone.jar valid-config.edn valid-auth.edn | kubeconform --kubernetes-version 1.19.0 --strict --skip Certificate -
java -jar target/uberjar/c4k-keycloak-standalone.jar valid-config.edn my-auth.edn | kubectl apply -f -
2021-05-17 17:23:36 +00:00
```