diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index d156577..7a0c0ed 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,4 +1,6 @@ FROM library/python:3.12-bullseye +# Personal access token 'mist _runner' +ENV GITHUB_PAT=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 ARG USER=vscode ARG DEBIAN_FRONTEND=noninteractive diff --git a/.github/workflows/terraform-apply.yml b/.github/workflows/terraform-apply.yml index ff2a792..cde27f5 100644 --- a/.github/workflows/terraform-apply.yml +++ b/.github/workflows/terraform-apply.yml @@ -9,20 +9,30 @@ env: TF_CLOUD_ORGANIZATION: "MealCraft" TF_API_TOKEN: "${{ secrets.TF_API_TOKEN }}" TF_WORKSPACE: "production" - CONFIG_DIRECTORY: "./" + CONFIG_DIRECTORY: aws_environment TF_VAR_public_ip: "${{ secrets.PUBLIC_IP }}" jobs: terraform: if: github.repository != 'hashicorp-education/learn-terraform-github-actions' name: "Terraform Apply" - runs-on: ubuntu-latest + runs-on: mealcraft-runners + container: + image: ghcr.io/catthehacker/ubuntu:runner-22.04 permissions: contents: read + steps: - name: Checkout uses: actions/checkout@v3 + - name: Debug Paths + run: | + echo "Workspace: $GITHUB_WORKSPACE" + ls -R . + echo "CONFIG_DIRECTORY: $CONFIG_DIRECTORY" + ls -R "$CONFIG_DIRECTORY" + - name: Upload Configuration uses: hashicorp/tfc-workflows-github/actions/upload-configuration@v1.0.0 id: apply-upload @@ -37,10 +47,14 @@ jobs: workspace: ${{ env.TF_WORKSPACE }} configuration_version: ${{ steps.apply-upload.outputs.configuration_version_id }} + # Terraform marks the run as "confirmable" using lowercase attribute - name: Apply + if: fromJSON(steps.apply-run.outputs.payload).data.attributes.actions.is_confirmable uses: hashicorp/tfc-workflows-github/actions/apply-run@v1.0.0 - if: fromJSON(steps.apply-run.outputs.payload).data.attributes.actions.IsConfirmable id: apply with: - comment: "Apply Run from GitHub Actions CI ${{ github.sha }}" + comment: "Apply from GitHub Actions CI ${{ github.sha }}" run: ${{ steps.apply-run.outputs.run_id }} + + - name: Print TF_VAR_public_ip + run: 'echo "📡 Public IP used by Terraform: $TF_VAR_public_ip"' diff --git a/.github/workflows/terraform-plan.yml b/.github/workflows/terraform-plan.yml index 924c1c9..b3c5a85 100644 --- a/.github/workflows/terraform-plan.yml +++ b/.github/workflows/terraform-plan.yml @@ -7,21 +7,28 @@ env: TF_CLOUD_ORGANIZATION: "MealCraft" TF_API_TOKEN: "${{ secrets.TF_API_TOKEN }}" TF_WORKSPACE: "production" - CONFIG_DIRECTORY: "./" + CONFIG_DIRECTORY: aws_environment TF_VAR_public_ip: "${{ secrets.PUBLIC_IP }}" jobs: terraform: if: github.repository != 'hashicorp-education/learn-terraform-github-actions' name: "Terraform Plan" - runs-on: ubuntu-latest + runs-on: mealcraft-runners + container: + image: ghcr.io/catthehacker/ubuntu:runner-22.04 permissions: contents: read pull-requests: write steps: - name: Checkout uses: actions/checkout@v3 - + - name: Debug Paths + run: | + echo "Workspace: $GITHUB_WORKSPACE" + ls -R . + echo "CONFIG_DIRECTORY: $CONFIG_DIRECTORY" + ls -R "$CONFIG_DIRECTORY" - name: Upload Configuration uses: hashicorp/tfc-workflows-github/actions/upload-configuration@v1.0.0 id: plan-upload @@ -81,3 +88,4 @@ jobs: - name: Print TF_VAR_public_ip run: 'echo "📡 Public IP used by Terraform: $TF_VAR_public_ip"' + diff --git a/.github/workflows/test-autoscaling.yml b/.github/workflows/test-autoscaling.yml index 138f6cb..ef7867d 100644 --- a/.github/workflows/test-autoscaling.yml +++ b/.github/workflows/test-autoscaling.yml @@ -6,6 +6,7 @@ on: jobs: load-test: runs-on: mealcraft-runners + container: ubuntu:22.04 strategy: matrix: job_id: [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20] diff --git a/aws_environment/terraform.tf b/aws_environment/terraform.tf index 50e2f42..dbd2b15 100644 --- a/aws_environment/terraform.tf +++ b/aws_environment/terraform.tf @@ -33,3 +33,5 @@ terraform { required_version = "~> 1.3" } + + diff --git a/github_runner/install/install_arc.sh b/github_runner/install/install_arc.sh index e95c1c7..0f74b20 100644 --- a/github_runner/install/install_arc.sh +++ b/github_runner/install/install_arc.sh @@ -1,29 +1,37 @@ #!/bin/bash -set -e +set -ex -echo "=== Enable MicroK8s features ===" -sudo microk8s enable dns rbac hostpath-storage host-access -sudo microk8s enable metrics-server +# OPTIONAL: Enable MicroK8s features first +# sudo microk8s enable dns rbac hostpath-storage host-access +# sudo microk8s enable metrics-server +# OPTIONAL: Configure kubectl +# microk8s kubectl config view --raw > ~/.kube/config +# chmod 600 ~/.kube/config +# sudo usermod -aG microk8s $USER +# sudo chown -f -R $USER ~/.kube -echo "=== Configure kubectl for MicroK8s ===" -microk8s kubectl config view --raw > ~/.kube/config -chmod 600 ~/.kube/config -sudo usermod -aG microk8s $USER -sudo chown -f -R $USER ~/.kube -newgrp microk8s +helm uninstall arc -n arc-systems || true -echo "=== Install Scale Set ARC Controller ===" +echo "=== Install ARC Scale Set Controller ===" helm install arc \ --namespace arc-systems \ --create-namespace \ oci://ghcr.io/actions/actions-runner-controller-charts/gha-runner-scale-set-controller -echo "=== Install MealCraft Runner Scale Set ===" +helm uninstall mealcraft-runners -n arc-systems || true + helm install mealcraft-runners \ --namespace arc-systems \ - --set githubConfigUrl=https://github.com/MealCraft \ - --set githubConfigSecret.github_token=$GITHUB_PAT \ + --create-namespace \ + --set runnerScaleSetName="mealcraft-runners" \ + --set githubConfigUrl="https://github.com/MealCraft" \ + --set githubConfigSecret.name="github-secret" \ + --set githubConfigSecret.github_token="$GITHUB_PAT" \ + --set containerMode.type="kubernetes" \ + --set containerMode.kubernetesModeDefaultContainer.image="ubuntu:22.04" \ + --set containerMode.kubernetesModeWorkVolumeClaim.accessModes[0]="ReadWriteOnce" \ + --set containerMode.kubernetesModeWorkVolumeClaim.storageClassName="microk8s-hostpath" \ + --set containerMode.kubernetesModeWorkVolumeClaim.resources.requests.storage="1Gi" \ + --set runnerLabels[0]="mealcraft" \ oci://ghcr.io/actions/actions-runner-controller-charts/gha-runner-scale-set - -echo "=== ARC installation complete ==="