Communitygithub.com

lguidolin/cloud-delivery-aks

在 Kubernetes 或 Azure Kubernetes Service (AKS) 上进行部署时使用,适用于配置云密钥、渐进式发布/金丝雀部署、每个PR的临时环境或k8s健康探测。关键词——Kubernetes、AKS、Key Vault、Argo Rollouts、Flagger、金丝雀、蓝绿、liveness、readiness、PodDisruptionBudget、HPA、回滚、GHCR。

cloud-delivery-aks 是什么?

该技能专门针对 Azure Kubernetes Service (AKS) 上的云交付机制设计,专注于实现部署安全性和验证门控。它严格按技术栈触发:只有涉及 k8s/AKS 的任务才会加载该技能,从而避免对无云部署需求的项目(如仅本地 Docker Compose)造成干扰。其核心遵循一系列交付规则,包括:通过内容摘要(digest)实现不可变镜像、基于每个 PR 的临时预览环境(在合并/关闭时自动销毁)、Kubernetes 健康探测门控(liveness、readiness、startup 探针)以及基于 Argo Rollouts 或 Flagger 的金丝雀/蓝绿渐进式发布(自动中止失败的金丝雀)。此外,回滚作为一等公民,通过重新部署先前已验证的摘要来实现。该技能还强调了CI作为门控机制,以及开发/生产环境的一致性和从环境中获取配置,机密信息通过 Azure Key Vault(Secrets Store CSI 驱动或 sealed secrets)管理。其管道定义了从预览到暂存再到生产的清晰阶段,并采用摘要提升机制(重打标签而非重新构建)来确保可重复性。技能还包含严格的安全机制,例如在合入前要求分支同步(在`enforced`模式下),并通过树比较来验证内容一致性。该技能适用于 Claude Code、Cursor 等AI Agent,并支持`enforced`和`advisory`两种审批模式。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/lguidolin/agent-skills/tree/main/skills/cloud-delivery-aks

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

基于AKS的云交付

概述

基于Kubernetes/Azure的交付机制。实现了AKS上的部署安全性和验证门控。按技术栈设计——该技能仅在任务涉及k8s/AKS时加载,因此没有云部署需求的项目(例如仅本地的Docker Compose)永远不会看到此内容。

交付规则

  • 本地开发运行完整技术栈,通过Docker Compose,一条命令即可,全面——这是一等要求。
  • 镜像在CI中构建 → GHCR,通过内容摘要标识,然后保持不变地提升:预览→暂存→生产。永不按环境重新构建。
  • 每个PR的临时预览环境。 每个PR部署到AKS上自己独立的命名空间供审查,在合并/关闭时销毁。 集成测试环境;创建和销毁成本低廉。
  • Kubernetes健康门控。 每个工作负载定义liveness、readiness和startup探针(连接到observability-and-slos中的端点)、滚动更新策略(带有界定的maxUnavailable/maxSurge)以及PodDisruptionBudget。使用HPA进行负载管理。
  • 面向生产的渐进式交付。 通过Argo Rollouts / Flagger实现金丝雀或蓝绿部署,并带有自动指标分析(关联SLO);失败的金丝雀自动中止。
  • 回滚是一等公民且经过预演。 不可变、基于摘要寻址的镜像使回滚只需重新部署先前良好的摘要(kubectl rollout undo / 中止rollout)。在有风险的变更发布前进行验证。
  • 迁移是独立的、有序的流水线步骤,可安全扩缩(参见zero-downtime-migrations),在依赖它们的代码之前运行——绝不捆绑在需要新Schema的Pod中。
  • CI是门控: lint、类型检查、契约检查、测试、安全扫描在每次变更时运行,并在enforced模式下阻止合并。CI还构建镜像并发布其来源证明,然后将该摘要保持不变地提升。
  • 开发/生产环境一致性与从环境获取配置。 来自Azure Key Vault的机密(通过Secrets Store CSI驱动或sealed secrets)——绝不放在镜像或提交的.env文件中。端口/配置来自环境。仅在开发时使用的工具(如pgTAP、测试运行器)绝不出现在生产镜像中。

