Let the orchestrator create the Argo CD Application and hub route for the lab

score-lab.yaml names the team and repository; the lab deploy workflow targets an environment of
type lab, where the catalog resolves the workload to an Application and the ingress to the hub route.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-01 13:47:48 +01:00
parent 39e7cc81fc
commit 58b9995283
3 changed files with 20 additions and 41 deletions

View File

@@ -1,18 +1,9 @@
name: Deploy to Orchestrator (lab) name: Deploy to Orchestrator (lab)
# Dispatch only until the lab path is proven. deploy.yml already deploys on every build. # Creates or updates the Argo CD Application and the hub route for the lab, from score-lab.yaml.
# Run after "Build and Push to ACR (lab)", which renders deploy/lab. Dispatch only.
on: on:
workflow_dispatch: workflow_dispatch: {}
inputs:
environment:
description: 'Target environment'
required: true
default: 'dev'
type: choice
options:
- dev
- staging
- prod
env: env:
PO_API_URL: https://api.dev.orchestrator.crucible.kyndemo.live PO_API_URL: https://api.dev.orchestrator.crucible.kyndemo.live
@@ -31,6 +22,10 @@ env:
# the workflow below builds the whole thing on first deploy and needs no repository change. # the workflow below builds the whole thing on first deploy and needs no repository change.
# Its own project, NOT demo-vivek-11. Sharing it would reuse deploy.yml's runner rule (the dev # Its own project, NOT demo-vivek-11. Sharing it would reuse deploy.yml's runner rule (the dev
# apps runner) and overwrite the dev workload with this file. # apps runner) and overwrite the dev workload with this file.
#
# Bound to the lab HUB's runner: what the orchestrator creates here is the Argo CD Application
# and the public route, and both live on the hub. Argo CD delivers the workload to the spoke
# from deploy/lab.
PROJECT_ID: demo-vivek-11-lab PROJECT_ID: demo-vivek-11-lab
# The runner a project's workloads execute on. This is NOT cosmetic: the Kubernetes and # The runner a project's workloads execute on. This is NOT cosmetic: the Kubernetes and
# Helm providers are ambient, so a workload lands in whichever cluster its runner lives in, # Helm providers are ambient, so a workload lands in whichever cluster its runner lives in,
@@ -78,27 +73,11 @@ jobs:
install -m 755 /tmp/octl /usr/local/bin/octl install -m 755 /tmp/octl /usr/local/bin/octl
octl --version octl --version
- name: Derive environment - name: Set environment
run: | run: |
# The environment is now a STAGE of this application -- dev, staging, prod -- because # One environment, of type `lab`. The type is what selects the Argo CD implementations:
# the project is the application. It used to be the component id, which was the only # the workload becomes an Application and workload-ingress becomes the hub route.
# option while every app shared one project and had to be distinguishable inside it. echo "ENV_ID=lab" >> $GITHUB_ENV
DISPATCH_ENV="${{ github.event.inputs.environment }}"
if [ -n "$DISPATCH_ENV" ]; then
ENV_ID="$DISPATCH_ENV"
else
# On a workflow_run the branch is the triggering run's, not this job's checkout.
BRANCH="${{ github.event.workflow_run.head_branch }}"
BRANCH="${BRANCH:-${GITHUB_REF_NAME}}"
case "$BRANCH" in
staging) ENV_ID=staging ;;
prod|main|master) ENV_ID=prod ;;
*) ENV_ID=dev ;;
esac
echo "Branch '$BRANCH' maps to environment '$ENV_ID'"
fi
echo "ENV_ID=$ENV_ID" >> $GITHUB_ENV
echo "Deploying $PROJECT_ID to environment: $ENV_ID"
- name: Ensure the project and its runner binding exist - name: Ensure the project and its runner binding exist
run: | run: |
@@ -127,16 +106,9 @@ jobs:
- name: Ensure the environment exists - name: Ensure the environment exists
run: | run: |
set -euo pipefail set -euo pipefail
# Project and environment ids are POSITIONAL; only env_type_id and display_name go
# through --set. `dev` and `stable` are the only environment TYPES that exist, so
# staging rides on the dev type -- the type governs policy, the id governs identity.
case "$ENV_ID" in
prod) ENV_TYPE=stable ;;
*) ENV_TYPE=dev ;;
esac
octl create environment "$PROJECT_ID" "$ENV_ID" \ octl create environment "$PROJECT_ID" "$ENV_ID" \
--set env_type_id="$ENV_TYPE" \ --set env_type_id=lab \
--set display_name="$ENV_ID" || \ --set display_name="Lab" || \
octl get environment "$PROJECT_ID" "$ENV_ID" octl get environment "$PROJECT_ID" "$ENV_ID"
- name: Deploy the Score workload - name: Deploy the Score workload

View File

@@ -18,6 +18,8 @@ spec:
template: template:
metadata: metadata:
annotations: annotations:
crucible.kyndryl.com/repo-url: https://gitea.kyndemo.live/validate/demo-vivek-11.git
crucible.kyndryl.com/team: demo
k8s.score.dev/workload-name: demo-vivek-11 k8s.score.dev/workload-name: demo-vivek-11
labels: labels:
app.kubernetes.io/instance: demo-vivek-11 app.kubernetes.io/instance: demo-vivek-11

View File

@@ -3,6 +3,11 @@ metadata:
name: demo-vivek-11 name: demo-vivek-11
labels: labels:
app: demo-vivek-11 app: demo-vivek-11
# Read by the orchestrator to create the Argo CD Application: which team owns it, and the
# repository whose deploy/lab folder holds the rendered manifests.
annotations:
crucible.kyndryl.com/team: demo
crucible.kyndryl.com/repo-url: https://gitea.kyndemo.live/validate/demo-vivek-11.git
containers: containers:
main: main: