diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 7a1c5b0..cdea507 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -2,7 +2,7 @@ FROM public.ecr.aws/docker/library/debian:bookworm-slim ARG EDA_VERSION=25.12.1 -ARG EDA_PLAYGROUND_REPO=kaelemc/playground +ARG EDA_PLAYGROUND_REPO=nokia-eda/playground ARG EDA_PLAYGROUND_DIR=/home/vscode/.playground ENV EDA_VERSION=${EDA_VERSION//./-} @@ -21,7 +21,6 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install --no-instal iproute2 \ procps \ vim \ - fontconfig \ xz-utils \ && rm -rf /var/lib/apt/lists/* @@ -34,14 +33,12 @@ RUN useradd -m -s /bin/zsh vscode && \ COPY --chmod=755 scripts/ /usr/local/bin/. COPY codespaces-4vcpu-kpt-setters.yaml /eda-codespaces/codespaces-4vcpu-kpt-setters.yaml -RUN curl -fsSL --retry 3 https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | TAG=v5.8.3 bash - # Add EDA Playground tools to PATH (zsh) RUN echo 'export PATH="$PATH:$EDA_PLAYGROUND_DIR/tools"' >> /etc/zsh/zshrc USER vscode -RUN git clone --depth 1 --branch v0.0.1 "https://github.com/$EDA_PLAYGROUND_REPO" $EDA_PLAYGROUND_DIR && cd $EDA_PLAYGROUND_DIR && \ +RUN git clone --depth 1 --branch main "https://github.com/$EDA_PLAYGROUND_REPO" $EDA_PLAYGROUND_DIR && cd $EDA_PLAYGROUND_DIR && \ make download-tools RUN curl -o $HOME/.bundle.yaml "https://raw.githubusercontent.com/nokia-eda/edaadm/refs/heads/main/bundles/eda-bundle-core-$EDA_VERSION.yaml" && \ @@ -55,12 +52,6 @@ RUN SRL=$(curl -s "https://raw.githubusercontent.com/nokia-eda/playground/refs/h RUN sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" RUN curl -sS https://starship.rs/install.sh | sudo sh -s -- -y -# Install Nerd Font for terminal icons (starship, etc.) -RUN mkdir -p /home/vscode/.local/share/fonts && \ - curl -fsSL https://github.com/ryanoasis/nerd-fonts/releases/latest/download/JetBrainsMono.tar.xz | \ - tar -xJf - -C /home/vscode/.local/share/fonts && \ - fc-cache -fv - # copy shell files COPY --chown=vscode:vscode shell/ /home/vscode/ COPY --chown=vscode:vscode shell/starship.toml /home/vscode/.config/starship.toml diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index be36f06..35e2163 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,6 +1,6 @@ { "name": "Nokia EDA in GitHub Codespaces", - "image": "ghcr.io/eda-labs/codespaces/base:main", + "image": "ghcr.io/eda-labs/codespaces/base:kindly", "features": { "ghcr.io/devcontainers/features/docker-in-docker:2": { "version": "latest", diff --git a/.devcontainer/onCreate.sh b/.devcontainer/onCreate.sh index de91b6d..4b72589 100755 --- a/.devcontainer/onCreate.sh +++ b/.devcontainer/onCreate.sh @@ -7,11 +7,3 @@ free -m sudo sysctl -w fs.inotify.max_user_watches=1048576 sudo sysctl -w fs.inotify.max_user_instances=512 -ensure-docker-is-ready - -k3d cluster create eda-demo \ - --image rancher/k3s:v1.34.1-k3s1 \ - --k3s-arg "--disable=traefik@server:*" \ - --k3s-arg "--disable=servicelb@server:*" \ - --volume "$HOME/.images.txt:/opt/images.txt@server:*" \ - --no-lb diff --git a/.devcontainer/overrides.mk b/.devcontainer/overrides.mk index e3d01cf..44eb1c4 100644 --- a/.devcontainer/overrides.mk +++ b/.devcontainer/overrides.mk @@ -31,3 +31,47 @@ define INSTALL_KPT_PACKAGE echo -e "--> INSTALL: [\033[0;32m$2\033[0m] - Applied and reconciled package" ;\ } endef + +.PHONY: patch-codespaces-engineconfig +patch-codespaces-engineconfig: | $(YQ) $(KPT_PKG) ## Patch the EngineConfig manifest to add codespaces custom settings + @{ \ + echo "--> INFO: Patching EngineConfig manifest for codespaces" ;\ + ENGINE_CONFIG_FILE="$(KPT_CORE)/engine-config/engineconfig.yaml" ;\ + if [[ ! -f "$$ENGINE_CONFIG_FILE" ]]; then (echo "[ERROR] EngineConfig manifest not found at $$ENGINE_CONFIG_FILE" && exit 1); fi ;\ + $(YQ) eval '.spec.customSettings = load("$(CODESPACES_ENGINECONFIG_CUSTOM_SETTINGS_PATCH)").customSettings' -i "$$ENGINE_CONFIG_FILE" ;\ + } + +.PHONY: ls-ways-to-reach-api-server +ls-ways-to-reach-api-server: | $(KUBECTL) configure-codespaces-keycloak + +.PHONY: configure-codespaces-keycloak +configure-codespaces-keycloak: | $(KUBECTL) ## Configure Keycloak frontendUrl for GitHub Codespaces + @if [ -n "$(CODESPACE_NAME)" ] && [ -n "$(GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN)" ]; then \ + CODESPACE_URL="https://$(CODESPACE_NAME)-9443.$(GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN)" ;\ + KC_URL="https://eda-keycloak:9443/core/httpproxy/v1/keycloak" ;\ + echo "--> INFO: Configuring Keycloak frontendUrl for Codespaces..." ;\ + $(KUBECTL) wait --for=condition=ready pod -l eda.nokia.com/app=keycloak -n $(EDA_CORE_NAMESPACE) --timeout=300s ;\ + TOKEN=$$($(KUBECTL) exec -n $(EDA_CORE_NAMESPACE) deploy/eda-toolbox -- curl -sk -X POST \ + "$${KC_URL}/realms/master/protocol/openid-connect/token" \ + -d "username=admin" -d "password=admin" -d "grant_type=password" -d "client_id=admin-cli" | jq -r '.access_token') ;\ + $(KUBECTL) exec -n $(EDA_CORE_NAMESPACE) deploy/eda-toolbox -- curl -sk -X PUT \ + "$${KC_URL}/admin/realms/eda" \ + -H "Authorization: Bearer $${TOKEN}" \ + -H "Content-Type: application/json" \ + -d "{\"attributes\": {\"frontendUrl\": \"$${CODESPACE_URL}/core/httpproxy/v1/keycloak\"}}" ;\ + echo "--> INFO: Keycloak frontendUrl set to: $${CODESPACE_URL}/core/httpproxy/v1/keycloak" ;\ + else \ + echo "--> INFO: Not running in Codespaces, skipping Keycloak frontendUrl configuration" ;\ + fi + + +.PHONY: metallb-operator +metallb-operator: | $(BASE) $(BUILD) $(KUBECTL) ; $(info --> LB: Loading the load balancer, metallb in the cluster) + @{ \ + $(KUBECTL) apply -f $(CFG)/metallb-native.yaml | $(INDENT_OUT) ;\ + sleep 15 ;\ + $(KUBECTL) wait --namespace metallb-system \ + --for=condition=ready pod \ + --selector=app=metallb \ + --timeout=120s | $(INDENT_OUT);\ + } \ No newline at end of file diff --git a/.devcontainer/postAttach.sh b/.devcontainer/postAttach.sh index 55284f9..d848397 100755 --- a/.devcontainer/postAttach.sh +++ b/.devcontainer/postAttach.sh @@ -1,16 +1,23 @@ #!/bin/bash echo " - .:.... - .:=**+--:. _____ ____ _ ___ ____ _ _ ____ - :=*******##**+-:.. | ____| _ \ / \ |_ _/ ___| | | | | _ \ - .=+******###*++=-::. | _| | | | |/ _ \ | |\___ \ | | | | |_) | - -+++******######***=... | |___| |_| / ___ \ | | ___) | | |_| | __/ - -++++******#######+----. |_____|____/_/ \_\ |___|____/ \___/|_| - .-++++++******#########*-:::. - .++++++++******########=:=:. - ..-=---=++++******#########+ .. - .. -++++=-:::-=+####::*= URL: https://${CODESPACE_NAME}-${EDA_PORT}.${GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN} - =++: +##* . - .:. .-: + ╔═══════════════════════════════════════╗ + ║ ║ + ║ ██████╗ ██╗ ██╗███╗ ██╗ ║ + ║ ██╔══██╗██║ ██║████╗ ██║ ║ + ║ ██████╔╝██║ ██║██╔██╗ ██║ ║ + ║ ██╔══██╗██║ ██║██║╚██╗██║ ║ + ║ ██║ ██║╚██████╔╝██║ ╚████║ ║ + ║ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝ ║ + ║ ███████╗██████╗ █████╗ ║ + ║ ██╔════╝██╔══██╗██╔══██╗ ║ + ║ █████╗ ██║ ██║███████║ ║ + ║ ██╔══╝ ██║ ██║██╔══██║ ║ + ║ ███████╗██████╔╝██║ ██║ ║ + ║ ╚══════╝╚═════╝ ╚═╝ ╚═╝ ║ + ║ ║ + ╚═══════════════════════════════════════╝ + + ⚡ URL: https://${CODESPACE_NAME}-${EDA_PORT}.${GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN} + " \ No newline at end of file diff --git a/.devcontainer/postCreate.sh b/.devcontainer/postCreate.sh index 1182e8a..9ec044a 100755 --- a/.devcontainer/postCreate.sh +++ b/.devcontainer/postCreate.sh @@ -5,8 +5,20 @@ cd $EDA_PLAYGROUND_DIR ensure-docker-is-ready +# start the kind cluster +make kind -TOKEN=$($EDA_PLAYGROUND_DIR/tools/yq -o=json '.assets.registries[].auth' $HOME/.bundle.yaml | jq -r '(reduce range(.extraEncodeCount + 1) as $_ (.username; @base64d)) + ":" + (reduce range(.extraEncodeCount + 1) as $_ (.password; @base64d))') -docker exec k3d-eda-demo-server-0 sh -c "cat /opt/images.txt | xargs -P $(nproc) -I {} crictl pull --creds $TOKEN {}" +# get token +encoded=$(grep 'GH_PKG_TOKEN ?=' "Makefile" | sed 's/.*?= *//') +prefix=$(printf '%s' 'Z2hwCg==' | base64 -d) +suffix=$(printf '%s' "$encoded" | base64 -d | cut -c 4- | tr -d '\n') +TOKEN="${prefix}${suffix}" -make -f Makefile -f $TRY_EDA_OVERRIDES_FILE try-eda NO_KIND=yes NO_LB=yes KPT_SETTERS_FILE=$TRY_EDA_KPT_SETTERS_FILE \ No newline at end of file +# preload images into kind cluster from the EDA core list +docker cp /home/vscode/.images.txt eda-demo-control-plane:/opt/images.txt +docker exec eda-demo-control-plane sh -c "cat /opt/images.txt | xargs -P $(nproc) -I {} crictl pull --creds nokia-eda-bot:$TOKEN {}" + +make -f Makefile -f $TRY_EDA_OVERRIDES_FILE try-eda KPT_SETTERS_FILE=$TRY_EDA_KPT_SETTERS_FILE + +# apply keycloak patch for codespaces redirects +# make -f Makefile -f $TRY_EDA_OVERRIDES_FILE configure-codespaces-keycloak KPT_SETTERS_FILE=$TRY_EDA_KPT_SETTERS_FILE \ No newline at end of file