How-to guide / Adopt existing resources
Preserve Helm-compatible labels
These docs describe Kix's main branch, which can include changes not yet released. Read the docs for the latest release.
Use Helm-style labels when an existing workload selects Pods with the app
and release keys. Keeping those selectors avoids an immutable-field change
when Kix takes ownership.
Check the existing labels
Section titled “Check the existing labels”Read the current workload selector and Pod template labels:
❱ kubectl get deployment helm-web -n apps -o jsonpath='{.spec.selector.matchLabels}{"\n"}{.spec.template.metadata.labels}{"\n"}' Continue if the selector follows the common Helm shape, with both app and
release set to the release name. For a different selector, use
selectorLabels
to copy it exactly.
Select Helm label style
Section titled “Select Helm label style”Set labelStyle on the instance:
83 apps.helm-web = {84 package = webPackage;85 labelStyle = "helm";86 config = {87 message = "Kix manages a Helm-labelled workload";88 environment = "production";89 };90 };For this instance, Kix generates app = "helm-web" and
release = "helm-web" as scope.selectorLabels. Packages built with Kix’s
workload and Service helpers use the same pair consistently.
Check before deploying
Section titled “Check before deploying”Evaluate the cluster:
❱ kix check how-to-adoption
TOOL RESULT DETAILS
eval pass 19 manifests evaluated
scorecard pass 0 errors, 14 warnings, 2 info
architecture.annotationDomainOwnership (warning), 1:
apps/client: 'client' uses annotations under domain 'example.com' (ConfigMap/legacy-api-client) but no package in this cluster declares that it handles them. Add the operator package that handles these annotations. If something outside Kix consumes this domain, declare it in `scorecard.knownAnnotationDomains`.
governance.hasOwner (warning), 4:
apps/client: package 'client' has no meta.owner
apps/helm-web: package 'helm-web' has no meta.owner
apps/legacy-api-contract: package 'legacy-api-contract' has no meta.owner
apps/legacy-web: package 'legacy-web' has no meta.owner
reliability.boundedResources (warning), 2:
apps/helm-web/helm-web: container 'nginx' is missing resource settings: limits.cpu. Set CPU and memory requests and limits.
apps/legacy-web/legacy-web: container 'nginx' is missing resource settings: limits.cpu. Set CPU and memory requests and limits.
reliability.hasProbes (warning), 2:
apps/helm-web/helm-web: container 'nginx' has no livenessProbe
apps/legacy-web/legacy-web: container 'nginx' has no livenessProbe
security.hasNetworkPolicy (warning), 1:
apps: namespace 'apps' has workloads but no network policy
security.nonRoot (warning), 2:
apps/helm-web/helm-web: container 'nginx' may run as root: neither it nor the pod sets securityContext.runAsNonRoot, and no non-zero runAsUser resolves for it
apps/legacy-web/legacy-web: container 'nginx' may run as root: neither it nor the pod sets securityContext.runAsNonRoot, and no non-zero runAsUser resolves for it
security.readOnlyRootfs (warning), 2:
apps/helm-web/helm-web: container 'nginx' does not set readOnlyRootFilesystem
apps/legacy-web/legacy-web: container 'nginx' does not set readOnlyRootFilesystem
2 info finding(s) not listed; run with -v to list them. Render the Deployment and Service to verify their labels and selectors:
❱ kix build how-to-adoption --output json
[
{
"apiVersion": "apps/v1",
"kind": "Deployment",
"metadata": {
"name": "helm-web",
"namespace": "apps",
"labels": {
"app": "helm-web",
"app.kubernetes.io/managed-by": "kix",
"app.kubernetes.io/name": "helm-web",
"release": "helm-web"
}
},
"spec": {
"selector": {
"matchLabels": {
"app": "helm-web",
"release": "helm-web"
}
},
"template": {
"metadata": {
"labels": {
"app": "helm-web",
"app.kubernetes.io/name": "helm-web",
"release": "helm-web"
}
}
}
}
},
{
"apiVersion": "v1",
"kind": "Service",
"metadata": {
"name": "helm-web",
"namespace": "apps",
"labels": {
"app.kubernetes.io/managed-by": "kix",
"release": "helm-web"
}
},
"spec": {
"selector": {
"app": "helm-web",
"release": "helm-web"
}
}
}
] Compare the rendered Deployment selector with the live selector from the first
step. kix plan --read-only cannot make this comparison because it finds
live resources through Kix’s management labels. A Helm-owned workload does
not have those labels, so the read-only plan shows it as a new resource.
Ask the API server to review the complete ownership change instead:
❱ kix plan how-to-adoption Because the selector is immutable, a mismatch appears in the plan as a write the deploy would stop on, before anything reaches the cluster.