Skip to content

Commit

Permalink
Merge pull request #12064 from sp98/use-cluster-id
Browse files Browse the repository at this point in the history
MCS: use cluster ID for ns lookup on exported service.
  • Loading branch information
travisn committed Apr 11, 2023
2 parents 85d7920 + 9e8e85d commit 85088e7
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 4 deletions.
3 changes: 3 additions & 0 deletions deploy/charts/rook-ceph/templates/resources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1920,6 +1920,9 @@ spec:
multiClusterService:
description: Enable multiClusterService to export the Services between peer clusters
properties:
clusterID:
description: 'ClusterID uniquely identifies a cluster. It is used as a prefix to nslookup exported services. For example: <clusterid>.<svc>.<ns>.svc.clusterset.local'
type: string
enabled:
description: Enable multiClusterService to export the mon and OSD services to peer cluster. Ensure that peer clusters are connected using an MCS API compatible application, like Globalnet Submariner.
type: boolean
Expand Down
3 changes: 3 additions & 0 deletions deploy/examples/crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1918,6 +1918,9 @@ spec:
multiClusterService:
description: Enable multiClusterService to export the Services between peer clusters
properties:
clusterID:
description: 'ClusterID uniquely identifies a cluster. It is used as a prefix to nslookup exported services. For example: <clusterid>.<svc>.<ns>.svc.clusterset.local'
type: string
enabled:
description: Enable multiClusterService to export the mon and OSD services to peer cluster. Ensure that peer clusters are connected using an MCS API compatible application, like Globalnet Submariner.
type: boolean
Expand Down
4 changes: 4 additions & 0 deletions pkg/apis/ceph.rook.io/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -2207,6 +2207,10 @@ type MultiClusterServiceSpec struct {
// like Globalnet Submariner.
// +optional
Enabled bool `json:"enabled,omitempty"`

// ClusterID uniquely identifies a cluster. It is used as a prefix to nslookup exported
// services. For example: <clusterid>.<svc>.<ns>.svc.clusterset.local
ClusterID string `json:"clusterID,omitempty"`
}
type ConnectionsSpec struct {
// Encryption settings for the network connections.
Expand Down
32 changes: 32 additions & 0 deletions pkg/apis/ceph.rook.io/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/operator/ceph/cluster/mon/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func (c *Cluster) createService(mon *monConfig) (*v1.Service, error) {

func (c *Cluster) exportService(service *v1.Service, monDaemon string) (string, error) {
logger.Infof("exporting service %q", service.Name)
exportedIP, err := k8sutil.ExportService(c.ClusterInfo.Context, c.context, service)
exportedIP, err := k8sutil.ExportService(c.ClusterInfo.Context, c.context, service, c.spec.Network.MultiClusterService.ClusterID)
if err != nil {
return "", errors.Wrapf(err, "failed to export service %q", service.Name)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/operator/ceph/cluster/osd/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ func (c *Cluster) makeDeployment(osdProps osdProperties, osd OSDInfo, provisionC
return nil, errors.Wrapf(err, "failed to configure osd service for osd.%d", osd.ID)
}

exportedIP, err := k8sutil.ExportService(c.clusterInfo.Context, c.context, osdService)
exportedIP, err := k8sutil.ExportService(c.clusterInfo.Context, c.context, osdService, c.spec.Network.MultiClusterService.ClusterID)
if err != nil {
return nil, errors.Wrapf(err, "failed to export service %q", osdService.Name)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/operator/k8sutil/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func IsServiceExported(ctx context.Context, c *clusterd.Context, name, namespace
}

// ExportService exports the service using MCS API and returns the external IP of the exported service
func ExportService(ctx context.Context, c *clusterd.Context, service *v1.Service) (string, error) {
func ExportService(ctx context.Context, c *clusterd.Context, service *v1.Service, clusterID string) (string, error) {
client, err := mcsv1Client.NewForConfig(c.KubeConfig)
if err != nil {
return "", errors.Wrap(err, "failed to get mcs-api client")
Expand All @@ -140,7 +140,7 @@ func ExportService(ctx context.Context, c *clusterd.Context, service *v1.Service

var exportedIP string
var serviceExportError error
exportedIP, err = GetExportedServiceIP(fmt.Sprintf("%s.%s.svc.clusterset.local", service.Name, service.Namespace))
exportedIP, err = GetExportedServiceIP(fmt.Sprintf("%s.%s.%s.svc.clusterset.local", clusterID, service.Name, service.Namespace))

if err != nil {
serviceExportError = errors.Wrapf(err, "failed to get exported service IP for %q", service.Name)
Expand Down

0 comments on commit 85088e7

Please sign in to comment.