Skip to content

Commit

Permalink
feat: make job into multi-cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
joryirving committed Dec 29, 2024
1 parent bdeccc6 commit ced7b05
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 23 deletions.
44 changes: 29 additions & 15 deletions .github/workflows/pre-pull-images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ name: "Pre-pull Images"
on:
pull_request:
branches: ["main"]
paths: ["kubernetes/**"]
paths:
- kubernetes/**/apps/**
- kubernetes/**/flux/**
- kubernetes/shared/**

concurrency:
group: ${{ github.workflow }}-${{ github.event.number || github.ref }}
Expand Down Expand Up @@ -70,7 +73,7 @@ jobs:
fail-fast: false
outputs:
images: ${{ steps.extract-images.outputs.images }}
paths: ${{ fromJSON(needs.changed-clusters.outputs.matrix) }}
paths: ${{ needs.changed-clusters.outputs.matrix }}
steps:
- name: Configure 1password
uses: 1password/load-secrets-action/configure@v2
Expand All @@ -92,12 +95,12 @@ jobs:
app-id: ${{ env.BOT_APP_ID }}
private-key: ${{ env.BOT_APP_PRIVATE_KEY }}

- name: Setup mise
uses: jdx/mise-action@v2
with:
mise_toml: |
[tools]
"aqua:mikefarah/yq" = "latest"
- name: Setup Homebrew
uses: Homebrew/actions/setup-homebrew@master

- name: Setup Workflow Tools
shell: bash
run: brew install jo yq

- name: Checkout Default Branch
uses: actions/checkout@v4
Expand Down Expand Up @@ -182,17 +185,28 @@ jobs:
with:
export-env: true
env:
TALOSCONFIG: op://Kubernetes/kubernetes/TALOSCONFIG_${{ env.cluster }}
TALOSCONFIG_BASE64: op://Kubernetes/kubernetes/TALOSCONFIG_${{ env.cluster }}_BASE64

- name: Setup mise
uses: jdx/mise-action@v2
- name: Write talosconfig
id: talosconfig
uses: timheuer/base64-to-file@v1
with:
mise_toml: |
[tools]
"aqua:siderolabs/talos" = "latest"
encodedString: "${{ env.TALOSCONFIG_BASE64 }}"
fileName: talosconfig

- name: Setup Homebrew
uses: Homebrew/actions/setup-homebrew@master

- name: Setup Workflow Tools
shell: bash
run: brew install siderolabs/tap/talosctl

- name: Pre-pull Image
run: talosctl -n $NODE_IP image pull ${{ matrix.images }}
env:
TALOSCONFIG: ${{ steps.talosconfig.outputs.filePath }}
run: |
NODE=$(talosctl config info --output json | jq --raw-output '.nodes[]' | shuf -n 1)
talosctl -n $NODE image pull ${{ matrix.images }}
# Summarize matrix https://github.community/t/status-check-for-a-matrix-jobs/127354/7
pre-pull-images-success:
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/schemas.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
env:
BOT_APP_ID: op://Kubernetes/github-bot/BOT_APP_ID
BOT_APP_PRIVATE_KEY: op://Kubernetes/github-bot/BOT_APP_PRIVATE_KEY
KUBECONFIG: op://Kubernetes/kubernetes/KUBECONFIG_BASE64
KUBECONFIG_BASE64: op://Kubernetes/kubernetes/KUBECONFIG_BASE64
CLOUDFLARE_API_TOKEN: op://Kubernetes/cloudflare/CLOUDFLARE_API_TOKEN_GHA
CLOUDFLARE_ACCOUNT_ID: op://Kubernetes/cloudflare/CLOUDFLARE_ACCOUNT_TAG

Expand All @@ -46,12 +46,12 @@ jobs:
with:
token: ${{ steps.app-token.outputs.token }}

- name: Setup mise
uses: jdx/mise-action@v2
with:
mise_toml: |
[tools]
"aqua:kubernetes/kubectl" = "latest"
- name: Setup Homebrew
uses: Homebrew/actions/setup-homebrew@master

- name: Setup Workflow Tools
shell: bash
run: brew install kubectl

- name: Setup Python
uses: actions/setup-python@v5
Expand All @@ -67,7 +67,7 @@ jobs:
id: kubeconfig
uses: timheuer/base64-to-file@v1
with:
encodedString: ${{ env.KUBECONFIG }}
encodedString: "${{ env.KUBECONFIG_BASE64 }}"
fileName: kubeconfig

- name: Download and run crd-extractor
Expand Down
2 changes: 2 additions & 0 deletions .taskfiles/onepassword/Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ tasks:
cmds:
- op item edit kubernetes KUBECONFIG_MAIN[text]="$(cat {{.ROOT_DIR}}/kubernetes/main/kubeconfig)" &>/dev/null
- op item edit kubernetes TALOSCONFIG_MAIN[text]="$(cat {{.ROOT_DIR}}/kubernetes/main/talos/clusterconfig/talosconfig)" &>/dev/null
- op item edit kubernetes TALOSCONFIG_MAIN_BASE64[text]="$(cat {{.ROOT_DIR}}/kubernetes/main/talos/clusterconfig/talosconfig | base64 -w 0)" &>/dev/null
preconditions:
- which op

Expand All @@ -26,6 +27,7 @@ tasks:
cmds:
- op item edit kubernetes KUBECONFIG_UTILITY[text]="$(cat {{.ROOT_DIR}}/kubernetes/utility/kubeconfig)" &>/dev/null
- op item edit kubernetes TALOSCONFIG_UTILITY[text]="$(cat {{.ROOT_DIR}}/kubernetes/utility/talos/clusterconfig/talosconfig)" &>/dev/null
- op item edit kubernetes TALOSCONFIG_UTILITY_BASE64[text]="$(cat {{.ROOT_DIR}}/kubernetes/main/talos/clusterconfig/talosconfig | base64 -w 0)" &>/dev/null
preconditions:
- which op

Expand Down

0 comments on commit ced7b05

Please sign in to comment.