流水线

阶段触发条件环境摘要
previewPR打开 / 同步临时命名空间 preview-<app>-pr-<N>在此构建,标签为 sha-<pr-head>
staging合入main持久命名空间 staging将preview摘要重打标签为 sha-<merge>
production发布创建 + 审批命名空间 production发布提交的父级摘要

为什么使用父级提交。 release-please的发布提交仅修改了CHANGELOG.md和清单文件,因此其树状结构从未被staging验证过——不论为发布PR构建的preview版本本身是什么,它从未被提升到preview之外。它的父级是最后一次功能合并,这正是staging一直在验证的内容,只要release-please将其发布分支保持在main的顶端(这是其默认行为)。从git(而非实时集群状态)中推导摘要可保持提升的可重复性。

重打标签的安全性。 Sqaash合并会产生不同的提交SHA,并且如果main在PR打开期间有变动,还会产生不同的树。两个保护措施:

  • 要求**“合入前分支已同步”**——这是必需状态检查规则的一个子集——从而保证squash树与PR头树在结构上相同。此保护需要分支保护,因此仅存在于enforced模式下;处于advisory模式的项目仅依赖下面的树比较作为唯一保护,应预期重建路径是常规而非例外情况。
  • 验证而非假设:比较 git rev-parse <merge>^{tree} 和PR头树。相等→重打标签。不相等→在合并SHA处重建。这并非交付规则所禁止的每环境重建:不等的树意味着内容本身与preview验证的不同,因此没有可提升的制品可供重用——并且重建的镜像作为新的候选者进入staging,而非提升。注意,当采用此路径时,失去了什么:该镜像从未在preview环境中被审查过,因此“已发布镜像即已审查镜像”不再成立。Staging是其第一次验证,而非第二次。

重打标签是一种指针操作——无需重建,无需拉取:

docker buildx imagetools create -t "$REPO:sha-$MERGE_SHA" "$REPO@sha256:$DIGEST"

证明仍绑定到PR头SHA,因此需在部署记录中记录头→合并的映射;镜像配置无法在不重建的情况下编辑。

审批门控——一个属性,两种机制:

模式机制
enforcedGitHub环境 production,需要审查者
advisory一个 workflow_dispatch提升任务;运行它即是决策

快速参考

关注点机制
机密Key Vault → CSI驱动;轮换;绝不在镜像中
健康liveness + readiness + startup探针;readiness检查真实依赖
安全发布金丝雀/蓝绿,SLO门控,失败时自动中止
回滚重新部署先前良好的摘要;有风险变更前预演
每个PR环境独立命名空间,合并时销毁
Schema独立有序步骤,安全扩缩,在代码之前
提升重打标签摘要;永不按环境重建
审批环境审查者(enforced)或手动调度(advisory)

为何此技能被隔离: 所有Azure/k8s的细节都通过技术栈特定触发器存放在此处。仅本地或不同云项目的项目使用其自己的交付技能;而原则(不可变制品、可逆且渐进式部署、解耦迁移)来自resilience-and-deploy-safety。

完整原理:宪法第十九条,见 engineering-constitution/references/engineering-constitution.md。

Individual skills in this repo

This repo contains 18 individual skills — each has its own dedicated page.

lguidolin/change-hygiene-and-code-craft

Use when writing or refactoring code, structuring a commit or PR, or deciding whether to abstract duplication. Symptoms — mixing reorg with logic changes, a PR doing several things at once, a file growing large, the second copy of similar code, or unsure whether to DRY something up.

lguidolin/commit-history-rewrite

Use when an existing repository has messy commit history that needs to conform to conventional commits before adopting release-please, or when intermediate WIP/fixup/merge commits need to be cleaned up.

lguidolin/conventional-commits-and-releases

Use when committing, writing a commit message, opening a PR that will be squash-merged, or configuring automated versioning/changelogs. Keywords — conventional commits, release-please, semver, feat/fix/chore, breaking change, changelog.

lguidolin/defense-in-depth-security

Use when handling untrusted input, secrets, authentication/authorization, or dependencies — or threat-modeling a new surface. Keywords — STRIDE, threat model, least privilege, secrets management, supply chain, dependency scanning, input validation, audit log, defense in depth.

