added repo
This commit is contained in:
@@ -0,0 +1,135 @@
|
||||
> Per [AI Blitz Plan §6](../AGENT_BOUNDARIES.md). Layer: 1-T.
|
||||
|
||||
# Coding Guidelines — ArgoCD Application Manifests
|
||||
|
||||
Conventions for ArgoCD `Application` YAML files in `incubator/<env>/`.
|
||||
|
||||
---
|
||||
|
||||
## Required fields
|
||||
|
||||
Every incubator Application must have all of these:
|
||||
|
||||
```yaml
|
||||
apiVersion: argoproj.io/v1alpha1
|
||||
kind: Application
|
||||
metadata:
|
||||
name: incubator-infra-<cluster> # Must match filename without .yaml
|
||||
namespace: <argocd-namespace> # argocd-prd | argocd-dev | argocd-shared-int
|
||||
finalizers:
|
||||
- resources-finalizer.argocd.argoproj.io
|
||||
spec:
|
||||
project: default
|
||||
source:
|
||||
repoURL: 'https://github.com/Meesho/devops-infra-argo-config'
|
||||
targetRevision: <branch> # main | develop | pre-prod
|
||||
path: generic-argo-apps-chart
|
||||
helm:
|
||||
valueFiles:
|
||||
- ../values/<env>/incubator-infra-<cluster>-values.yaml
|
||||
destination:
|
||||
name: in-cluster
|
||||
namespace: <argocd-namespace>
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## `metadata.name` rules
|
||||
|
||||
- Must equal the filename without `.yaml` — this is ArgoCD's tracking key (R9).
|
||||
- Convention: `incubator-infra-<gke-cluster-name>` (e.g. `incubator-infra-k8s-central-prd-ase1`).
|
||||
- Changing this after the Application is registered breaks ArgoCD tracking; treat as immutable.
|
||||
|
||||
---
|
||||
|
||||
## `metadata.namespace` (ArgoCD namespace)
|
||||
|
||||
| Environment | Namespace |
|
||||
| ----------- | --------- |
|
||||
| prd | `argocd-prd` |
|
||||
| stg / dev | `argocd-dev` |
|
||||
| int | `argocd-shared-int` |
|
||||
|
||||
The `metadata.namespace` and `spec.destination.namespace` must be the same value.
|
||||
|
||||
---
|
||||
|
||||
## `spec.source.repoURL` allow-list
|
||||
|
||||
Only one value is permitted:
|
||||
|
||||
```text
|
||||
https://github.com/Meesho/devops-infra-argo-config
|
||||
```
|
||||
|
||||
Changing this is a **Layer 3** operation. See [AGENT_BOUNDARIES.md](../AGENT_BOUNDARIES.md).
|
||||
|
||||
---
|
||||
|
||||
## `spec.source.targetRevision`
|
||||
|
||||
Must match the environment branch:
|
||||
|
||||
| Environment | `targetRevision` |
|
||||
| ----------- | ---------------- |
|
||||
| prd | `main` |
|
||||
| stg / dev | `develop` |
|
||||
| int | `pre-prod` |
|
||||
|
||||
Never pin to a feature branch. Feature branches are not monitored by auto-sync.
|
||||
|
||||
---
|
||||
|
||||
## `spec.source.path`
|
||||
|
||||
Always `generic-argo-apps-chart`. This is the Helm chart that renders child Applications from the values file.
|
||||
|
||||
---
|
||||
|
||||
## `spec.destination.name`
|
||||
|
||||
Always `in-cluster`. Incubator Applications run on the ArgoCD admin cluster itself, not on the target GKE cluster.
|
||||
|
||||
---
|
||||
|
||||
## `spec.destination.namespace`
|
||||
|
||||
Must match `metadata.namespace` — same ArgoCD namespace.
|
||||
|
||||
---
|
||||
|
||||
## Finalizer
|
||||
|
||||
The finalizer `resources-finalizer.argocd.argoproj.io` must be present. It causes ArgoCD to cascade-delete child Applications when the parent incubator is deleted. Removing it creates orphaned child Applications.
|
||||
|
||||
---
|
||||
|
||||
## `helm.valueFiles` path convention
|
||||
|
||||
Paths are relative to the chart root (`generic-argo-apps-chart/`), so `..` is required to reach the repo root:
|
||||
|
||||
```text
|
||||
generic-argo-apps-chart/ (chart root = ArgoCD's working dir for this source)
|
||||
../values/<env>/incubator-infra-<cluster>-values.yaml
|
||||
└── resolves to: values/<env>/incubator-infra-<cluster>-values.yaml at repo root
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Naming invariant
|
||||
|
||||
Directory and values path vary by env — but the invariant itself is universal:
|
||||
|
||||
```text
|
||||
prd (main):
|
||||
Filename: incubator/prd/incubator-infra-k8s-central-prd-ase1.yaml
|
||||
metadata.name: incubator-infra-k8s-central-prd-ase1
|
||||
helm.valueFiles: ../values/prd/incubator-infra-k8s-central-prd-ase1-values.yaml
|
||||
|
||||
stg (develop):
|
||||
Filename: incubator/infra/incubator-infra-k8s-central-stg-ase1.yaml
|
||||
metadata.name: incubator-infra-k8s-central-stg-ase1
|
||||
helm.valueFiles: ../values/dev/ incubator-infra-k8s-central-stg-ase1-values.yaml
|
||||
```
|
||||
|
||||
All three must be consistent. Any mismatch causes a routing failure.
|
||||
@@ -0,0 +1,141 @@
|
||||
> Per [AI Blitz Plan §6](../AGENT_BOUNDARIES.md). Layer: 1-T.
|
||||
|
||||
# Coding Guidelines — Helm Values Files
|
||||
|
||||
Conventions for cluster values files (`values/<env>/incubator-infra-<cluster>-values.yaml`).
|
||||
|
||||
---
|
||||
|
||||
## File naming
|
||||
|
||||
```text
|
||||
values/<values-dir>/incubator-infra-<gke-cluster-name>-values.yaml
|
||||
```
|
||||
|
||||
The values directory name does **not** always match the environment name:
|
||||
|
||||
| Environment | Branch | Values dir | Example |
|
||||
| ----------- | ------ | ---------- | ------- |
|
||||
| prd | `main` | `values/prd/` | `values/prd/incubator-infra-k8s-central-prd-ase1-values.yaml` |
|
||||
| stg | `develop` | `values/dev/` | `values/dev/incubator-infra-k8s-central-stg-ase1-values.yaml` |
|
||||
| dev | `develop` | `values/dev/` | `values/dev/incubator-infra-k8s-central-dev-ase1-values.yaml` |
|
||||
| int | `pre-prod` | `values/int/` | `values/int/incubator-infra-k8s-shared-int-ase1-values.yaml` |
|
||||
| admin | `main` / `pre-prod` | `values/admin/` | `values/admin/incubator-infra-k8s-devops-admin-ase1-values.yaml` |
|
||||
|
||||
Note: stg and dev clusters both live under `values/dev/` on the `develop` branch.
|
||||
|
||||
---
|
||||
|
||||
## Top-level structure
|
||||
|
||||
Four keys in this exact order — no additions, no reordering:
|
||||
|
||||
```yaml
|
||||
clusterSpec:
|
||||
argocdSpec:
|
||||
teamSpec:
|
||||
appSpec:
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## `clusterSpec`
|
||||
|
||||
```yaml
|
||||
clusterSpec:
|
||||
destination:
|
||||
server: "" # Always empty string — name-based routing only
|
||||
name: "k8s-central-prd-ase1" # Must match GKE cluster name and helm-overrides/ folder
|
||||
```
|
||||
|
||||
- `server` is always `""`. Never set a URL here.
|
||||
- `name` is immutable after cluster registration. Changing it redirects all tooling.
|
||||
|
||||
---
|
||||
|
||||
## `argocdSpec`
|
||||
|
||||
```yaml
|
||||
argocdSpec:
|
||||
namespace: argocd-prd # argocd-prd | argocd-dev | argocd-shared-int
|
||||
```
|
||||
|
||||
| Environment | Namespace |
|
||||
| ----------- | --------- |
|
||||
| prd | `argocd-prd` |
|
||||
| stg / dev | `argocd-dev` |
|
||||
| int | `argocd-shared-int` |
|
||||
|
||||
---
|
||||
|
||||
## `teamSpec`
|
||||
|
||||
```yaml
|
||||
teamSpec:
|
||||
devops:
|
||||
source:
|
||||
repoURL: https://github.com/Meesho/devops-infra-helm-charts
|
||||
targetRevision: main # main | develop | pre-prod
|
||||
path: helm-templates
|
||||
valueFiles: ../../helm-overrides/<cluster>
|
||||
labels:
|
||||
bu: infra
|
||||
team: devops
|
||||
env: prd # prd | stg | dev | int | admin
|
||||
cluster: k8s-central-prd-ase1 # Must match clusterSpec.destination.name
|
||||
```
|
||||
|
||||
**`repoURL` allow-list:** Only `https://github.com/Meesho/devops-infra-helm-charts` is permitted.
|
||||
|
||||
**`targetRevision`** must match the environment:
|
||||
|
||||
| Environment | `targetRevision` |
|
||||
| ----------- | ---------------- |
|
||||
| prd | `main` |
|
||||
| stg / dev | `develop` |
|
||||
| int | `pre-prod` |
|
||||
|
||||
**`valueFiles` path:** Relative from `helm-templates/` root (two levels up) to the cluster's override directory. Always `../../helm-overrides/<cluster>`.
|
||||
|
||||
**`labels.cluster`** must equal `clusterSpec.destination.name` exactly — it is used in Application name generation.
|
||||
|
||||
---
|
||||
|
||||
## `appSpec`
|
||||
|
||||
```yaml
|
||||
appSpec:
|
||||
- name: keda # Short, lowercase, hyphen-separated tool name
|
||||
namespace: keda-central-prd # Target K8s namespace
|
||||
chartDir: keda # Directory under helm-templates/ in helm-charts repo
|
||||
valuesDir: keda # Directory under helm-overrides/<cluster>/ in helm-charts repo
|
||||
```
|
||||
|
||||
- One entry = one ArgoCD child Application.
|
||||
- Generated name: `<name>-<mungedCluster>-<env>` (e.g. `keda-central-prd`).
|
||||
- `chartDir` and `valuesDir` **must exist** in `devops-infra-helm-charts` before adding the entry (R3).
|
||||
|
||||
### Optional fields
|
||||
|
||||
```yaml
|
||||
- name: coredns
|
||||
namespace: kube-system
|
||||
chartDir: coredns
|
||||
valuesDir: coredns
|
||||
nameOverride: coredns-central-prd # Only for name collisions or >253 char names (R7)
|
||||
additionalValueFiles:
|
||||
- ../../helm-templates/coredns/gcp-ase1a-values.yaml
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Common mistakes
|
||||
|
||||
| Mistake | Impact | Fix |
|
||||
| ------- | ------ | --- |
|
||||
| `server: <url>` instead of `""` | May route to wrong cluster | Always use `""` |
|
||||
| Wrong `targetRevision` for env | Tools pull from wrong chart branch | Use `main`/`develop`/`pre-prod` per env |
|
||||
| `chartDir` not in `helm-templates/` | ArgoCD render failure | Verify in `devops-infra-helm-charts` first |
|
||||
| `valuesDir` missing `custom-values.yaml` | ArgoCD render failure | Add `custom-values.yaml` to the override dir |
|
||||
| `labels.cluster` ≠ `clusterSpec.destination.name` | Application name munging uses wrong cluster | Keep them identical |
|
||||
| Duplicate `name` in `appSpec` | Application name collision | Use `nameOverride` for multi-instance tools |
|
||||
@@ -0,0 +1,149 @@
|
||||
# Coding Guidelines — Values Files and appSpec Entries
|
||||
|
||||
> YAML authoring conventions for `devops-infra-argo-config`.
|
||||
>
|
||||
> **Scope:** `values/<env>/<cluster>-values.yaml` files and `appSpec` entries within them.
|
||||
|
||||
---
|
||||
|
||||
## Values file structure
|
||||
|
||||
Every values file has exactly four top-level keys in this order:
|
||||
|
||||
```yaml
|
||||
clusterSpec: # Cluster identity — destination for ArgoCD
|
||||
argocdSpec: # ArgoCD namespace
|
||||
teamSpec: # Source repo, labels, team identity
|
||||
appSpec: # List of tools to deploy to this cluster
|
||||
```
|
||||
|
||||
Do not add other top-level keys. Do not reorder these keys.
|
||||
|
||||
---
|
||||
|
||||
## `clusterSpec` conventions
|
||||
|
||||
```yaml
|
||||
clusterSpec:
|
||||
destination:
|
||||
server: "" # Leave empty — use name-based routing
|
||||
name: "k8s-central-prd-ase1" # Must match the cluster name in GKE
|
||||
```
|
||||
|
||||
- `server` is always empty string `""` — name-based routing is the standard.
|
||||
- `name` must exactly match the GKE cluster name and the `helm-overrides/` folder in the sister repo.
|
||||
|
||||
---
|
||||
|
||||
## `argocdSpec` conventions
|
||||
|
||||
```yaml
|
||||
argocdSpec:
|
||||
namespace: argocd-prd # prd → argocd-prd | stg/dev → argocd-dev | int → argocd-shared-int
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## `teamSpec` conventions
|
||||
|
||||
```yaml
|
||||
teamSpec:
|
||||
devops:
|
||||
source:
|
||||
repoURL: https://github.com/Meesho/devops-infra-helm-charts
|
||||
targetRevision: main # Env-specific: prd=main, stg/dev=develop, int=pre-prod
|
||||
path: helm-templates # Chart root in the helm-charts repo
|
||||
valueFiles: ../../helm-overrides/k8s-central-prd-ase1 # Relative path to overrides
|
||||
labels:
|
||||
bu: infra # Always "infra" for this repo
|
||||
team: devops # Always "devops" — maps to sre AppProject
|
||||
env: prd # prd, int, dev, or admin
|
||||
cluster: k8s-central-prd-ase1 # Must match clusterSpec.destination.name
|
||||
```
|
||||
|
||||
- `targetRevision` must match the environment branch: `main` (prd), `develop` (stg/dev), `pre-prod` (int). Deviating from this requires explicit justification.
|
||||
- `valueFiles` is a relative path from the chart source to the cluster's override directory in `devops-infra-helm-charts`.
|
||||
- Labels are used by the generic chart template for Application naming and metadata.
|
||||
|
||||
---
|
||||
|
||||
## `appSpec` entry conventions
|
||||
|
||||
Each entry in `appSpec` defines one ArgoCD child Application:
|
||||
|
||||
```yaml
|
||||
appSpec:
|
||||
- name: keda # Short tool name (used in Application name generation)
|
||||
namespace: keda-central-prd # Target namespace (auto-created by ArgoCD)
|
||||
chartDir: keda # Directory under helm-templates/ in helm-charts repo
|
||||
valuesDir: keda # Directory under helm-overrides/<cluster>/ in helm-charts repo
|
||||
```
|
||||
|
||||
### Required fields
|
||||
|
||||
| Field | Description | Convention |
|
||||
| ----- | ----------- | ---------- |
|
||||
| `name` | Short tool identifier | Lowercase, hyphen-separated. Used in rendered Application name. |
|
||||
| `namespace` | Kubernetes namespace for the tool | Pattern: `<tool>-<mungedCluster>` or shared namespace (e.g., `victoriametrics`, `kube-system`) |
|
||||
| `chartDir` | Chart directory name in `helm-templates/` | Must exist in `devops-infra-helm-charts` |
|
||||
| `valuesDir` | Override directory name in `helm-overrides/<cluster>/` | Must exist in `devops-infra-helm-charts` |
|
||||
|
||||
### Optional fields
|
||||
|
||||
| Field | When to use |
|
||||
| ----- | ----------- |
|
||||
| `nameOverride` | Only when the auto-generated name exceeds 253 chars or collides with another entry |
|
||||
| `additionalValueFiles` | When a tool needs region-shared overlays (e.g., CoreDNS GCP zone values) |
|
||||
|
||||
### Ordering
|
||||
|
||||
New appSpec entries should be appended at the end of the list. Do not sort alphabetically — the order reflects deployment history and makes diffs cleaner.
|
||||
|
||||
---
|
||||
|
||||
## Namespace naming patterns
|
||||
|
||||
| Pattern | When |
|
||||
| ------- | ---- |
|
||||
| `<tool>-<mungedCluster>` | Default. Example: `keda-central-prd`, `contour-external-central-prd` |
|
||||
| Shared namespace | When multiple tools share a namespace. Example: `victoriametrics` for all VM tools, `kube-system` for system tools |
|
||||
| Tool-specific with role | Multi-instance tools. Example: `contour-internal-0-central-prd`, `contour-internal-1-central-prd` |
|
||||
|
||||
---
|
||||
|
||||
## Application name generation
|
||||
|
||||
The generic chart template generates names as:
|
||||
|
||||
```
|
||||
<name>-<mungedCluster>-<env>
|
||||
```
|
||||
|
||||
**Cluster munging rules** (applied in order by the Helm template):
|
||||
1. Replace `dp-` with placeholder, `backup` with placeholder
|
||||
2. Strip: `p-`, `prd-`, `int-`, `dev-`, `-cluster`
|
||||
3. Replace: `prod-ops` → `infra`, `-ase1c` → `-c`, `-ase1` → (empty), `k8s-` → (empty)
|
||||
4. Restore placeholders
|
||||
|
||||
**Example:** `k8s-central-prd-ase1` → `central-prd` → Application name: `keda-central-prd`
|
||||
|
||||
---
|
||||
|
||||
## YAML formatting
|
||||
|
||||
- 2-space indentation (no tabs).
|
||||
- No trailing whitespace.
|
||||
- Single newline at end of file.
|
||||
- Quote strings only when YAML requires it (e.g., empty strings `""`).
|
||||
- Use block style for lists (one `- ` per line), not flow style.
|
||||
|
||||
---
|
||||
|
||||
## Common mistakes
|
||||
|
||||
| Mistake | Why it's wrong | Fix |
|
||||
| ------- | -------------- | --- |
|
||||
| Adding `nameOverride` without justification | Breaks naming consistency; see R7 | Remove unless name > 253 chars or collision |
|
||||
| `chartDir` that doesn't exist in helm-charts | ArgoCD will fail to render the Application | Verify with `ls helm-templates/<chartDir>/` |
|
||||
| Duplicate `name` in same appSpec list | Two Applications will have the same name → conflict | Use unique tool names or `nameOverride` for multi-instance |
|
||||
| Changing `targetRevision` away from env branch | All tools on the cluster pull from the wrong branch | Must match env: `main` (prd), `develop` (stg/dev), `pre-prod` (int) |
|
||||
Reference in New Issue
Block a user