@@ -166,6 +166,29 @@ spec:
166166 mode :
167167 type : string
168168 enum : ["ipvs","iptables"]
169+ - name : templateSelector
170+ required : false
171+ schema :
172+ openAPIV3Schema :
173+ description : When set, we use tag-based template selection (and drop sourceNode/templateID).
174+ type : object
175+ properties :
176+ matchTags :
177+ type : array
178+ items :
179+ type : string
180+ minItems : 1
181+ required :
182+ - matchTags
183+ - name : localStorage
184+ required : false
185+ schema :
186+ openAPIV3Schema :
187+ type : boolean
188+ default : false
189+ description : >
190+ If true, CAPMOX will schedule clones from a template on the same node where the VM is created (works with
191+ templateSelector or explicit sourceNode/templateID). Defaults to false.
169192 - name : cloneSpec
170193 required : true
171194 schema :
@@ -187,8 +210,6 @@ spec:
187210 properties :
188211 controlPlane : &machineSpec
189212 type : object
190- required :
191- - sourceNode
192213 properties :
193214 disks :
194215 type : object
@@ -512,20 +533,162 @@ spec:
512533 path: /etc/kubernetes/admin.conf
513534 type: FileOrCreate
514535 name: kubeconfig
536+ - name : ApplyLocalStorageFlag-ControlPlane
537+ definitions :
515538 - selector :
516539 apiVersion : infrastructure.cluster.x-k8s.io/v1alpha1
517540 kind : ProxmoxMachineTemplate
518541 matchResources :
519542 controlPlane : true
520543 jsonPatches :
521- - op : replace
544+ - op : add
545+ path : /spec/template/spec/localStorage
546+ valueFrom :
547+ template : ' {{ .localStorage | default false }}'
548+
549+ - name : ApplyLocalStorageFlag-Worker
550+ definitions :
551+ - selector :
552+ apiVersion : infrastructure.cluster.x-k8s.io/v1alpha1
553+ kind : ProxmoxMachineTemplate
554+ matchResources :
555+ machineDeploymentClass :
556+ names :
557+ - proxmox-worker
558+ jsonPatches :
559+ - op : add
560+ path : /spec/template/spec/localStorage
561+ valueFrom :
562+ template : ' {{ .localStorage | default false }}'
563+
564+ - name : ApplyLocalStorageFlag-LoadBalancer
565+ definitions :
566+ - selector :
567+ apiVersion : infrastructure.cluster.x-k8s.io/v1alpha1
568+ kind : ProxmoxMachineTemplate
569+ matchResources :
570+ machineDeploymentClass :
571+ names :
572+ - proxmox-loadbalancer
573+ jsonPatches :
574+ - op : add
575+ path : /spec/template/spec/localStorage
576+ valueFrom :
577+ template : ' {{ .localStorage | default false }}'
578+
579+ # (A) Selector mode: if templateSelector is provided, set it and REMOVE sourceNode/templateID
580+ - name : TemplateSelectorMode-ControlPlane
581+ enabledIf : ' {{ if .templateSelector }}true{{ end }}'
582+ definitions :
583+ - selector :
584+ apiVersion : infrastructure.cluster.x-k8s.io/v1alpha1
585+ kind : ProxmoxMachineTemplate
586+ matchResources :
587+ controlPlane : true
588+ jsonPatches :
589+ - op : add
590+ path : /spec/template/spec/templateSelector
591+ valueFrom :
592+ variable : templateSelector
593+ - op : remove
594+ path : /spec/template/spec/sourceNode
595+ - op : remove
596+ path : /spec/template/spec/templateID
597+ - name : TemplateSelectorMode-Worker
598+ enabledIf : ' {{ if .templateSelector }}true{{ end }}'
599+ definitions :
600+ - selector :
601+ apiVersion : infrastructure.cluster.x-k8s.io/v1alpha1
602+ kind : ProxmoxMachineTemplate
603+ matchResources :
604+ machineDeploymentClass :
605+ names :
606+ - proxmox-worker
607+ jsonPatches :
608+ - op : add
609+ path : /spec/template/spec/templateSelector
610+ valueFrom :
611+ variable : templateSelector
612+ - op : remove
613+ path : /spec/template/spec/sourceNode
614+ - op : remove
615+ path : /spec/template/spec/templateID
616+ - name : TemplateSelectorMode-LoadBalancer
617+ enabledIf : ' {{ if .templateSelector }}true{{ end }}'
618+ definitions :
619+ - selector :
620+ apiVersion : infrastructure.cluster.x-k8s.io/v1alpha1
621+ kind : ProxmoxMachineTemplate
622+ matchResources :
623+ machineDeploymentClass :
624+ names :
625+ - proxmox-loadbalancer
626+ jsonPatches :
627+ - op : add
628+ path : /spec/template/spec/templateSelector
629+ valueFrom :
630+ variable : templateSelector
631+ - op : remove
632+ path : /spec/template/spec/sourceNode
633+ - op : remove
634+ path : /spec/template/spec/templateID
635+
636+ # (B) Explicit mode: when NO templateSelector, set sourceNode/templateID from cloneSpec
637+ - name : ExplicitMode-ControlPlane
638+ enabledIf : ' {{ if not .templateSelector }}true{{ end }}'
639+ definitions :
640+ - selector :
641+ apiVersion : infrastructure.cluster.x-k8s.io/v1alpha1
642+ kind : ProxmoxMachineTemplate
643+ matchResources :
644+ controlPlane : true
645+ jsonPatches :
646+ - op : add
522647 path : /spec/template/spec/sourceNode
523648 valueFrom :
524649 variable : cloneSpec.machineSpec.controlPlane.sourceNode
525- - op : replace
650+ - op : add
526651 path : /spec/template/spec/templateID
527652 valueFrom :
528653 variable : cloneSpec.machineSpec.controlPlane.templateID
654+ - name : ExplicitMode-Worker
655+ enabledIf : ' {{ if not .templateSelector }}true{{ end }}'
656+ definitions :
657+ - selector :
658+ apiVersion : infrastructure.cluster.x-k8s.io/v1alpha1
659+ kind : ProxmoxMachineTemplate
660+ matchResources :
661+ machineDeploymentClass :
662+ names :
663+ - proxmox-worker
664+ jsonPatches :
665+ - op : add
666+ path : /spec/template/spec/sourceNode
667+ valueFrom :
668+ variable : cloneSpec.machineSpec.workerNode.sourceNode
669+ - op : add
670+ path : /spec/template/spec/templateID
671+ valueFrom :
672+ variable : cloneSpec.machineSpec.workerNode.templateID
673+ - name : ExplicitMode-LoadBalancer
674+ enabledIf : ' {{ if not .templateSelector }}true{{ end }}'
675+ definitions :
676+ - selector :
677+ apiVersion : infrastructure.cluster.x-k8s.io/v1alpha1
678+ kind : ProxmoxMachineTemplate
679+ matchResources :
680+ machineDeploymentClass :
681+ names :
682+ - proxmox-loadbalancer
683+ jsonPatches :
684+ - op : add
685+ path : /spec/template/spec/sourceNode
686+ valueFrom :
687+ variable : cloneSpec.machineSpec.loadBalancer.sourceNode
688+ - op : add
689+ path : /spec/template/spec/templateID
690+ valueFrom :
691+ variable : cloneSpec.machineSpec.loadBalancer.templateID
529692 - name : kube-proxy-setup
530693 description : " kube-proxy configuration"
531694 enabledIf : " {{ if eq .kubeProxy.mode \" ipvs\" }}true{{ end }}"
@@ -573,23 +736,6 @@ spec:
573736 template : |
574737 - name: root
575738 sshAuthorizedKeys: {{ .cloneSpec.sshAuthorizedKeys }}
576- - selector :
577- apiVersion : infrastructure.cluster.x-k8s.io/v1alpha1
578- kind : ProxmoxMachineTemplate
579- matchResources :
580- controlPlane : false
581- machineDeploymentClass :
582- names :
583- - proxmox-worker
584- jsonPatches :
585- - op : replace
586- path : /spec/template/spec/sourceNode
587- valueFrom :
588- variable : cloneSpec.machineSpec.workerNode.sourceNode
589- - op : replace
590- path : /spec/template/spec/templateID
591- valueFrom :
592- variable : cloneSpec.machineSpec.workerNode.templateID
593739 - name : LoadBalancerSetup
594740 description : " Configure LoadBalancer Node Initialisation"
595741 definitions :
@@ -607,23 +753,6 @@ spec:
607753 template : |
608754 - name: root
609755 sshAuthorizedKeys: {{ .cloneSpec.sshAuthorizedKeys }}
610- - selector :
611- apiVersion : infrastructure.cluster.x-k8s.io/v1alpha1
612- kind : ProxmoxMachineTemplate
613- matchResources :
614- controlPlane : false
615- machineDeploymentClass :
616- names :
617- - proxmox-loadbalancer
618- jsonPatches :
619- - op : replace
620- path : /spec/template/spec/sourceNode
621- valueFrom :
622- variable : cloneSpec.machineSpec.loadBalancer.sourceNode
623- - op : replace
624- path : /spec/template/spec/templateID
625- valueFrom :
626- variable : cloneSpec.machineSpec.loadBalancer.templateID
627756 - name : ControlPlaneNodeSockets
628757 description : " Configure Control Plane Sockets"
629758 enabledIf : " {{ if .cloneSpec.machineSpecs.controlPlane.numSockets }}true{{ end }}"
0 commit comments