Skip to content

Commit

Permalink
Set Control Plane Service Template
Browse files Browse the repository at this point in the history
Signed-off-by: RejwankabirHamim <[email protected]>
  • Loading branch information
RejwankabirHamim committed Jan 14, 2025
1 parent 3e82e41 commit 27014df
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions pkg/cmds/config/capk.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,14 @@ func NewCmdCAPK() *cobra.Command {
var out bytes.Buffer

err = parser.ProcessResources(in, func(ri parser.ResourceInfo) error {
if ri.Object.GetKind() == "KubevirtMachineTemplate" {
if err := setBootstrapCheckStrategy(ri); err != nil {
if ri.Object.GetAPIVersion() == "infrastructure.cluster.x-k8s.io/v1alpha1" &&
ri.Object.GetKind() == "KubevirtCluster" {
if err := SetControlPlaneServiceTemplate(ri); err != nil {
return err
}
} else if ri.Object.GetAPIVersion() == "infrastructure.cluster.x-k8s.io/v1alpha1" &&
ri.Object.GetKind() == "KubevirtMachineTemplate" {
if err := SetBootstrapCheckStrategy(ri); err != nil {
return err
}
}
Expand All @@ -69,9 +75,20 @@ func NewCmdCAPK() *cobra.Command {
return cmd
}

func setBootstrapCheckStrategy(ri parser.ResourceInfo) error {
func SetBootstrapCheckStrategy(ri parser.ResourceInfo) error {
if err := unstructured.SetNestedField(ri.Object.UnstructuredContent(), "none", "spec", "template", "spec", "virtualMachineBootstrapCheck", "checkStrategy"); err != nil {
return err
}
return nil
}

func SetControlPlaneServiceTemplate(ri parser.ResourceInfo) error {
if err := unstructured.SetNestedField(ri.Object.UnstructuredContent(), "0.0.0.0", "spec", "controlPlaneServiceTemplate", "metadata", "annotations", "kube-vip.io/loadbalancerIPs"); err != nil {
return err
}

if err := unstructured.SetNestedField(ri.Object.UnstructuredContent(), "LoadBalancer", "spec", "controlPlaneServiceTemplate", "spec", "type"); err != nil {
return err
}
return nil
}

0 comments on commit 27014df

Please sign in to comment.