How-to guide / Author packages and clusters
Declare package roles and metadata
Add meta beside a package’s options and build attributes:
16 meta = {17 version = "1.0.0";18 description = "Configuration owned by an application team";19 owner = "platform";20 lifecycle = "stateless";21 scope = "namespace";22 };Use these fields to describe the package:
versionidentifies the package version shown by inspection commands and in PackageInstance records.descriptiongives the package a short human-readable purpose.owneridentifies the team responsible for it and supports governance scorecard rules.lifecycleclassifies its state asstateless,stateful,durable, orephemeral. Kix records the value in thekix.run/lifecycleannotation. Only"stateful"changes evaluation and deployment behavior: custom resources in a"stateful"package must declareholdsData, and replacing a data-holding resource in a"stateful"package triggers the deployment migration gate. Other values are descriptive only.scopesays which namespaces may use the package. A package argument is filled from the consumer’s own namespace. An instance in another namespace is used only when the cluster definition names it, withdeps.<arg> = ref.<namespace>.<instance>, or when the provider’s package serves the whole cluster. A package serves the whole cluster when it setsmeta.scope = "cluster", claims a role inmeta.roles, or declaresmeta.conflictsWithon acluster:key; operators, ingress controllers, and certificate issuers are the usual cases. Stand-ins made withkix.mkImportserve the whole cluster unless they setscope = "namespace"; when several imports answer one name, name the one you mean withref.meta.scope = "cluster"also makes auto-instantiation place the package once per cluster. An instance that Kix creates fromavailablePackagesor enables viaoptional = trueto satisfy a dependency binds from any namespace, unless its scope is"namespace".meta.scope = "namespace"goes the other way: the package is never used from another namespace, not even withref. Databases, caches, and anything that hands out a Secret leavescopeunset, so a consumer in another namespace names the instance it means.
version, description, and owner describe the package. lifecycle and
scope affect evaluation and deployment behavior, so choose them carefully.
Claim an infrastructure role
Section titled “Claim an infrastructure role”Add meta.roles only when the package provides one of Kix’s registered
cluster infrastructure roles. This minimal provider claims the
storageClasses role:
13 meta = {14 version = "1.0.0";15 description = "Default StorageClass for the composition example";16 owner = "platform";17 roles = [ "storageClasses" ];18 };Registered roles are also dependency-resolution aliases. Kix validates role
names, prevents conflicting providers, and checks any required out
attributes when a consumer resolves the role.
The storageClasses role requires an exported storageClassName, so the
package root supplies it:
35 root = {36 resource = self.storageClass;37 out.storageClassName = self.storageClass.out.name;38 };Do not use roles as general package tags. Ordinary application dependencies
are resolved through instance names, aliases, or explicit deps wiring.
Check the declarations
Section titled “Check the declarations”Run the normal checks after adding or changing metadata:
❱ kix check how-to-composition
TOOL RESULT DETAILS
eval pass 15 manifests evaluated
scorecard pass 0 errors, 0 warnings, 0 info Evaluation fails if a role name is unknown, two managed packages claim the same role, or a resolved provider does not satisfy the role’s output contract.