From a50814a6684de0cb0ede3b29e42cd82302e47bf9 Mon Sep 17 00:00:00 2001 From: Anurag Mittal Date: Wed, 13 Nov 2024 07:12:07 +0000 Subject: [PATCH] COSI-17: add-dev-container-for-sodi-driver - the container sets up minikube, s3 and iam services. --- .devcontainer/devcontainer.json | 42 +++++++++++++++++++++++++ .devcontainer/setup-dev-container.sh | 32 +++++++++++++++++++ .github/scripts/setup_cosi_resources.sh | 2 +- 3 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 .devcontainer/devcontainer.json create mode 100644 .devcontainer/setup-dev-container.sh mode change 100644 => 100755 .github/scripts/setup_cosi_resources.sh diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..67fc28f --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,42 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/go +{ + "name": "Go Dev Container", + "image": "mcr.microsoft.com/devcontainers/go:1-1.23-bookworm", + // Features to add to the dev container. More info: https://containers.dev/features. + "features": { + "ghcr.io/devcontainers/features/go:1": { + "version": "latest" + }, + "ghcr.io/devcontainers/features/docker-in-docker:2": { + "version": "latest", + "moby": true + }, + "ghcr.io/devcontainers/features/aws-cli:1": {}, + "ghcr.io/devcontainers/features/kubectl-helm-minikube:1": { + "version": "1.31", + "helm": "latest", + "minikube": "latest" + } + }, + "forwardPorts": [8000, 8600], + "customizations": { + "codespaces": { + "repositories": { + "scality/cloudserver": { + "permissions": { + "packages": "read" + } + }, + "scality/vault": { + "permissions": { + "packages": "read" + } + } + } + } + }, + "postCreateCommand": "bash .devcontainer/setup-dev-container.sh" + // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "root" +} diff --git a/.devcontainer/setup-dev-container.sh b/.devcontainer/setup-dev-container.sh new file mode 100644 index 0000000..3a6604d --- /dev/null +++ b/.devcontainer/setup-dev-container.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +echo "Installing Ginkgo and Gomega..." +go install github.com/onsi/ginkgo/v2/ginkgo +go get github.com/onsi/gomega/... + +# Create a KIND cluster +echo "Starting Minikube..." +minikube start + +echo "Logging into GHCR (GitHub Container Registry)..." +echo "$REPOSITORY_USER_TOKEN" | docker login ghcr.io -u "$REPOSITORY_USER" --password-stdin + +# Navigate to the directory and prepare the environment +echo "Preparing S3 and IAM log and directories..." +cd .github/s3_and_iam_deployment && \ +mkdir -p logs/s3 logs/iam logs/cosi_driver data/vaultdb && \ +sudo chown -R vscode:vscode logs data && \ +chmod -R ugo+rwx logs data && \ + +# Start Docker Compose for the 'iam_s3' profile +echo "Deploying S3 and IAM using docker compose..." +docker compose --profile iam_s3 up -d + +# Set Minikube's Docker environment variables +eval $(minikube docker-env) + +# Prune Docker on Minikube's Docker Daemon +echo "Pruning unused images..." +docker system prune -af + +echo "Setup complete." diff --git a/.github/scripts/setup_cosi_resources.sh b/.github/scripts/setup_cosi_resources.sh old mode 100644 new mode 100755 index 71f5649..21f6dd0 --- a/.github/scripts/setup_cosi_resources.sh +++ b/.github/scripts/setup_cosi_resources.sh @@ -54,7 +54,7 @@ fi # Step 6: Verify COSI driver Pod Status log_and_run echo "Verifying COSI driver Pod status..." -if ! kubectl wait --namespace scality-object-storage --for=condition=ready pod --selector=app.kubernetes.io/name=scality-cosi-driver --timeout=20s; then +if ! kubectl wait --namespace scality-object-storage --for=condition=ready pod --selector=app.kubernetes.io/name=scality-cosi-driver --timeout=30s; then echo "Error: COSI driver Pod did not reach ready state." | tee -a "$LOG_FILE" exit 1 fi