k8s

module
v0.25.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 7, 2026 License: MIT

README

k8s

Kubernetes clusters as Pulumi components, behind one provider-neutral contract.

Provisions the cluster and the things a cluster needs around it — the network, the peering, a registry pull-through cache, a backup store — as Pulumi ComponentResources with documented child names and names the caller supplies. EKS Auto Mode is the first provider; self-hosted Talos is the second. Whichever provider made it, the consumer of a cluster sees the same thing: a name, an endpoint, a CA, an OIDC issuer and a set of capabilities.

What Where
Go module github.com/truvity/k8s go get github.com/truvity/k8s@v0.1.0
pkg/cluster — the provider-neutral contract: outputs and capabilities, with a validator Go package, no cloud dependency
pkg/aws/pullthroughcache — ECR pull-through cache rules and their credential secrets, truvity:k8s/aws:PullThroughCache Pulumi component, unreleased
pkg/aws/backupbucket — DEPRECATED, moved to truvity/cnpg pkg/aws/backupstore; a versioned, KMS-encrypted cross-account backup bucket with version deletion denied, optional Object Lock and cross-region replica, truvity:k8s/aws:BackupBucket Pulumi component, unreleased
pkg/aws/vpcpeering — a cross-account, cross-region VPC peering with its routes, DNS-resolution options and private-zone associations, truvity:k8s/aws:VpcPeering Pulumi component, unreleased
pkg/aws/vpc — a VPC with its subnets, route tables, gateways, NAT, IPv6, hardened defaults, gateway endpoints and flow logs, truvity:k8s/aws:Vpc Pulumi component, unreleased
pkg/aws/podidentity — an EKS Pod Identity role with its trust policy, permissions and one association per service account, truvity:k8s/aws:PodIdentity Pulumi component, unreleased
pkg/aws/ekscluster — an EKS Auto Mode cluster with its secrets key, cluster and node roles and control-plane log group, truvity:k8s/aws:EksCluster Pulumi component, unreleased
pkg/aws/eksoidc — the external OIDC issuer association of an EKS cluster, truvity:k8s/aws:EksOidc Pulumi component, unreleased
pkg/aws/ackfactory — the AWS identity of the ACK controllers: the IAM and EKS controller roles, the service controllers' roles (adopting what is live) and the per-project capability roles; plain functions, names are API Go package, unreleased
charts/cluster-baseline — Pod Security Admission labels per namespace (default level, reasoned exemptions, warn-first rollout), a guard, and opt-in default-deny, quota and limit range Helm chart, oci://ghcr.io/truvity/charts/cluster-baseline, unreleased
charts/cluster-foundation — Namespaces with their Pod Security labels and deletion protection, ClusterRoleBindings, StorageClasses and the EKS Auto Mode NetworkPolicy switch, every name a value Helm chart, oci://ghcr.io/truvity/charts/cluster-foundation, unreleased
charts/cluster-network-policies — a cluster's own NetworkPolicies as data: selector, policy types and rules per entry, each with a required reason, sync wave and optional deletion protection Helm chart, oci://ghcr.io/truvity/charts/cluster-network-policies, unreleased
charts/eks-auto-node-pools — Karpenter NodePools and NodeClasses for EKS Auto Mode, one disruption budget per pool, subnet tags and roles as values Helm chart, oci://ghcr.io/truvity/charts/eks-auto-node-pools, unreleased
charts/guardrails-projects — the guardrails of every project namespace from a list of project rows: Namespace with labels and Pod Security, baseline NetworkPolicy (shared rules filtered by the row's kind), quota and LimitRange by profile, Roles and RoleBindings, an ACK IAMRoleSelector for the row's ceiling role; data-bearing objects carry Prune=false,Delete=false Helm chart, oci://ghcr.io/truvity/charts/guardrails-projects
charts/tenancy — DEPRECATED (window): per-tenant NetworkPolicy, quota, RBAC, NATS account and Pod Identity and the Namespace itself with its Pod Security labels, one profile per tier, every name a value Helm chart, oci://ghcr.io/truvity/charts/tenancy, unreleased
charts/volume-snapshot-crds — the CSI external-snapshotter CustomResourceDefinitions, mirrored verbatim at the upstream version pinned in crdctl.yaml Helm chart, oci://ghcr.io/truvity/charts/volume-snapshot-crds
charts/cilium-crds — the Cilium CustomResourceDefinitions, mirrored verbatim at the upstream version pinned in crdctl.yaml Helm chart, oci://ghcr.io/truvity/charts/cilium-crds

The two CRD charts carry the UPSTREAM version they mirror, not this repository's: a release publishes each only if that version is not in the registry yet. Their CRDs are generated by just crds (which also sets the chart version) and committed; just crds-check proves they still equal the upstream.

The provider packages (EKS first) are not in v0.1.0; they arrive one reviewed extraction at a time and are listed in the CHANGELOG. The extracted components so far, the pull-through cache, the backup bucket, the VPC peering, the VPC and the Pod Identity role, are unreleased.

Who it is for

A team that runs its own clusters from a Pulumi program in Go and wants the cluster, its network and its supporting pieces as reusable components, rather than as a copy of another team's infrastructure repository. It assumes you already have a Pulumi backend, cloud credentials and a naming scheme; it chooses none of them.

It deliberately does not pick your names, your address ranges, your permission boundaries or your accounts, does not install workloads into the cluster. The charts render cluster objects and never workloads: cluster-baseline labels namespaces someone else owns, cluster-foundation renders the foundation objects (namespaces, role bindings, storage classes), eks-auto-node-pools the Karpenter pools and tenancy what each tenant namespace needs around it; see the reference.

The model

Three ideas.

A component is a Pulumi ComponentResource with a documented set of child resources. The child names are part of the API: a caller that adopts a component over existing infrastructure relies on them to keep its resources' URNs, through aliases the component declares.

A contract is what every provider component reports, in pkg/cluster.Outputs: name, endpoint, certificate authority, OIDC issuer and the capabilities the cluster offers (node pools, storage, network policy, workload identity, load balancing, API access). A consumer asks for a capability; it does not branch on the provider.

A caller-supplied name is any name, tag, range or boundary a component would otherwise have to choose. Components take them as inputs; none has a default that belongs to one estate.

Install and a worked example

go get github.com/truvity/k8s@v0.1.0

The contract is what a consumer of any provider writes against:

out := cluster.Outputs{
	Provider:                cluster.ProviderEKS,
	Name:                    "example",
	Endpoint:                "https://api.example.test",
	CertificateAuthorityPEM: caPEM,
	OIDCIssuer:              "https://oidc.example.test/id/abc",
	Capabilities:            cluster.NewCapabilities(cluster.NodePools, cluster.WorkloadIdentity),
}
if err := out.Validate(); err != nil {
	return err // the provider reported something a consumer cannot use
}
if out.Capabilities.Has(cluster.WorkloadIdentity) {
	// wire pod identities against out.OIDCIssuer
}

Consumers

The estate this is being extracted from will adopt it cluster by cluster, each adoption proven by an empty Pulumi preview (see docs/decisions/0002-urn-stability.md). No consumer is recorded at v0; a repository that adopts it adds a line here.

Neighbours

  • pulumi-pipeline — runs many Pulumi stacks as one pipeline with refusal gates; the natural driver for programs that use these components.
  • policy — the contracts this repository is held to (docs/contracts/component.md).
  • ci-workflows — the shared CI and release workflows this repository calls.

Documentation

The rule that makes this repository public

Mechanism only. A cluster's name, its address ranges, its account, its permission boundaries and every tag pattern are the caller's: an input, a hook the caller supplies, or a file the caller commits. Nothing here defaults to one estate's value, and the tests never reach a real cloud — providers run against Pulumi mocks and cluster behaviour against kind. hack/leak-canary.sh enforces the mechanical half over tracked files and runs in the gate.

Status

v0: the API may still move in a minor release, and every move is a Breaking: bullet in the CHANGELOG. Today the module holds the contract only; providers are added by extraction from a running estate, each with its URN-stability proof.

Development

devbox shell        # pins every tool
just check          # build, test, lint, leak-canary
just vuln           # reachable Go advisories (its own workflow in CI, not in check)

Releasing

Releases are a v* tag, which the shared release workflow turns into the Go module version and a GitHub Release. Automatic patch releases are not armed; the first release and every minor and major are hand-cut tags.

Licence

MIT. See LICENSE.

Directories

Path Synopsis
pkg
aws/ackfactory
Package ackfactory deploys the AWS identity of the ACK controllers: the roles, the policies and the Pod Identity associations the controllers that cannot bootstrap themselves need, plus the per-project capability roles the controllers assume.
Package ackfactory deploys the AWS identity of the ACK controllers: the roles, the policies and the Pod Identity associations the controllers that cannot bootstrap themselves need, plus the per-project capability roles the controllers assume.
aws/backupbucket
Package backupbucket is DEPRECATED: the cross-account backup bucket and its KMS key moved to github.com/truvity/cnpg/v2/pkg/aws/backupstore (K5 of the estate model: the backup bucket belongs to the CNPG family).
Package backupbucket is DEPRECATED: the cross-account backup bucket and its KMS key moved to github.com/truvity/cnpg/v2/pkg/aws/backupstore (K5 of the estate model: the backup bucket belongs to the CNPG family).
aws/ekscluster
Package ekscluster deploys one EKS Auto Mode cluster as a Pulumi ComponentResource: the cluster, the KMS key its secrets are encrypted with, the cluster's IAM role and the Auto Mode node role with their policies, and the CloudWatch log group the control plane logs to.
Package ekscluster deploys one EKS Auto Mode cluster as a Pulumi ComponentResource: the cluster, the KMS key its secrets are encrypted with, the cluster's IAM role and the Auto Mode node role with their policies, and the CloudWatch log group the control plane logs to.
aws/eksoidc
Package eksoidc points an EKS cluster's API server at an external OIDC issuer, as a Pulumi ComponentResource: one eks.IdentityProviderConfig, the association EKS validates bearer tokens against.
Package eksoidc points an EKS cluster's API server at an external OIDC issuer, as a Pulumi ComponentResource: one eks.IdentityProviderConfig, the association EKS validates bearer tokens against.
aws/podidentity
Package podidentity deploys one EKS Pod Identity role as a Pulumi ComponentResource: the IAM role whose trust policy admits the EKS Pod Identity service for one namespace and its service accounts, the permissions it carries, and one PodIdentityAssociation per service account.
Package podidentity deploys one EKS Pod Identity role as a Pulumi ComponentResource: the IAM role whose trust policy admits the EKS Pod Identity service for one namespace and its service accounts, the permissions it carries, and one PodIdentityAssociation per service account.
aws/pullthroughcache
Package pullthroughcache deploys Amazon ECR pull-through cache rules for upstream container registries, as one Pulumi ComponentResource.
Package pullthroughcache deploys Amazon ECR pull-through cache rules for upstream container registries, as one Pulumi ComponentResource.
aws/vpc
Package vpc deploys one AWS VPC with its subnets, route tables, gateways, default-resource hardening, gateway endpoints and flow logs as one Pulumi ComponentResource.
Package vpc deploys one AWS VPC with its subnets, route tables, gateways, default-resource hardening, gateway endpoints and flow logs as one Pulumi ComponentResource.
aws/vpclayout
Package vpclayout is the address plan of a fleet of VPCs: which /16 a network gets, how its logical subnets are cut into one block per availability zone, and what each block is called.
Package vpclayout is the address plan of a fleet of VPCs: which /16 a network gets, how its logical subnets are cut into one block per availability zone, and what each block is called.
aws/vpcpeering
Package vpcpeering deploys one VPC peering connection between two VPCs, with the routes that make it carry traffic and, optionally, the private hosted-zone associations that make names resolve across it, as one Pulumi ComponentResource.
Package vpcpeering deploys one VPC peering connection between two VPCs, with the routes that make it carry traffic and, optionally, the private hosted-zone associations that make names resolve across it, as one Pulumi ComponentResource.
cluster
Package cluster is the provider-neutral contract of a Kubernetes cluster that some provider component (EKS Auto Mode, self-hosted Talos, ...) has provisioned.
Package cluster is the provider-neutral contract of a Kubernetes cluster that some provider component (EKS Auto Mode, self-hosted Talos, ...) has provisioned.
nscatalog
Package nscatalog is the namespace catalog: one row per (cluster, namespace) with one column group per concern (guardrails, identity, data, exposure, observability, delivery).
Package nscatalog is the namespace catalog: one row per (cluster, namespace) with one column group per concern (guardrails, identity, data, exposure, observability, delivery).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL