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

feat(platform): support registry to cluster net #2005

Merged
merged 1 commit into from
Jun 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions api/platform/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ const (
// SOCKS5 ProxyType = "SOCKS5"
)

const (
// RegistrationCommandAnno contains base64 registration command of cluster net
RegistrationCommandAnno = "tkestack.io/registration-command"
)

// KubeVendorType describe the kubernetes provider of the cluster
// ref https://github.com/open-cluster-management/multicloud-operators-foundation/blob/e94b719de6d5f3541e948dd70ad8f1ff748aa452/pkg/apis/internal.open-cluster-management.io/v1beta1/clusterinfo_types.go#L137
type KubeVendorType string
Expand Down
5 changes: 5 additions & 0 deletions api/platform/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ const (
// SOCKS5 ProxyType = "SOCKS5"
)

const (
// RegistrationCommandAnno contains base64 registration command of cluster net
RegistrationCommandAnno = "tkestack.io/registration-command"
)

// KubeVendorType describe the kubernetes provider of the cluster
// ref https://github.com/open-cluster-management/multicloud-operators-foundation/blob/e94b719de6d5f3541e948dd70ad8f1ff748aa452/pkg/apis/internal.open-cluster-management.io/v1beta1/clusterinfo_types.go#L137
type KubeVendorType string
Expand Down
21 changes: 21 additions & 0 deletions pkg/platform/provider/baremetal/cluster/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ package cluster
import (
"bytes"
"context"
"encoding/base64"
"encoding/hex"
"fmt"
"io/ioutil"
Expand Down Expand Up @@ -1534,3 +1535,23 @@ func (p *Provider) EnsureInitAPIServerHost(ctx context.Context, c *v1.Cluster) e
func (p *Provider) EnsureModifyAPIServerHost(ctx context.Context, c *v1.Cluster) error {
return p.setAPIServerHost(ctx, c, "127.0.0.1")
}

func (p *Provider) EnsureClusternetRegistration(ctx context.Context, c *v1.Cluster) error {
if c.Annotations[platformv1.RegistrationCommandAnno] == "" {
log.FromContext(ctx).Info("registration command is empty, skip EnsureClusternetRegistration")
return nil
}
cmd, err := base64.StdEncoding.DecodeString(c.Annotations[platformv1.RegistrationCommandAnno])
if err != nil {
return fmt.Errorf("decode registration command failed: %v", err)
}
machineSSH, err := c.Spec.Machines[0].SSH()
if err != nil {
return err
}
_, stderr, exit, err := machineSSH.Exec(string(cmd))
if err != nil {
return fmt.Errorf("exec %q failed:exit %d:stderr %s:error %s", cmd, exit, stderr, err)
}
return nil
}
2 changes: 2 additions & 0 deletions pkg/platform/provider/baremetal/cluster/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ func NewProvider() (*Provider, error) {
p.EnsureJoinPhaseControlPlaneJoinETCD,
p.EnsureJoinPhaseControlPlaneJoinUpdateStatus,

p.EnsureClusternetRegistration,

p.EnsureGalaxy,
p.EnsureCilium,

Expand Down
5 changes: 0 additions & 5 deletions pkg/platform/types/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,7 @@ func (c *Cluster) RESTConfigForBootstrap() (*rest.Config, error) {
if err != nil {
return nil, err
}
host, err := c.HostForBootstrap()
if err != nil {
return nil, err
}
configCopy := *c.restConfig
configCopy.Host = host

return &configCopy, nil
}
Expand Down