Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for clustersetIP #1231

Merged
merged 1 commit into from
Sep 25, 2024
Merged

Conversation

vthapar
Copy link
Contributor

@vthapar vthapar commented Sep 24, 2024

  1. Add ClustersetIP flags to deploy-broker and join.
  2. Add ClustersetIP CIDRs to config CRs.
  3. Show clustersetupCIDR in show networks output.
  4. Add use-clusterset-ip flag to service export

Refer: submariner-io/enhancements#230

@submariner-bot
Copy link
Contributor

🤖 Created branch: z_pr1231/vthapar/clustersetip
🚀 Full E2E won't run until the "ready-to-test" label is applied. I will add it automatically once the PR has 2 approvals, or you can add it manually.

@@ -89,6 +90,10 @@ func addDeployBrokerFlags(flags *pflag.FlagSet) {

flags.StringVar(&deployflags.BrokerURL, "broker-url", "",
"broker API endpoint URL (stored in the broker information file, defaults to the context URL)")
flags.BoolVar(&deployflags.BrokerSpec.ClustersetIPEnabled, "enable-clusterset-ip", false,
"set default support for ClustersetIP in connecting clusters (default disabled)")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"set default support for ClustersetIP in connecting clusters (default disabled)")
"set default support for use of clusterset IP for exported services in connecting clusters (default disabled)")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

flags.BoolVar(&deployflags.BrokerSpec.ClustersetIPEnabled, "enable-clusterset-ip", false,
"set default support for ClustersetIP in connecting clusters (default disabled)")
flags.StringVar(&deployflags.BrokerSpec.ClustersetIPCIDRRange, "clusterset-ip-cidr-range",
clustersetip.DefaultCIDR, "ClustersetIP CIDR supernet range for allocating ClustersetIP CIDRs to each cluster")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
clustersetip.DefaultCIDR, "ClustersetIP CIDR supernet range for allocating ClustersetIP CIDRs to each cluster")
clustersetip.DefaultCIDR, "Clusterset IP CIDR supernet range for allocating clusterset IP CIDRs to each cluster")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


func addExportServiceFlags(cmd *cobra.Command) {
exportRestConfigProducer.SetupFlags(exportServiceCmd.Flags())
cmd.PersistentFlags().BoolVar(&useClustersetIP, "use-clusterset-ip", false, "use clusterset ip for this service")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
cmd.PersistentFlags().BoolVar(&useClustersetIP, "use-clusterset-ip", false, "use clusterset ip for this service")
cmd.PersistentFlags().BoolVar(&useClustersetIP, "use-clusterset-ip", false, "use clusterset IP for this service")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -147,6 +147,10 @@ func addJoinFlags(cmd *cobra.Command) {
"check the broker certificate (disable this to allow \"insecure\" connections)")
cmd.Flags().StringVar(&joinFlags.BrokerURL, "broker-url", "",
"URL of the broker API endpoint (overrides the URL stored in the broker information file)")
cmd.Flags().BoolVar(&joinFlags.EnableClustersetIP, "enable-clusterset-ip", false,
"set default support for ClustersetIP in the cluster (default disabled)")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"set default support for ClustersetIP in the cluster (default disabled)")
"set default support for use of clusterset IP for exported services in the cluster (default disabled)")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

