Repository navigation
Open
Labels
area/apiIssues or PRs related to the cozystack-api aggregated API serverIssues or PRs related to the cozystack-api aggregated API serverarea/virtualizationIssues or PRs related to virtualization (kubevirt, cdi, vmi, vm-import)Issues or PRs related to virtualization (kubevirt, cdi, vmi, vm-import)kind/featureCategorizes issue or PR as related to a new featureCategorizes issue or PR as related to a new featurelifecycle/frozenIndicates that an issue or PR should not be auto-closed due to stalenessIndicates that an issue or PR should not be auto-closed due to stalenesspriority/backlogGeneral backlog priority. Lower than priority/important-longtermGeneral backlog priority. Lower than priority/important-longtermtriage/acceptedIndicates an issue is ready to be actively worked onIndicates an issue is ready to be actively worked on
Description
Summary
Move validation of instanceType and instanceProfile values from Helm lookup function to a validating admission webhook in cozystack-api.
Background
Currently, VM-related charts (virtual-machine, vm-instance, kubernetes) use Helm's lookup function to validate that specified instanceType and instanceProfile exist in the cluster:
{{- if and .Values.instanceType (not (lookup "instancetype.kubevirt.io/v1beta1" "VirtualMachineClusterInstancetype" "" .Values.instanceType)) }}
{{- fail (printf "Specified instanceType does not exist in the cluster: %s" .Values.instanceType) }}
{{- end }}Problems with current approach
- GitOps incompatibility:
lookupreturnsnilwithhelm template, breaking ArgoCD and similar tools - Testing difficulty: Cannot test charts with
helm template --dry-run - Inconsistent UX: Validation happens at render time, not at API level
- Code duplication: Same validation logic repeated in multiple charts
Proposed Solution
Add a validating admission webhook in cozystack-api that:
- Intercepts HelmRelease resources for VM-related applications
- Validates that referenced
instanceTypeexists asVirtualMachineClusterInstancetype - Validates that referenced
instanceProfileexists asVirtualMachineClusterPreference - Returns clear error messages on validation failure
Affected charts
packages/apps/virtual-machinepackages/apps/vm-instancepackages/apps/kubernetes(for node groups)
Benefits
- Works with any GitOps tool (ArgoCD, FluxCD, etc.)
- Testable with
helm template - Centralized validation logic
- Better error messages at API level
- Consistent with Kubernetes admission patterns
Implementation Notes
- cozystack-api already has webhook infrastructure (
internal/lineagecontrollerwebhook/) - Could be implemented as a new validating webhook or extension to existing infrastructure
- Should validate on CREATE and UPDATE operations
Related
- Research on Helm lookup alternatives for GitOps compatibility
Reacted by dosubot
Metadata
Metadata
Assignees
Labels
area/apiIssues or PRs related to the cozystack-api aggregated API serverIssues or PRs related to the cozystack-api aggregated API serverarea/virtualizationIssues or PRs related to virtualization (kubevirt, cdi, vmi, vm-import)Issues or PRs related to virtualization (kubevirt, cdi, vmi, vm-import)kind/featureCategorizes issue or PR as related to a new featureCategorizes issue or PR as related to a new featurelifecycle/frozenIndicates that an issue or PR should not be auto-closed due to stalenessIndicates that an issue or PR should not be auto-closed due to stalenesspriority/backlogGeneral backlog priority. Lower than priority/important-longtermGeneral backlog priority. Lower than priority/important-longtermtriage/acceptedIndicates an issue is ready to be actively worked onIndicates an issue is ready to be actively worked on
Activity
dosubot commentedon May 1, 2026
Hi, Aleksei Sviridkin (@lexfrei). I'm Dosu, and I'm helping the cozystack team manage their backlog and am marking this issue as stale.
Issue Summary:
instanceTypeandinstanceProfilefor VM-related Helm charts.lookupfunction to improve GitOps compatibility and allow testing withhelm template.Next Steps:
Thank you for your understanding and contribution!