From 8f113858418d418e8f5a0cabef306317449ab411 Mon Sep 17 00:00:00 2001 From: Manuel Buil Date: Fri, 12 May 2023 11:17:56 +0200 Subject: [PATCH] Add IPv6 subnet and publicIP in the extension backend Signed-off-by: Manuel Buil --- Documentation/extension.md | 8 ++++++-- pkg/backend/extension/extension.go | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Documentation/extension.md b/Documentation/extension.md index c489544479..ae71773262 100644 --- a/Documentation/extension.md +++ b/Documentation/extension.md @@ -14,13 +14,17 @@ This backend has the following configuration * `SubnetAddCommand` (string): Command to run when a subnet is added * stdin - The output from `PreStartupCommand` is passed in. * The following environment variables are set - * SUBNET - The subnet of the remote host that was added. + * SUBNET - The ipv4 subnet of the remote host that was added. + * IPV6SUBNET - The ipv6 subnet of the remote host that was added. * PUBLIC_IP - The public IP of the remote host. + * PUBLIC_IPV6 - The public IPv6 of the remote host. * `SubnetRemoveCommand`(string): Command to run when a subnet is removed * stdin - The output from `PreStartupCommand` is passed in. * The following environment variables are set - * SUBNET - The subnet of the remote host that was removed. + * SUBNET - The ipv4 subnet of the remote host that was removed. + * IPV6SUBNET - The ipv6 subnet of the remote host that was removed. * PUBLIC_IP - The public IP of the remote host. + * PUBLIC_IPV6 - The public IPv6 of the remote host. All commands are run through the `sh` shell and are run with the same permissions as the flannel daemon. diff --git a/pkg/backend/extension/extension.go b/pkg/backend/extension/extension.go index 4ecd1d82fc..af96065d8e 100644 --- a/pkg/backend/extension/extension.go +++ b/pkg/backend/extension/extension.go @@ -117,7 +117,9 @@ func (be *ExtensionBackend) RegisterNetwork(ctx context.Context, wg *sync.WaitGr cmd_output, err := runCmd([]string{ fmt.Sprintf("NETWORK=%s", config.Network), fmt.Sprintf("SUBNET=%s", lease.Subnet), + fmt.Sprintf("IPV6SUBNET=%s", lease.IPv6Subnet), fmt.Sprintf("PUBLIC_IP=%s", attrs.PublicIP)}, + fmt.Sprintf("PUBLIC_IPV6=%s", attrs.PublicIPv6)}, "", "sh", "-c", n.postStartupCommand) if err != nil { return nil, fmt.Errorf("failed to run command: %s Err: %v Output: %s", n.postStartupCommand, err, cmd_output)