nginx/kubernetes-ingress/nic-structure
Claude Code and agent skill by nginx/kubernetes-ingress
- community
Checking that the SKILL.md file is still in the repository.
NIC architecture, resource processing pipeline, template systems, and key type definitions. Use when exploring the codebase, understanding data flow, debugging config generation, or working on controller logic.
Install
npx vskill@latest install nginx/kubernetes-ingress/nic-structureSKILL.md
The same SKILL.md was published earlier as nginx/kubernetes-ingress/nic-structure.
NIC Architecture and Structure
Repository Layout
Architectural Layers
Each layer has a strict ownership boundary. Identify the correct layer before placing any change.
| Layer | Package(s) | Owns | |
|---|---|---|---|
| Data model | pkg/apis/configuration/v1/ | CRD struct definitions, generated DeepCopy | |
| Validation | pkg/apis/configuration/validation/, internal/k8s/validation.go | CRD field validation (kubebuilder markers), Ingress annotation validation | |
| Controller | internal/k8s/ | Event handling, in-memory state, secret resolution, sync handlers, status updates | |
| Config generation | internal/configs/, version1/, version2/ | Extended resource → NGINX config struct → template render → file write | |
| Process management | internal/nginx/ | NGINX process lifecycle, reload, rollback |
Layer crossing rules — violations cause architectural drift:
- Config generation (
internal/configs/) must NOT call the k8s API or accessSecretStoredirectly — it receives pre-resolved role-qualifiedSecretReferencevia extended resources. Controller-side WAF bundle resolution and the dedicated PLMKubeClientSecretSourceare explicit exceptions to the normal extended-resource flow. - Controller (
internal/k8s/) must NOT generate NGINX config text or render templates. - Data model (
types.go) must NOT importinternal/configsorinternal/k8s. - Validation layer must NOT trigger NGINX reloads or update k8s status.
Generated Artifacts — never hand-edit
Every entry below is produced by a command. Regenerate and commit the output after changing the source.
| Artifact | Source | Command | Diffed by CI | |
|---|---|---|---|---|
pkg/apis/**/zz_generated.deepcopy.go, pkg/client/** | pkg/apis/**/types.go | make update-codegen | yes (pkg/**) | |
config/crd/bases/*.yaml | kubebuilder markers in pkg/apis/** | make update-crds | yes | |
config/crd/upstream/*.yaml | kubebuilder markers in pkg/apis/externaldnsk8s/** | make update-crds | yes | |
deploy/crds.yaml, deploy/crds-nap-*.yaml | config/crd/** via kustomize | make update-crds | no | |
docs/crd/*.md | config/crd/bases via hack/generate-crd-docs.go | make update-crds (runs update-crd-docs) | no | |
charts/nginx-ingress/crds | symlink to config/crd/bases/ | nothing — never edit | n/a | |
internal/telemetry/*_generated.go, data.avdl | Data / NICResourceCounts in internal/telemetry/exporter.go | make telemetry-schema | yes | |
internal/configs/version1/__snapshots__/** | version1/*.tmpl + fixtures in template_test.go | make test-update-snaps | via unit-tests | |
internal/configs/version2/__snapshots__/** | version2/*.tmpl + fixtures in templates_test.go | make test-update-snaps | via unit-tests | |
charts/tests/__snapshots__/** | chart templates + charts/tests/testdata/*.yaml | make test-update-snaps | via unit-tests |
Two traps:
verify-codegendiffs onlyconfig/crd/basesandconfig/crd/upstreamaftermake update-crds. Uncommitteddeploy/crds*.yamlordocs/crd/changes pass CI silently.- Snapshot files only re-record the existing fixtures. A template change with no matching fixture produces an empty diff and zero coverage — see
nic-testingfor the required sequence.
Resource Processing Pipeline
Secret Store
The secret store (internal/k8s/secrets/) is role-driven. A reference site selects a SecretRole for each secret. Kubernetes Secret.type does not determine validation, materialization, or reload behavior.
Phase 1 — reference-gated caching (syncSecret() and SecretStore.AddOrUpdateSecret()): syncSecret() finds direct references and Policy references through policySecretIndex. Referenced and special Secrets are cached; unreferenced Secrets are evicted. preSyncSecrets() temporarily primes the store during startup, and the informer-backed resolver loads newly referenced Secrets on demand.
Phase 2 — lazy role resolution (SecretStore.GetSecret()): For an existing Secret, GetSecret() validates and caches the result by (namespace/name, role). Valid file-backed roles are materialized under /etc/nginx/secrets/ using role-specific filenames. Missing lookups return an error reference with the expected path but are not cached.
Secret roles (internal/k8s/secrets/validation.go): Kubernetes Secret.type is not used for validation, so any type is accepted. The Opaque type is recommended, or kubernetes.io/tls for TLS secrets. Legacy nginx.org/* and nginx.com/* types remain accepted.
| Role | Required or Recognized Keys | Used for | |
|---|---|---|---|
RoleTLS | tls.crt, tls.key | TLS server certs | |
RoleCA | ca.crt; optional ca.crl | CA cert (mTLS / upstream trust) | |
RoleJWK | jwk | JWT validation keys | |
RoleHtpasswd | htpasswd | HTTP Basic auth | |
RoleOIDC | client-secret | OIDC client secret | |
RoleAPIKey | Client IDs and credentials | API key auth | |
RoleLicense | license.jwt | NGINX Plus license | |
RoleWAFBundle | token, or username and password; optional ca.crt | Bundle-fetch credentials |
Special secrets Default-server TLS, wildcard TLS, license, management client certificate, and management trusted CA are selected by configured references. One Secret can satisfy multiple roles; NIC validates and writes every applicable representation and performs the strongest required reload once.
Key invariant: Extended resources carry map[secrets.SecretRefKey]*secrets.SecretReference, keyed by namespaced Secret and role. Standard config generation may consume Path, CRLPath, Error, and role-specific data, but must not inspect Secret.type or call SecretStore.GetSecret().
Two Template Systems
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryChecking.github/skills/nic-structure/SKILL.md
Popularity
- Repository stars
- 5,081
- Repository forks
- 2,051
- 7-day trend score
- 43
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/nginx/kubernetes-ingress/nic-structure)