Deliver the lab from manifests rendered from score-lab.yaml
deploy/lab is rendered by score-k8s with the platform's provisioners and replaces the hand-written deploy/manifests. The lab build workflow now renders and commits it after the build. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
name: Build and Push to ACR (lab)
|
||||
|
||||
# Dispatch only while the lab path is proven. Build and deploy the SAME commit: the deploy tags
|
||||
# the image with the commit it was dispatched from.
|
||||
# Dispatch only while the lab path is proven. Builds the image for the dispatched commit, then
|
||||
# renders score-lab.yaml with the platform's provisioners and commits the result to deploy/lab,
|
||||
# which Argo CD delivers.
|
||||
on:
|
||||
workflow_dispatch: {}
|
||||
|
||||
@@ -11,6 +12,13 @@ concurrency:
|
||||
|
||||
env:
|
||||
AZURE_FEDERATED_TOKEN_FILE: /var/run/secrets/azure/tokens/azure-identity-token
|
||||
ACR_LOGIN_SERVER: cruciblecoredevacr.azurecr.io
|
||||
# Platform provisioners release. Upgrading is a change to this pin.
|
||||
PROVISIONERS_VERSION: v0.1.0
|
||||
SCORE_K8S_VERSION: 0.19.0
|
||||
SCORE_K8S_SHA256: 7c62f3585f1864cad7c4032557e183cb65fef22a7a15f3cbe22365849ca95e2c
|
||||
ORAS_VERSION: 1.2.3
|
||||
ORAS_SHA256: b4efc97a91f471f323f193ea4b4d63d8ff443ca3aab514151a30751330852827
|
||||
|
||||
jobs:
|
||||
build:
|
||||
@@ -78,3 +86,76 @@ jobs:
|
||||
echo "| **Service** | demo-vivek-11 |" >> $GITHUB_STEP_SUMMARY
|
||||
echo "| **Commit** | ${{ gitea.sha }} |" >> $GITHUB_STEP_SUMMARY
|
||||
echo "| **Image** | $IMAGE_FULL |" >> $GITHUB_STEP_SUMMARY
|
||||
|
||||
render:
|
||||
name: Render manifests
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
id-token: write
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install tools
|
||||
run: |
|
||||
command -v az &>/dev/null || curl -sL https://aka.ms/InstallAzureCLIDeb | bash
|
||||
python3 -c 'import yaml' 2>/dev/null || (apt-get update -qq && apt-get install -y python3-yaml)
|
||||
mkdir -p "$HOME/bin" && cd "$(mktemp -d)"
|
||||
curl -fsSL -o score-k8s.tgz "https://github.com/score-spec/score-k8s/releases/download/${SCORE_K8S_VERSION}/score-k8s_${SCORE_K8S_VERSION}_linux_amd64.tar.gz"
|
||||
curl -fsSL -o oras.tgz "https://github.com/oras-project/oras/releases/download/v${ORAS_VERSION}/oras_${ORAS_VERSION}_linux_amd64.tar.gz"
|
||||
echo "${SCORE_K8S_SHA256} score-k8s.tgz" | sha256sum -c -
|
||||
echo "${ORAS_SHA256} oras.tgz" | sha256sum -c -
|
||||
tar -xzf score-k8s.tgz score-k8s && tar -xzf oras.tgz oras
|
||||
install -m 0755 score-k8s oras "$HOME/bin/"
|
||||
echo "$HOME/bin" >> $GITHUB_PATH
|
||||
|
||||
- name: Azure login (OIDC)
|
||||
run: |
|
||||
az login \
|
||||
--service-principal \
|
||||
--username "$AZURE_CLIENT_ID" \
|
||||
--tenant "$AZURE_TENANT_ID" \
|
||||
--federated-token "$(cat $AZURE_FEDERATED_TOKEN_FILE)"
|
||||
|
||||
- name: Pull platform provisioners
|
||||
run: |
|
||||
az acr login --name "${ACR_LOGIN_SERVER%%.*}" --expose-token --output tsv --query accessToken \
|
||||
| oras login "$ACR_LOGIN_SERVER" --username 00000000-0000-0000-0000-000000000000 --password-stdin
|
||||
oras pull "${ACR_LOGIN_SERVER}/score-provisioners:${PROVISIONERS_VERSION}" -o "$HOME/provisioners"
|
||||
ls -1 "$HOME/provisioners"
|
||||
|
||||
- name: Render score-lab.yaml
|
||||
run: |
|
||||
P="$HOME/provisioners"
|
||||
OUT="$PWD/deploy/lab"
|
||||
WORK="$(mktemp -d)"
|
||||
cp score-lab.yaml "$WORK/score.yaml"
|
||||
cd "$WORK"
|
||||
score-k8s init --no-sample --quiet \
|
||||
$(for f in "$P"/*.provisioners.yaml; do printf -- '--provisioners %s ' "$f"; done) \
|
||||
$(for f in "$P"/*.tpl.yaml; do printf -- '--patch-templates %s ' "$f"; done)
|
||||
# Platform rule: only the platform's provisioners, so an unsupported resource type fails.
|
||||
rm -f .score-k8s/zz-default.provisioners.yaml
|
||||
CRUCIBLE_ENV=lab score-k8s generate score.yaml --quiet \
|
||||
--image "${ACR_LOGIN_SERVER}/demo-vivek-11:${{ gitea.sha }}" \
|
||||
--namespace demo-vivek-11 \
|
||||
-o manifests.yaml
|
||||
python3 "$P/policy-check.py" manifests.yaml
|
||||
python3 "$P/split.py" manifests.yaml "$OUT"
|
||||
|
||||
- name: Commit rendered manifests
|
||||
run: |
|
||||
git config user.name "gitea-actions"
|
||||
git config user.email "gitea-actions@noreply.gitea.kyndemo.live"
|
||||
git add deploy/lab
|
||||
if git diff --cached --quiet; then
|
||||
echo "deploy/lab is already up to date"
|
||||
exit 0
|
||||
fi
|
||||
SHA="${{ gitea.sha }}"
|
||||
git commit -m "deploy(lab): render ${SHA:0:12} [skip ci]"
|
||||
git pull --rebase origin "${{ gitea.ref_name }}"
|
||||
git push origin "HEAD:${{ gitea.ref_name }}"
|
||||
|
||||
@@ -12,7 +12,7 @@ browser ─► hub pe-gatewayapi (demo-vivek-11.apps.lab…) ─► Private Link
|
||||
|---|---|---|
|
||||
| `argocd/` | lab **hub** | `kubectl apply` once |
|
||||
| `hub/` | lab **hub** | `kubectl apply` once |
|
||||
| `manifests/` | lab **spoke** | Argo CD, from this repo |
|
||||
| `lab/` | lab **spoke** | Argo CD, from this repo. **Generated**: never edit by hand |
|
||||
|
||||
## Apply
|
||||
|
||||
@@ -31,7 +31,10 @@ The lab uses argocd-agent's **destination-based mapping**, and this app belongs
|
||||
- `destination.name: apps-lab`: the agent to deploy to, and the routing key. **Never**
|
||||
`destination.server`, which resolves to the hub itself.
|
||||
|
||||
## Image
|
||||
## How `lab/` is produced
|
||||
|
||||
`manifests/kustomization.yaml` pins the tag. Set it to the commit the lab build pushed, and commit:
|
||||
Argo CD deploys what is in Git.
|
||||
`lab/` is rendered from `score-lab.yaml` by the **Build and Push to ACR (lab)** workflow: it builds
|
||||
the image, renders with the platform's provisioners
|
||||
(`cruciblecoredevacr.azurecr.io/score-provisioners`, version pinned in the workflow), and commits the
|
||||
result. The image tag is the commit that was built. To change what is deployed, change
|
||||
`score-lab.yaml` and run the workflow.
|
||||
|
||||
@@ -11,7 +11,7 @@ spec:
|
||||
source:
|
||||
repoURL: https://gitea.kyndemo.live/validate/demo-vivek-11.git
|
||||
targetRevision: main
|
||||
path: deploy/manifests
|
||||
path: deploy/lab
|
||||
destination:
|
||||
# The agent to deploy to -- under destination-based mapping this IS the routing key. Never
|
||||
# server: https://kubernetes.default.svc resolves to the hub itself.
|
||||
|
||||
88
deploy/lab/deployment-demo-vivek-11.yaml
Normal file
88
deploy/lab/deployment-demo-vivek-11.yaml
Normal file
@@ -0,0 +1,88 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
annotations:
|
||||
k8s.score.dev/workload-name: demo-vivek-11
|
||||
labels:
|
||||
app.kubernetes.io/instance: demo-vivek-11
|
||||
app.kubernetes.io/managed-by: score-k8s
|
||||
app.kubernetes.io/name: demo-vivek-11
|
||||
name: demo-vivek-11
|
||||
namespace: demo-vivek-11
|
||||
spec:
|
||||
revisionHistoryLimit: 3
|
||||
selector:
|
||||
matchLabels:
|
||||
app.kubernetes.io/instance: demo-vivek-11
|
||||
strategy: {}
|
||||
template:
|
||||
metadata:
|
||||
annotations:
|
||||
k8s.score.dev/workload-name: demo-vivek-11
|
||||
labels:
|
||||
app.kubernetes.io/instance: demo-vivek-11
|
||||
app.kubernetes.io/managed-by: score-k8s
|
||||
app.kubernetes.io/name: demo-vivek-11
|
||||
spec:
|
||||
automountServiceAccountToken: false
|
||||
containers:
|
||||
- env:
|
||||
- name: OTEL_EXPORTER_OTLP_ENDPOINT
|
||||
value: http://otel-collector.monitoring.svc.cluster.local:4318
|
||||
- name: OTEL_EXPORTER_OTLP_PROTOCOL
|
||||
value: http/protobuf
|
||||
- name: OTEL_LOGS_EXPORTER
|
||||
value: none
|
||||
- name: OTEL_METRICS_EXPORTER
|
||||
value: otlp
|
||||
- name: OTEL_RESOURCE_ATTRIBUTES
|
||||
value: service.name=demo-vivek-11
|
||||
- name: OTEL_SERVICE_NAME
|
||||
value: demo-vivek-11
|
||||
- name: OTEL_TRACES_EXPORTER
|
||||
value: otlp
|
||||
image: cruciblecoredevacr.azurecr.io/demo-vivek-11:9bc0bce407eb2e817eb2d8ccb17a03b51489893e
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /actuator/health
|
||||
port: 8080
|
||||
name: main
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /actuator/health
|
||||
port: 8080
|
||||
resources:
|
||||
limits:
|
||||
memory: 1Gi
|
||||
requests:
|
||||
cpu: 250m
|
||||
memory: 512Mi
|
||||
securityContext:
|
||||
allowPrivilegeEscalation: false
|
||||
capabilities:
|
||||
drop:
|
||||
- ALL
|
||||
privileged: false
|
||||
readOnlyRootFilesystem: true
|
||||
runAsNonRoot: true
|
||||
seccompProfile:
|
||||
type: RuntimeDefault
|
||||
startupProbe:
|
||||
failureThreshold: 36
|
||||
httpGet:
|
||||
path: /actuator/health
|
||||
port: 8080
|
||||
periodSeconds: 5
|
||||
volumeMounts:
|
||||
- mountPath: /tmp
|
||||
name: crucible-tmp
|
||||
enableServiceLinks: false
|
||||
securityContext:
|
||||
runAsNonRoot: true
|
||||
seccompProfile:
|
||||
type: RuntimeDefault
|
||||
volumes:
|
||||
- emptyDir:
|
||||
sizeLimit: 256Mi
|
||||
name: crucible-tmp
|
||||
status: {}
|
||||
27
deploy/lab/httproute-demo-vivek-11.yaml
Normal file
27
deploy/lab/httproute-demo-vivek-11.yaml
Normal file
@@ -0,0 +1,27 @@
|
||||
apiVersion: gateway.networking.k8s.io/v1
|
||||
kind: HTTPRoute
|
||||
metadata:
|
||||
annotations:
|
||||
crucible.kyndryl.com/public-hostname: demo-vivek-11.apps.lab.crucible.kyndemo.live
|
||||
k8s.score.dev/resource-uid: workload-ingress.default#demo-vivek-11.ingress
|
||||
k8s.score.dev/source-workload: demo-vivek-11
|
||||
labels:
|
||||
app.kubernetes.io/managed-by: score-k8s
|
||||
app.kubernetes.io/name: demo-vivek-11
|
||||
name: demo-vivek-11
|
||||
namespace: demo-vivek-11
|
||||
spec:
|
||||
hostnames:
|
||||
- demo-vivek-11.int.apps.lab.crucible.kyndemo.live
|
||||
parentRefs:
|
||||
- name: pe-gatewayapi-int
|
||||
namespace: gatewayapi
|
||||
sectionName: http
|
||||
rules:
|
||||
- backendRefs:
|
||||
- name: demo-vivek-11
|
||||
port: 80
|
||||
matches:
|
||||
- path:
|
||||
type: PathPrefix
|
||||
value: /
|
||||
8
deploy/lab/kustomization.yaml
Normal file
8
deploy/lab/kustomization.yaml
Normal file
@@ -0,0 +1,8 @@
|
||||
# Generated by crucible-platform-score-provisioners. Do not edit: re-render instead.
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
resources:
|
||||
- deployment-demo-vivek-11.yaml
|
||||
- httproute-demo-vivek-11.yaml
|
||||
- networkpolicy-demo-vivek-11.yaml
|
||||
- service-demo-vivek-11.yaml
|
||||
20
deploy/lab/networkpolicy-demo-vivek-11.yaml
Normal file
20
deploy/lab/networkpolicy-demo-vivek-11.yaml
Normal file
@@ -0,0 +1,20 @@
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/managed-by: score-k8s
|
||||
app.kubernetes.io/name: demo-vivek-11
|
||||
name: demo-vivek-11
|
||||
namespace: demo-vivek-11
|
||||
spec:
|
||||
ingress:
|
||||
- from:
|
||||
- podSelector: {}
|
||||
- namespaceSelector:
|
||||
matchLabels:
|
||||
kubernetes.io/metadata.name: gatewayapi
|
||||
podSelector:
|
||||
matchLabels:
|
||||
app.kubernetes.io/instance: demo-vivek-11
|
||||
policyTypes:
|
||||
- Ingress
|
||||
21
deploy/lab/service-demo-vivek-11.yaml
Normal file
21
deploy/lab/service-demo-vivek-11.yaml
Normal file
@@ -0,0 +1,21 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
annotations:
|
||||
k8s.score.dev/workload-name: demo-vivek-11
|
||||
labels:
|
||||
app.kubernetes.io/instance: demo-vivek-11
|
||||
app.kubernetes.io/managed-by: score-k8s
|
||||
app.kubernetes.io/name: demo-vivek-11
|
||||
name: demo-vivek-11
|
||||
namespace: demo-vivek-11
|
||||
spec:
|
||||
ports:
|
||||
- name: web
|
||||
port: 80
|
||||
protocol: TCP
|
||||
targetPort: 8080
|
||||
selector:
|
||||
app.kubernetes.io/instance: demo-vivek-11
|
||||
status:
|
||||
loadBalancer: {}
|
||||
@@ -1,59 +0,0 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: demo-vivek-11
|
||||
labels:
|
||||
app: demo-vivek-11
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: demo-vivek-11
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: demo-vivek-11
|
||||
spec:
|
||||
securityContext:
|
||||
runAsNonRoot: true
|
||||
containers:
|
||||
- name: main
|
||||
image: demo-vivek-11
|
||||
# Only while the tag is `latest`. Remove once kustomization.yaml pins a sha.
|
||||
imagePullPolicy: Always
|
||||
ports:
|
||||
- name: http
|
||||
containerPort: 8080
|
||||
env:
|
||||
- name: OTEL_SERVICE_NAME
|
||||
value: demo-vivek-11
|
||||
- name: OTEL_EXPORTER_OTLP_ENDPOINT
|
||||
value: http://otel-collector.monitoring.svc.cluster.local:4318
|
||||
- name: OTEL_EXPORTER_OTLP_PROTOCOL
|
||||
value: http/protobuf
|
||||
- name: OTEL_RESOURCE_ATTRIBUTES
|
||||
value: service.name=demo-vivek-11
|
||||
- name: OTEL_METRICS_EXPORTER
|
||||
value: otlp
|
||||
- name: OTEL_TRACES_EXPORTER
|
||||
value: otlp
|
||||
- name: OTEL_LOGS_EXPORTER
|
||||
value: none
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /actuator/health
|
||||
port: http
|
||||
initialDelaySeconds: 20
|
||||
periodSeconds: 10
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /actuator/health
|
||||
port: http
|
||||
initialDelaySeconds: 60
|
||||
periodSeconds: 20
|
||||
resources:
|
||||
requests:
|
||||
cpu: 250m
|
||||
memory: 512Mi
|
||||
limits:
|
||||
memory: 1Gi
|
||||
@@ -1,22 +0,0 @@
|
||||
# On the SPOKE's internal Gateway. The hub rewrites Host to this name before forwarding
|
||||
# (deploy/hub/remote-route.yaml), so it must match remote_hostname there.
|
||||
apiVersion: gateway.networking.k8s.io/v1
|
||||
kind: HTTPRoute
|
||||
metadata:
|
||||
name: demo-vivek-11
|
||||
spec:
|
||||
parentRefs:
|
||||
- name: pe-gatewayapi-int
|
||||
namespace: gatewayapi
|
||||
# The hub forwards plaintext to port 80 across Private Link.
|
||||
sectionName: http
|
||||
hostnames:
|
||||
- demo-vivek-11.int.apps.lab.crucible.kyndemo.live
|
||||
rules:
|
||||
- matches:
|
||||
- path:
|
||||
type: PathPrefix
|
||||
value: /
|
||||
backendRefs:
|
||||
- name: demo-vivek-11
|
||||
port: 80
|
||||
@@ -1,12 +0,0 @@
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
namespace: demo-vivek-11
|
||||
resources:
|
||||
- deployment.yaml
|
||||
- service.yaml
|
||||
- httproute.yaml
|
||||
images:
|
||||
- name: demo-vivek-11
|
||||
newName: cruciblecoredevacr.azurecr.io/demo-vivek-11
|
||||
# Replace with the commit sha "Build and Push to ACR (lab)" pushed.
|
||||
newTag: latest
|
||||
@@ -1,13 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: demo-vivek-11
|
||||
labels:
|
||||
app: demo-vivek-11
|
||||
spec:
|
||||
selector:
|
||||
app: demo-vivek-11
|
||||
ports:
|
||||
- name: web
|
||||
port: 80
|
||||
targetPort: http
|
||||
Reference in New Issue
Block a user