How shashidhar-p/krm-functions works
Project type and purpose
• This repo, “krm-functions,” is an open-source library of Kubernetes Resource Model (KRM) functions and packaged resource sets meant to be consumed by the kpt CLI.
• It is not a traditional client-server application but rather a family of reusable functions (as containers or Go binaries) plus one packaged Kubernetes resource bundle (“ngnix-pkg”).
File structure
• Top-level:
– KPTpackages-KRMfunctions.pdf: design/usage doc
– README.md: repository overview
– ngnix-pkg/: a kpt package containing Nginx k8s manifests + package config
– set-replicas/: a KRM function implemented in Go (with Dockerfile, tests, FunctionConfig)
• In ngnix-pkg: Kptfile, resource definitions (service.yaml, deployment.yaml, etc.), package-context.yaml, resourcegroup.yaml → this is a static bundle.
• In set-replicas: main.go + go.mod, Kptfile describing the function, a Dockerfile to containerize it, a golden_test.go with testdata for function behavior.
README for additional insights
• README only has the title; deeper details are in individual sub-dirs.
• Each subdirectory’s README.md explains its own contract: how to invoke the function or apply the package.
a. Main components
1. kpt CLI (entry point)
2. ngnix-pkg package (static Kubernetes resources + metadata)
3. set-replicas KRM function (Go code → Docker image)
4. FunctionConfig CRD inputs
6. Developer/test harness (golden tests)
b. Relationships & interactions
• User invokes “kpt pkg get” or “kpt fn run” → pulls ngnix-pkg or set-replicas function container
• For ngnix-pkg: kpt applies overlays, then “kubectl apply” pushes resources to cluster
• For set-replicas: kpt streams resource YAML + FunctionConfig to the function container, which mutates replica counts, then outputs updated YAML
• In CI: golden_test.go drives main.go using testdata files to verify behavior
c. Architectural patterns/design principles
• Package-centric delivery: resources co-located with package metadata (Kptfile)
• Test harness pattern: conventional golden-file testing
d. Key technologies/frameworks
• kpt CLI and KRM function SDK
• Go modules and standard library
• Docker (containerize function)
• Kubernetes resource manifests (YAML CRDs)
Final detail capture
• Don’t omit the PDF (architecture doc) – represent it as a reference/documentation node
• Testdata directory under set-replicas as part of the test harness component
• Where Kptfile and package-context.yaml live within ngnix-pkg to show package metadata vs. resource files