Skip to content

Commit

Permalink
review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
eaudetcobello committed Jun 6, 2024
1 parent 7d284da commit 03e3af2
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 35 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{{- if and (.Values.bgp.enabled) (eq .Values.driver "cilium") }}
{{- if (.Values.bgp.enabled) }}
{{- if (eq .Values.driver "cilium") }}

apiVersion: "cilium.io/v2alpha1"
kind: CiliumBGPPeeringPolicy
metadata:
Expand All @@ -15,4 +17,6 @@ spec:
neighbors:
{{- toYaml . | nindent 4 }}
{{- end }}

{{- end}}
{{- end}}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{{- if and (.Values.l2.enabled) (eq .Values.driver "cilium") }}
{{- if .Values.l2.enabled }}
{{- if (eq .Values.driver "cilium") }}

apiVersion: "cilium.io/v2alpha1"
kind: CiliumL2AnnouncementPolicy
metadata:
Expand All @@ -12,4 +14,6 @@ spec:
{{- end }}
externalIPs: true
loadBalancerIPs: true

{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{{- if and (.Values.ipPool.cidrs) (eq .Values.driver "cilium") }}
{{- if .Values.l2.enabled }}
{{- if (eq .Values.driver "cilium") }}

apiVersion: "cilium.io/v2alpha1"
kind: CiliumLoadBalancerIPPool
metadata:
Expand All @@ -10,4 +12,6 @@ spec:
blocks:
{{- toYaml . | nindent 4 }}
{{- end }}

{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{{- if and (.Values.bgp.enabled) (eq .Values.driver "metallb") }}
{{- if .Values.bgp.enabled }}
{{- if (eq .Values.driver "metallb") }}

{{- range .Values.bgp.neighbors }}
apiVersion: "metallb.io/v1beta2"
Expand All @@ -15,3 +16,4 @@ spec:
{{- end }}

{{- end }}
{{- end}}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{{- if .Values.l2.enabled }}
{{- if (eq .Values.driver "metallb") -}}

apiVersion: "metallb.io/v1beta1"
kind: L2Advertisement
metadata:
Expand All @@ -15,4 +17,6 @@ spec:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}

{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{{- if .Values.l2.enabled }}
{{- if (eq .Values.driver "metallb") }}

apiVersion: "metallb.io/v1beta1"
kind: IPAddressPool
metadata:
Expand All @@ -10,4 +12,6 @@ spec:
{{- range .Values.ipPool.cidrs }}
- {{ . }}
{{- end }}

{{- end }}
{{- end }}
31 changes: 0 additions & 31 deletions src/k8s/pkg/k8sd/features/metallb/loadbalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,6 @@ func enableLoadBalancer(ctx context.Context, snap snap.Snap, loadbalancer types.
return fmt.Errorf("failed to apply LoadBalancer configuration: %w", err)
}

if err := rolloutRestartMetalLB(ctx, snap, 3); err != nil {
return fmt.Errorf("failed to rollout restart metallb to apply LoadBalancer configuration: %w", err)
}

return nil
}

Expand Down Expand Up @@ -118,30 +114,3 @@ func waitForRequiredLoadBalancerCRDs(ctx context.Context, snap snap.Snap, bgpMod
return requiredCount == 0, nil
})
}

func rolloutRestartMetalLB(ctx context.Context, snap snap.Snap, attempts int) error {
client, err := snap.KubernetesClient("")
if err != nil {
return fmt.Errorf("failed to create kubernetes client: %w", err)
}

if err := control.RetryFor(ctx, attempts, 0, func() error {
if err := client.RestartDeployment(ctx, "metallb-controller", "kube-system"); err != nil {
return fmt.Errorf("failed to restart metallb-controller deployment: %w", err)
}
return nil
}); err != nil {
return fmt.Errorf("failed to restart metallb-controller deployment after %d attempts: %w", attempts, err)
}

if err := control.RetryFor(ctx, attempts, 0, func() error {
if err := client.RestartDaemonset(ctx, "metallb-speaker", "kube-system"); err != nil {
return fmt.Errorf("failed to restart metallb-speaker daemonset: %w", err)
}
return nil
}); err != nil {
return fmt.Errorf("failed to restart metallb-speaker daemonset after %d attempts: %w", attempts, err)
}

return nil
}

0 comments on commit 03e3af2

Please sign in to comment.