From 3b2993da223a589007e7ac652e8bd6de0fa8fea5 Mon Sep 17 00:00:00 2001 From: Francesco Torta <62566275+fra98@users.noreply.github.com> Date: Fri, 22 Nov 2024 17:50:34 +0100 Subject: [PATCH] feature: ipam support additional pools --- cmd/ipam/main.go | 2 ++ deployments/liqo/templates/liqo-ipam-deployment.yaml | 4 ++++ deployments/liqo/templates/liqo-ipam-networks.yaml | 1 + pkg/ipam/initialize.go | 3 +++ pkg/ipam/ipam.go | 2 ++ 5 files changed, 12 insertions(+) diff --git a/cmd/ipam/main.go b/cmd/ipam/main.go index 79c926a05d..a0026273c1 100644 --- a/cmd/ipam/main.go +++ b/cmd/ipam/main.go @@ -72,6 +72,8 @@ func main() { cmd.Flags().IntVar(&options.ServerOpts.Port, "port", consts.IpamPort, "The port on which to listen for incoming gRPC requests.") cmd.Flags().DurationVar(&options.ServerOpts.SyncFrequency, "interval", consts.SyncFrequency, "The interval at which the IPAM will synchronize the IPAM storage.") + cmd.Flags().StringSliceVar(&options.ServerOpts.AdditionalPools, "additional-pools", []string{}, + "Additional pools to acquire IPs and Networks from.") // Leader election flags. cmd.Flags().BoolVar(&options.EnableLeaderElection, "leader-election", false, "Enable leader election for IPAM. "+ diff --git a/deployments/liqo/templates/liqo-ipam-deployment.yaml b/deployments/liqo/templates/liqo-ipam-deployment.yaml index 7ced18abe2..2f42c220e6 100644 --- a/deployments/liqo/templates/liqo-ipam-deployment.yaml +++ b/deployments/liqo/templates/liqo-ipam-deployment.yaml @@ -55,6 +55,10 @@ spec: - --leader-election - --leader-election-namespace=$(POD_NAMESPACE) {{- end }} + {{- if .Values.ipam.additionalPools }} + {{- $d := dict "commandName" "--additional-pools" "list" .Values.ipam.additionalPools }} + {{- include "liqo.concatenateList" $d | nindent 12 }} + {{- end }} {{- if .Values.common.extraArgs }} {{- toYaml .Values.common.extraArgs | nindent 12 }} {{- end }} diff --git a/deployments/liqo/templates/liqo-ipam-networks.yaml b/deployments/liqo/templates/liqo-ipam-networks.yaml index 4ceee13929..6f9cf02588 100644 --- a/deployments/liqo/templates/liqo-ipam-networks.yaml +++ b/deployments/liqo/templates/liqo-ipam-networks.yaml @@ -53,4 +53,5 @@ metadata: ipam.liqo.io/network-not-remapped: "true" spec: cidr: {{ $value }} +--- {{- end }} diff --git a/pkg/ipam/initialize.go b/pkg/ipam/initialize.go index 647e04e8cf..9b0da85fe6 100644 --- a/pkg/ipam/initialize.go +++ b/pkg/ipam/initialize.go @@ -24,6 +24,9 @@ import ( // +kubebuilder:rbac:groups=ipam.liqo.io,resources=networks,verbs=get;list;watch func (lipam *LiqoIPAM) initialize(ctx context.Context) error { + // TODO: set additional pools + klog.Infof("Additional pools: %v", lipam.opts.AdditionalPools) + if err := lipam.initializeNetworks(ctx); err != nil { return err } diff --git a/pkg/ipam/ipam.go b/pkg/ipam/ipam.go index e4945f394d..21dbdd7c3d 100644 --- a/pkg/ipam/ipam.go +++ b/pkg/ipam/ipam.go @@ -41,6 +41,8 @@ type LiqoIPAM struct { type ServerOptions struct { Port int SyncFrequency time.Duration + + AdditionalPools []string } // New creates a new instance of the LiqoIPAM.