lguidolin/designing-before-building

Use when starting a feature, fixing a non-trivial bug, or about to write implementation code — before any code exists. Symptoms you need this: "this is simple, I'll just code it", reaching for the editor before a design is approved, or an idea that hasn't been turned into a spec and plan.

lguidolin/engineering-constitution

Use when starting work in a project that follows the engineering constitution, orienting to its rules, or deciding which engineering practice applies to a task — spec writing, commits, testing, security, deploys, database, or UI work.

lguidolin/graphql-contract-testing

Use when writing a GraphQL query/mutation that the UI and a test will share, or building route/schema contract or smoke tests. Symptoms — copying a query into a test, a test asserting on query text, schema change that didn't break the UI build, or RLS/permission drift. Keywords — graphql-codegen, typed document, contract test, route smoke test.

lguidolin/init-repo-CI

Use when setting up a new repository with conventional commits, release-please, and CI automation, or when retrofitting an existing repository that lacks automated versioning and PR validation workflows.

lguidolin/interface-craft-and-accessibility

Use when building or styling UI — components, layouts, forms, design tokens — or making accessibility decisions. Keywords — a11y, WCAG, keyboard navigation, focus state, contrast, design system, minimalist UI, component reuse, ARIA, semantic HTML.

lguidolin/merge-gates-and-automation

Use when setting up or changing CI, pre-push hooks, or a task runner, or deciding what must pass before merge. Symptoms — tempted to put authoritative checks only in a local hook, skip CI, bypass with --no-verify, or unsure what gates a merge vs. runs locally.

lguidolin/observability-and-slos

Use when adding logging, metrics, tracing, health checks, SLOs, or alerting — or when building a service surface that needs to be operable and debuggable. Keywords — structured logs, OpenTelemetry, correlation id, RED metrics, liveness, readiness, SLI, SLO, error budget, alerting.

lguidolin/performance-and-scale

Use when working on hot paths, list endpoints, pagination, data-access in loops, or public interfaces/schemas. Symptoms — unbounded queries, N+1 access, no latency budget, optimizing without measuring, or changing an interface many consumers depend on. Keywords — pagination, N+1, Hyrum's Law, performance budget, bundle size.

lguidolin/postgres-postgraphile-rls-and-sql

Use when writing PostgreSQL, PostGraphile config, Row-Level Security policies, SQL schema files, or working on the Browser→App→PostGraphile→Postgres data path. Keywords — RLS, SECURITY DEFINER, search_path, pgSettings, grants, roles, GraphQL depth limit, query cost, statement_timeout, SQL file organization.

lguidolin/recording-decisions

Use when a design or architecture decision has been made and needs to be captured — writing a decision record or ADR, updating a decision index, noting a deferred idea, or superseding a past decision. Keywords — ADR, decision record, rationale, rejected alternatives, dependency index.

lguidolin/resilience-and-deploy-safety

Use when planning a deploy, designing a rollback, or responding to an incident or writing a postmortem. Keywords — deploy safety, rollback, immutable artifact, progressive delivery, canary, blast radius, incident response, blameless postmortem, error budget.

lguidolin/ship-it

Use when the user wants to ship work — push, PR, archive decision records, merge, and clean up. Handles the full lifecycle from committing final changes through post-merge cleanup including converting specs/plans to compact decision records.

lguidolin/tests-as-a-control

Use when writing or modifying tests, when a test breaks during a refactor, or when testing permission/role rules. Symptoms — tempted to edit a test to make it pass, testing only the happy path, a deny-test that started passing, flaky tests, or unsure what to assert.

lguidolin/zero-downtime-migrations

Use when changing a database schema where data must survive the change — adding/removing/renaming columns, constraints, indexes, or backfilling. Symptoms — a destructive migration bundled with a code deploy, a NOT NULL column with a backfill, a table-locking UPDATE, or a rename. Keywords — expand/contract, parallel change, backfill, NOT VALID, CREATE INDEX CONCURRENTLY, graphile-migrate.

相关技能