-
Notifications
You must be signed in to change notification settings - Fork 23
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
Conversation
🤖 Created branch: z_pr1231/vthapar/clustersetip |
cmd/subctl/deploybroker.go
Outdated
@@ -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)") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"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)") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
cmd/subctl/deploybroker.go
Outdated
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") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
cmd/subctl/export.go
Outdated
|
||
func addExportServiceFlags(cmd *cobra.Command) { | ||
exportRestConfigProducer.SetupFlags(exportServiceCmd.Flags()) | ||
cmd.PersistentFlags().BoolVar(&useClustersetIP, "use-clusterset-ip", false, "use clusterset ip for this service") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
cmd/subctl/join.go
Outdated
@@ -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)") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"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)") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
cmd/subctl/join.go
Outdated
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") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"ClustersetIP CIDR to be allocated to the cluster") | |
"Clusterset IP CIDR to be allocated to the cluster") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
pkg/deploy/submariner.go
Outdated
@@ -46,6 +47,7 @@ type SubmarinerOptions struct { | |||
LoadBalancerEnabled bool | |||
HealthCheckEnabled bool | |||
BrokerK8sInsecure bool | |||
ClustersetipEnabled bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ClustersetipEnabled bool | |
ClustersetIPEnabled bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
pkg/deploy/submariner.go
Outdated
@@ -105,6 +108,7 @@ func populateSubmarinerSpec(options *SubmarinerOptions, brokerInfo *broker.Info, | |||
BrokerK8sApiServer: brokerURL, | |||
BrokerK8sSecret: brokerSecret.ObjectMeta.Name, | |||
BrokerK8sInsecure: options.BrokerK8sInsecure, | |||
ClustersetIPEnabled: options.ClustersetipEnabled, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ClustersetIPEnabled: options.ClustersetipEnabled, | |
ClustersetIPEnabled: options.ClustersetipEnabled, | |
ClustersetIPCIDR: clustersetConfig.ClustersetIPCIDR, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
pkg/deploy/submariner.go
Outdated
if clustersetConfig.ClustersetIPCIDR != "" { | ||
submarinerSpec.ClustersetIPCIDR = clustersetConfig.ClustersetIPCIDR | ||
} |
There was a problem hiding this comment.
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.
if clustersetConfig.ClustersetIPCIDR != "" { | |
submarinerSpec.ClustersetIPCIDR = clustersetConfig.ClustersetIPCIDR | |
} |
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return errors.Wrap(err, "unable to determine clustersetIP CIDR") | |
return errors.Wrap(err, "unable to determine the clusterset IP CIDR") |
pkg/service/export.go
Outdated
@@ -43,6 +44,10 @@ func Export(clientProducer client.Producer, serviceNamespace, svcName string, st | |||
}, | |||
} | |||
|
|||
if useClustersetIP { | |||
mcsServiceExport.SetAnnotations(map[string]string{lhconstants.UseClustersetIP: "true"}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mcsServiceExport.SetAnnotations(map[string]string{lhconstants.UseClustersetIP: "true"}) | |
mcsServiceExport.SetAnnotations(map[string]string{lhconstants.UseClustersetIP: strconv.FormatBool(true)}) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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".
pkg/deploy/broker.go
Outdated
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") | ||
} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
Line 80 in e6b9fe5
if options.BrokerSpec.GlobalnetEnabled { |
There was a problem hiding this comment.
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.
4e5d3c1
to
670cb45
Compare
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]>
670cb45
to
3dd3407
Compare
🤖 Closed branches: [z_pr1231/vthapar/clustersetip] |
show networks
output.service export
Refer: submariner-io/enhancements#230