Skip to content

Commit

Permalink
chore: gateway flags refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
cheina97 committed Mar 4, 2025
1 parent fd85e73 commit fab005e
Show file tree
Hide file tree
Showing 13 changed files with 51 additions and 51 deletions.
Empty file added ADOPTERS.md
Empty file.
26 changes: 13 additions & 13 deletions cmd/liqoctl/cmd/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,45 +121,45 @@ func newNetworkConnectCommand(ctx context.Context, options *network.Options) *co
}

// Server flags
cmd.Flags().StringVar(&options.ServerGatewayType, "server-type", forge.DefaultGwServerType,
cmd.Flags().StringVar(&options.ServerGatewayType, "gw-server-type", forge.DefaultGwServerType,
"Type of Gateway Server. Leave empty to use default Liqo implementation of WireGuard")
cmd.Flags().StringVar(&options.ServerTemplateName, "server-template-name", forge.DefaultGwServerTemplateName,
cmd.Flags().StringVar(&options.ServerTemplateName, "gw-server-template-name", forge.DefaultGwServerTemplateName,
"Name of the Gateway Server template")
cmd.Flags().StringVar(&options.ServerTemplateNamespace, "server-template-namespace", "",
cmd.Flags().StringVar(&options.ServerTemplateNamespace, "gw-server-template-namespace", "",
"Namespace of the Gateway Server template")
cmd.Flags().Var(options.ServerServiceType, "server-service-type",
cmd.Flags().Var(options.ServerServiceType, "gw-server-service-type",
fmt.Sprintf("Service type of the Gateway Server service. Default: %s."+
" Note: use ClusterIP only if you know what you are doing and you have a proper network configuration",
forge.DefaultGwServerServiceType))
cmd.Flags().Int32Var(&options.ServerServicePort, "server-service-port", forge.DefaultGwServerPort,
cmd.Flags().Int32Var(&options.ServerServicePort, "gw-server-service-port", forge.DefaultGwServerPort,
fmt.Sprintf("Port of the Gateway Server service. Default: %d", forge.DefaultGwServerPort))
cmd.Flags().Int32Var(&options.ServerServiceNodePort, "server-service-nodeport", 0,
cmd.Flags().Int32Var(&options.ServerServiceNodePort, "gw-server-service-nodeport", 0,
"Force the NodePort of the Gateway Server service. Leave empty to let Kubernetes allocate a random NodePort")
cmd.Flags().StringVar(&options.ServerServiceLoadBalancerIP, "server-service-loadbalancerip", "",
cmd.Flags().StringVar(&options.ServerServiceLoadBalancerIP, "gw-server-service-loadbalancerip", "",
"Force LoadBalancer IP of the Gateway Server service. Leave empty to use the one provided by the LoadBalancer provider")

// Client flags
cmd.Flags().StringVar(&options.ClientGatewayType, "client-type", forge.DefaultGwClientType,
cmd.Flags().StringVar(&options.ClientGatewayType, "gw-client-type", forge.DefaultGwClientType,
"Type of Gateway Client. Leave empty to use default Liqo implementation of WireGuard")
cmd.Flags().StringVar(&options.ClientConnectAddress, "client-address", "",
cmd.Flags().StringVar(&options.ClientConnectAddress, "gw-client-address", "",
"Define the address used by the gateway client to connect to the gateway server. "+
"This value overrides the one automatically retrieved by Liqo and it is useful when the server is "+
"not directly reachable (e.g. the server is behind a NAT)")
cmd.Flags().Int32Var(&options.ClientConnectPort, "client-port", 0,
cmd.Flags().Int32Var(&options.ClientConnectPort, "gw-client-port", 0,
"Define the port used by the gateway client to connect to the gateway server. "+
"This value overrides the one automatically retrieved by Liqo and it is useful when the server is "+
"not directly reachable (e.g. the server is behind a NAT)")
cmd.Flags().StringVar(&options.ClientTemplateName, "client-template-name", forge.DefaultGwClientTemplateName,
cmd.Flags().StringVar(&options.ClientTemplateName, "gw-client-template-name", forge.DefaultGwClientTemplateName,
"Name of the Gateway Client template")
cmd.Flags().StringVar(&options.ClientTemplateNamespace, "client-template-namespace", "",
cmd.Flags().StringVar(&options.ClientTemplateNamespace, "gw-client-template-namespace", "",
"Namespace of the Gateway Client template")

// Common flags
cmd.Flags().IntVar(&options.MTU, "mtu", forge.DefaultMTU,
fmt.Sprintf("MTU of the Gateway server and client. Default: %d", forge.DefaultMTU))
cmd.Flags().BoolVar(&options.DisableSharingKeys, "disable-sharing-keys", false, "Disable the sharing of public keys between the two clusters")

runtime.Must(cmd.RegisterFlagCompletionFunc("server-service-type", completion.Enumeration(options.ServerServiceType.Allowed)))
runtime.Must(cmd.RegisterFlagCompletionFunc("gw-server-service-type", completion.Enumeration(options.ServerServiceType.Allowed)))

return cmd
}
Expand Down
16 changes: 8 additions & 8 deletions cmd/liqoctl/cmd/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ the following operations:
Examples:
$ {{ .Executable }} peer --remote-kubeconfig <provider>
$ {{ .Executable }} peer --remote-kubeconfig <provider> --server-service-type NodePort
$ {{ .Executable }} peer --remote-kubeconfig <provider> --gw-server-service-type NodePort
$ {{ .Executable }} peer --remote-kubeconfig <provider> --cpu 2 --memory 4Gi --pods 10
$ {{ .Executable }} peer --remote-kubeconfig <provider> --create-resource-slice false
$ {{ .Executable }} peer --remote-kubeconfig <provider> --create-virtual-node false
Expand Down Expand Up @@ -90,28 +90,28 @@ func newPeerCommand(ctx context.Context, f *factory.Factory) *cobra.Command {

// Networking flags
cmd.Flags().BoolVar(&options.NetworkingDisabled, "networking-disabled", false, "Disable networking between the two clusters")
cmd.Flags().Var(options.ServerServiceType, "server-service-type",
cmd.Flags().Var(options.ServerServiceType, "gw-server-service-type",
fmt.Sprintf("Service type of the Gateway Server service. Default: %s."+
" Note: use ClusterIP only if you know what you are doing and you have a proper network configuration",
nwforge.DefaultGwServerServiceType))
cmd.Flags().Int32Var(&options.ServerServicePort, "server-service-port", nwforge.DefaultGwServerPort,
cmd.Flags().Int32Var(&options.ServerServicePort, "gw-server-service-port", nwforge.DefaultGwServerPort,
fmt.Sprintf("Port of the Gateway Server service. Default: %d", nwforge.DefaultGwServerPort))
cmd.Flags().Int32Var(&options.ServerServiceNodePort, "server-service-nodeport", 0,
cmd.Flags().Int32Var(&options.ServerServiceNodePort, "gw-server-service-nodeport", 0,
"Force the NodePort of the Gateway Server service. Leave empty to let Kubernetes allocate a random NodePort")
cmd.Flags().StringVar(&options.ServerServiceLoadBalancerIP, "server-service-loadbalancerip", "",
cmd.Flags().StringVar(&options.ServerServiceLoadBalancerIP, "gw-server-service-loadbalancerip", "",
"IP of the LoadBalancer for the Gateway Server service")
cmd.Flags().StringVar(&options.ClientConnectAddress, "client-address", "",
cmd.Flags().StringVar(&options.ClientConnectAddress, "gw-client-address", "",
"Define the address used by the gateway client to connect to the gateway server. "+
"This value overrides the one automatically retrieved by Liqo and it is useful when the server is "+
"not directly reachable (e.g. the server is behind a NAT)")
cmd.Flags().Int32Var(&options.ClientConnectPort, "client-port", 0,
cmd.Flags().Int32Var(&options.ClientConnectPort, "gw-client-port", 0,
"Define the port used by the gateway client to connect to the gateway server. "+
"This value overrides the one automatically retrieved by Liqo and it is useful when the server is "+
"not directly reachable (e.g. the server is behind a NAT)")
cmd.Flags().IntVar(&options.MTU, "mtu", nwforge.DefaultMTU,
fmt.Sprintf("MTU of the Gateway server and client. Default: %d", nwforge.DefaultMTU))

runtime.Must(cmd.RegisterFlagCompletionFunc("server-service-type", completion.Enumeration(options.ServerServiceType.Allowed)))
runtime.Must(cmd.RegisterFlagCompletionFunc("gw-server-service-type", completion.Enumeration(options.ServerServiceType.Allowed)))

// Authentication flags
cmd.Flags().BoolVar(&options.CreateResourceSlice, "create-resource-slice", true, "Create a ResourceSlice for the peering")
Expand Down
2 changes: 1 addition & 1 deletion docs/_legacy/examples/global-ingress.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ This will allow Liqo to [offload workloads and reflect services](/features/offlo
To proceed, first we need to peer the *gslb-eu* cluster with *gslb-us*:

```bash
liqoctl peer --remote-kubeconfig "$KUBECONFIG_US" --server-service-type NodePort
liqoctl peer --remote-kubeconfig "$KUBECONFIG_US" --gw-server-service-type NodePort
```

```{admonition} Note
Expand Down
18 changes: 9 additions & 9 deletions docs/advanced/nat.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,19 @@ To do so, you need to pass the IP address or FQDN of the NAT and port where conf
```bash
liqoctl peer \
--remote-kubeconfig $PATH_TO_CLUSTER2_KUBECONFIG \
--client-address $NAT_PUBBLIC_ADDR \
--client-port $NAT_MAPPING_PORT \
--server-service-nodeport $GATEWAY_SERVER_NODEPORT
--gw-client-address $NAT_PUBBLIC_ADDR \
--gw-client-port $NAT_MAPPING_PORT \
--gw-server-service-nodeport $GATEWAY_SERVER_NODEPORT
```

Filling the placeholders, in our specific example, the command becomes:

```bash
liqoctl peer \
--remote-kubeconfig $PATH_TO_CLUSTER2_KUBECONFIG \
--client-address 203.0.113.8 \
--client-port 40582 \
--server-service-nodeport 30742
--gw-client-address 203.0.113.8 \
--gw-client-port 40582 \
--gw-server-service-nodeport 30742

```

Expand All @@ -66,7 +66,7 @@ The command above sets up a complete peering between cluster 1 and cluster 2.
```bash
liqoctl network connect \
--remote-kubeconfig $PATH_TO_CLUSTER2_KUBECONFIG \
--client-address $NAT_PUBBLIC_ADDR \
--client-port $NAT_MAPPING_PORT \
--server-service-nodeport $GATEWAY_SERVER_NODEPORT
--gw-client-address $NAT_PUBBLIC_ADDR \
--gw-client-port $NAT_MAPPING_PORT \
--gw-server-service-nodeport $GATEWAY_SERVER_NODEPORT
```
14 changes: 7 additions & 7 deletions docs/advanced/peering/inter-cluster-network.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ To establish a connection between two clusters, you can run the following comman
liqoctl network connect \
--kubeconfig $CLUSTER_1_KUBECONFIG_PATH \
--remote-kubeconfig $CLUSTER_2_KUBECONFIG_PATH \
--server-service-type NodePort \
--gw-server-service-type NodePort \
--wait
```

Expand Down Expand Up @@ -88,8 +88,8 @@ The command above applied the following changes to the clusters:
```{admonition} Note
You can see further configuration options with `liqoctl network connect --help`.
For instance, in the previous command we have used the `--server-service-type NodePort` option to expose the Liqo Gateway service as a NodePort service.
Alternatively, you can use the `--server-service-type LoadBalancer` option to expose the Liqo Gateway service as a LoadBalancer service (if supported by your cloud provider).
For instance, in the previous command we have used the `--gw-server-service-type NodePort` option to expose the Liqo Gateway service as a NodePort service.
Alternatively, you can use the `--gw-server-service-type LoadBalancer` option to expose the Liqo Gateway service as a LoadBalancer service (if supported by your cloud provider).
```

In **cluster 1**, which, in this case, **hosts the client gateway**, you will find the following resources:
Expand Down Expand Up @@ -209,10 +209,10 @@ INFO (remote) Network configuration correctly deleted

You can configure how to expose the Liqo Gateway Server service by using the following flags for the `liqoctl network connect` command on the server side:

* `--server-service-type` (default `LoadBalancer`): the type of the Gateway service, it can be `NodePort` or `LoadBalancer`.
* `--server-port` (default `51840`): the port of the Gateway service.
* `--node-port` (default `0`): set it to force the NodePort binding to a specific port. If set to `0`, the system will allocate a port automatically.
* `--load-balancer-ip` (default `""`): set it to force the LoadBalancer service to bind to a specific IP address. If set to `""`, the system will allocate an IP address automatically.
* `--gw-server-service-type` (default `LoadBalancer`): the type of the Gateway service, it can be `NodePort` or `LoadBalancer`.
* `--gw-server-service-port` (default `51840`): Port of the Gateway Server service.
* `--gw-server-service-nodeport` (default `""`): force the NodePort of the Gateway Server service. Leave empty to let Kubernetes allocate a random NodePort.
* `--gw-server-service-loadbalancerip` (default `""`): Force LoadBalancer IP of the Gateway Server service. Leave empty to use the one provided by the LoadBalancer provider.
* `--mtu` (default `1340`): the MTU of the Gateway interface. Note that the MTU must be the same on both sides.

Use the `liqoctl network connect --help` command to see all the available options.
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/offloading-with-policies.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ In this way, you can easily identify the clusters through their characterizing l
Once Liqo is installed in your clusters, you can establish new *peerings*:

```bash
liqoctl peer --remote-kubeconfig "$KUBECONFIG_FLORENCE" --server-service-type NodePort
liqoctl peer --remote-kubeconfig "$KUBECONFIG_NAPLES" --server-service-type NodePort
liqoctl peer --remote-kubeconfig "$KUBECONFIG_FLORENCE" --gw-server-service-type NodePort
liqoctl peer --remote-kubeconfig "$KUBECONFIG_NAPLES" --gw-server-service-type NodePort
```

When the above commands return successfully, you can check the peering status by running:
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,10 @@ In this example, we will leverage the *liqoctl peer* command to peer the two clu
This approach requires the user to have access to the `kubeconfig` of both clusters.

Let's issue the peering command from the consumer cluster, which is Rome in this case.
The `--remote-kubeconfig` flag is used to specify the `kubeconfig` of the remote provider cluster, which is Milan in this case. Moreover, as no load balancer is configured in the clusters, we will set `--server-service-type` to `NodePort` to use a port of the nodes of the clusters to expose the Liqo gateway.
The `--remote-kubeconfig` flag is used to specify the `kubeconfig` of the remote provider cluster, which is Milan in this case. Moreover, as no load balancer is configured in the clusters, we will set `--gw-server-service-type` to `NodePort` to use a port of the nodes of the clusters to expose the Liqo gateway.

```bash
liqoctl peer --remote-kubeconfig "$KUBECONFIG_MILAN" --server-service-type NodePort
liqoctl peer --remote-kubeconfig "$KUBECONFIG_MILAN" --gw-server-service-type NodePort
```

The peering should be completed successfully after a few seconds (if the Docker images are already cached in the involved clusters) or minutes (when the Docker images have to be downloaded).
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/replicated-deployments.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ The setup script named them **europe-cloud**, **europe-rome-edge** and **europe-
Now, you can establish new Liqo *peerings* from *origin* to *destination* clusters:

```bash
liqoctl peer --remote-kubeconfig "$KUBECONFIG_EUROPE_ROME_EDGE" --server-service-type NodePort
liqoctl peer --remote-kubeconfig "$KUBECONFIG_EUROPE_MILAN_EDGE" --server-service-type NodePort
liqoctl peer --remote-kubeconfig "$KUBECONFIG_EUROPE_ROME_EDGE" --gw-server-service-type NodePort
liqoctl peer --remote-kubeconfig "$KUBECONFIG_EUROPE_MILAN_EDGE" --gw-server-service-type NodePort
```

When the above commands return successfully, you can check the peering status by running:
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/service-offloading.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ The setup script named them **london** and **newyork**.
Once Liqo is installed in your clusters, you can establish new *peerings*:

```bash
liqoctl peer --remote-kubeconfig "$KUBECONFIG_NEWYORK" --server-service-type NodePort
liqoctl peer --remote-kubeconfig "$KUBECONFIG_NEWYORK" --gw-server-service-type NodePort
```

When the above command returns successfully, you can check the peering status by running:
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/stateful-applications.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ We suggest exporting the kubeconfig of the first cluster as default (i.e., `KUBE
Once Liqo is installed in your clusters, you can establish new *peerings*:

```bash
liqoctl peer --remote-kubeconfig "$KUBECONFIG_LYON" --server-service-type NodePort
liqoctl peer --remote-kubeconfig "$KUBECONFIG_LYON" --gw-server-service-type NodePort
```

When the above command returns successfully, you can check the peering status by running:
Expand Down
4 changes: 2 additions & 2 deletions pkg/liqoctl/network/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ func (c *Cluster) checkTemplateServerServiceNodePort(template *unstructured.Unst
// If the field is missing, it might be optional (represented by leading ?). If not, raise an error
if _, errOptional := maps.GetNestedField(port, "?nodePort"); errOptional != nil {
return fmt.Errorf("unable to get spec.template.spec.service.spec.ports[0].nodePort int the server template, " +
"since you specified the flag \"--server-service-nodeport\" you need to add the \"nodePort\" field in the template")
"since you specified the flag \"--gw-server-service-nodeport\" you need to add the \"nodePort\" field in the template")
}
}

Expand All @@ -333,7 +333,7 @@ func (c *Cluster) checkTemplateServerServiceLoadBalancer(template *unstructured.
// If the field is missing, it might be optional (represented by leading ?). If not, raise an error
if _, errOptional := maps.GetNestedField(template.Object, fmt.Sprintf("%s.?loadBalancerIP", servicePath)); errOptional != nil {
return fmt.Errorf("unable to get %s of the server template, "+
"since you specified the flag \"--server-service-loadbalancerip\" you need to add the \"loadBalancerIP\" field in the template", servicePath)
"since you specified the flag \"--gw-server-service-loadbalancerip\" you need to add the \"loadBalancerIP\" field in the template", servicePath)
}
}
return nil
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/pipeline/installer/liqo/peer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ do
ARGS=(--kubeconfig "${KUBECONFIG}" --remote-kubeconfig "${PROVIDER_KUBECONFIG}")

if [[ "${INFRA}" == "kubeadm" ]]; then
ARGS=("${ARGS[@]}" --server-service-type NodePort)
ARGS=("${ARGS[@]}" --gw-server-service-type NodePort)
elif [[ "${INFRA}" == "kind" ]]; then
ARGS=("${ARGS[@]}" --server-service-type NodePort)
ARGS=("${ARGS[@]}" --gw-server-service-type NodePort)
elif [[ "${INFRA}" == "k3s" ]]; then
ARGS=("${ARGS[@]}" --server-service-type NodePort)
ARGS=("${ARGS[@]}" --gw-server-service-type NodePort)
fi

echo "Environment variables:"
Expand Down

0 comments on commit fab005e

Please sign in to comment.