Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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//./-}
Expand All @@ -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/*

Expand All @@ -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" && \
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
8 changes: 0 additions & 8 deletions .devcontainer/onCreate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
44 changes: 44 additions & 0 deletions .devcontainer/overrides.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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);\
}
31 changes: 19 additions & 12 deletions .devcontainer/postAttach.sh
Original file line number Diff line number Diff line change
@@ -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}

"
18 changes: 15 additions & 3 deletions .devcontainer/postCreate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
# 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