cmd.Flags().BoolVar(&joinFlags.EnableClustersetIP, "enable-clusterset-ip", false,
"set default support for ClustersetIP in the cluster (default disabled)")
cmd.Flags().StringVar(&joinFlags.ClustersetIPCIDR, "clusterset-ip-cidr", "",
"ClustersetIP CIDR to be allocated to the cluster")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"ClustersetIP CIDR to be allocated to the cluster")
"Clusterset IP CIDR to be allocated to the cluster")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -46,6 +47,7 @@ type SubmarinerOptions struct {
LoadBalancerEnabled bool
HealthCheckEnabled bool
BrokerK8sInsecure bool
ClustersetipEnabled bool
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ClustersetipEnabled bool
ClustersetIPEnabled bool

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -105,6 +108,7 @@ func populateSubmarinerSpec(options *SubmarinerOptions, brokerInfo *broker.Info,
BrokerK8sApiServer: brokerURL,
BrokerK8sSecret: brokerSecret.ObjectMeta.Name,
BrokerK8sInsecure: options.BrokerK8sInsecure,
ClustersetIPEnabled: options.ClustersetipEnabled,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ClustersetIPEnabled: options.ClustersetipEnabled,
ClustersetIPEnabled: options.ClustersetipEnabled,
ClustersetIPCIDR: clustersetConfig.ClustersetIPCIDR,

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines 133 to 135
if clustersetConfig.ClustersetIPCIDR != "" {
submarinerSpec.ClustersetIPCIDR = clustersetConfig.ClustersetIPCIDR
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can just initialize above regardless if empty.

Suggested change
if clustersetConfig.ClustersetIPCIDR != "" {
submarinerSpec.ClustersetIPCIDR = clustersetConfig.ClustersetIPCIDR
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah right, forgot that this is omitifempty.

pkg/join/join.go Outdated
err = clustersetip.AllocateCIDRFromConfigMap(ctx, brokerClientProducer.ForGeneral(), brokerNamespace,
&clustersetConfig, status)
if err != nil {
return errors.Wrap(err, "unable to determine clustersetIP CIDR")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return errors.Wrap(err, "unable to determine clustersetIP CIDR")
return errors.Wrap(err, "unable to determine the clusterset IP CIDR")

@@ -43,6 +44,10 @@ func Export(clientProducer client.Producer, serviceNamespace, svcName string, st
},
}

if useClustersetIP {
mcsServiceExport.SetAnnotations(map[string]string{lhconstants.UseClustersetIP: "true"})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
mcsServiceExport.SetAnnotations(map[string]string{lhconstants.UseClustersetIP: "true"})
mcsServiceExport.SetAnnotations(map[string]string{lhconstants.UseClustersetIP: strconv.FormatBool(true)})

Copy link
Contributor Author

@vthapar vthapar Sep 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the tricky one. Way flags work, default is false. But I don't want to set anything if user hasn't given an explicit option. In this case, setting it to false is different from not setting it at all. Not setting it means it will use the global setting on cluster. Setting false means even if global is true, it will not use clustersetip for this service.

I realize the way I've done means user can never set false explicitly, but I went with my option for backwards compatibility where existing usage is to not have it set at all.

Any suggestions on how we can handle it better? This is a case where we want true, false, nil. Can we do that?

EDIT: How about make it a string?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah make it a string and verify it's either "true" or "false".

Comment on lines 91 to 100
if err = clustersetip.ValidateExistingClustersetIPNetworks(ctx, clientProducer.ForGeneral(), options.BrokerNamespace); err != nil {
return status.Error(err, "error validating existing clustersetIPCIDR configmap")
}

if err = clustersetip.CreateConfigMap(ctx, clientProducer.ForGeneral(), options.BrokerSpec.ClustersetIPEnabled,
options.BrokerSpec.ClustersetIPCIDRRange, 0, options.BrokerNamespace); err != nil {
return status.Error(err, "error creating clustersetIPCIDR configmap on Broker")
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the broker controller handle this as it does for globalnet?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the broker controller handle this as it does for globalnet?

Yeah, it should but that is for addon use case where addon operator runs broker controller. There is no broker controller when usin subctl to deploy broker, that is why we do this for globlanet too in subctl.

if options.BrokerSpec.GlobalnetEnabled {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, the broker controller always runs in the operator pod - it's activated by creation of the Broker resource.

The behavior wrt the addon vs subctl is actually the opposite: the addon creates the globalnet ConfigMap and does not create the Broker resource while subctl does both tho I'm not sure why. It's fine if we do the same for clusterset IP here to mirror globalnet behavior but perhaps we should also do the same in the broker controller otherwise it renders the new fields in the Broker CRD meaningless. We could revisit the duplicate behavior later.

Also note that the helm charts does neither but it's moot b/c we expect the user to pass in the global CIDR when deploying the operator.

@tpantelis tpantelis requested a review from yboaron September 25, 2024 13:30
1. Add ClustersetIP flags to deploy-broker and join.
2. Add ClustersetIP CIDRs to config CRs.
3. Show clustersetupCIDR in `show networks` output.
4. Add use-clusterset-ip flag to `service export`

Refer: submariner-io/enhancements#230

Signed-off-by: Vishal Thapar <[email protected]>
@tpantelis tpantelis added the ready-to-test When a PR is ready for full E2E testing label Sep 25, 2024
@tpantelis tpantelis merged commit 3c28b2e into submariner-io:devel Sep 25, 2024
33 checks passed
@submariner-bot
Copy link
Contributor

🤖 Closed branches: [z_pr1231/vthapar/clustersetip]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-to-test When a PR is ready for full E2E testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants