Skip to content
This repository was archived by the owner on Aug 12, 2025. It is now read-only.

Commit a6d3608

Browse files
authored
Merge pull request #320 from pluralsh/kube-vip
✨ Add support for kube-vip
2 parents d4bbdaa + b0cff13 commit a6d3608

17 files changed

+547
-110
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ generate: ## Generate code
275275

276276
.PHONY: generate-templates
277277
generate-templates: $(KUSTOMIZE) ## Generate cluster templates
278+
$(KUSTOMIZE) build templates/experimental-kube-vip --load-restrictor LoadRestrictionsNone > templates/cluster-template-kube-vip.yaml
278279
$(KUSTOMIZE) build templates/experimental-crs-cni --load-restrictor LoadRestrictionsNone > templates/cluster-template-crs-cni.yaml
279280
$(KUSTOMIZE) build templates/addons/calico > templates/addons/calico.yaml
280281

api/v1alpha3/packetcluster_types.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ import (
2121
clusterv1 "sigs.k8s.io/cluster-api/api/v1alpha3"
2222
)
2323

24+
// VIPManagerType describes if the VIP will be managed by CPEM or kube-vip
25+
type VIPManagerType string
26+
2427
// PacketClusterSpec defines the desired state of PacketCluster
2528
type PacketClusterSpec struct {
2629
// ProjectID represents the Packet Project where this cluster will be placed into
@@ -32,6 +35,12 @@ type PacketClusterSpec struct {
3235
// ControlPlaneEndpoint represents the endpoint used to communicate with the control plane.
3336
// +optional
3437
ControlPlaneEndpoint clusterv1.APIEndpoint `json:"controlPlaneEndpoint"`
38+
39+
// VIPManager represents whether this cluster uses CPEM or kube-vip to
40+
// manage its vip for the api server IP
41+
// +kubebuilder:validation:Enum=CPEM;KUBE_VIP
42+
// +kubebuilder:default:=CPEM
43+
VIPManager VIPManagerType `json:"vipManager"`
3544
}
3645

3746
// PacketClusterStatus defines the observed state of PacketCluster

api/v1alpha3/zz_generated.conversion.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1beta1/packetcluster_types.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ const (
2626
NetworkInfrastructureReadyCondition clusterv1.ConditionType = "NetworkInfrastructureReady"
2727
)
2828

29+
// VIPManagerType describes if the VIP will be managed by CPEM or kube-vip
30+
type VIPManagerType string
31+
2932
// PacketClusterSpec defines the desired state of PacketCluster
3033
type PacketClusterSpec struct {
3134
// ProjectID represents the Packet Project where this cluster will be placed into
@@ -37,6 +40,12 @@ type PacketClusterSpec struct {
3740
// ControlPlaneEndpoint represents the endpoint used to communicate with the control plane.
3841
// +optional
3942
ControlPlaneEndpoint clusterv1.APIEndpoint `json:"controlPlaneEndpoint"`
43+
44+
// VIPManager represents whether this cluster uses CPEM or kube-vip to
45+
// manage its vip for the api server IP
46+
// +kubebuilder:validation:Enum=CPEM;KUBE_VIP
47+
// +kubebuilder:default:=CPEM
48+
VIPManager VIPManagerType `json:"vipManager"`
4049
}
4150

4251
// PacketClusterStatus defines the observed state of PacketCluster

api/v1beta1/packetcluster_webhook.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,13 @@ func (c *PacketCluster) ValidateUpdate(oldRaw runtime.Object) error {
7171
)
7272
}
7373

74+
if !reflect.DeepEqual(c.Spec.VIPManager, old.Spec.VIPManager) {
75+
allErrs = append(allErrs,
76+
field.Invalid(field.NewPath("spec", "VIPManager"),
77+
c.Spec.VIPManager, "field is immutable"),
78+
)
79+
}
80+
7481
if len(allErrs) == 0 {
7582
return nil
7683
}

config/crd/bases/infrastructure.cluster.x-k8s.io_packetclusters.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,17 @@ spec:
6868
description: ProjectID represents the Packet Project where this cluster
6969
will be placed into
7070
type: string
71+
vipManager:
72+
default: CPEM
73+
description: VIPManager represents whether this cluster uses CPEM
74+
or kube-vip to manage its vip for the api server IP
75+
enum:
76+
- CPEM
77+
- KUBE_VIP
78+
type: string
7179
required:
7280
- projectID
81+
- vipManager
7382
type: object
7483
status:
7584
description: PacketClusterStatus defines the observed state of PacketCluster
@@ -134,8 +143,17 @@ spec:
134143
description: ProjectID represents the Packet Project where this cluster
135144
will be placed into
136145
type: string
146+
vipManager:
147+
default: CPEM
148+
description: VIPManager represents whether this cluster uses CPEM
149+
or kube-vip to manage its vip for the api server IP
150+
enum:
151+
- CPEM
152+
- KUBE_VIP
153+
type: string
137154
required:
138155
- projectID
156+
- vipManager
139157
type: object
140158
status:
141159
description: PacketClusterStatus defines the observed state of PacketCluster

config/default/kustomization.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ patchesStrategicMerge:
2626
- manager_pull_policy.yaml
2727
- manager_webhook_patch.yaml
2828
- webhookcainjection_patch.yaml
29-
- manager_credentials_patch.yaml
29+
- manager_credentials_config_patch.yaml
3030

3131
vars:
3232
- name: CERTIFICATE_NAMESPACE # namespace of the certificate CR

config/default/kustomizeconfig.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
varReference:
33
- kind: Deployment
44
path: spec/template/spec/volumes/secret/secretName
5+
- kind: Deployment
6+
path: spec/template/spec/volumes/configMap/configMapName

controllers/packetcluster_controller.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,13 @@ func (r *PacketClusterReconciler) reconcileNormal(ctx context.Context, clusterSc
137137
}
138138
}
139139

140+
if clusterScope.PacketCluster.Spec.VIPManager == "KUBE_VIP" {
141+
if err := r.PacketClient.EnableProjectBGP(packetCluster.Spec.ProjectID); err != nil {
142+
log.Error(err, "error enabling bgp for project")
143+
return ctrl.Result{}, err
144+
}
145+
}
146+
140147
clusterScope.PacketCluster.Status.Ready = true
141148
conditions.MarkTrue(packetCluster, infrav1.NetworkInfrastructureReadyCondition)
142149

0 commit comments

Comments
 (0)