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 set ssh jump server in cls #2001

Merged
merged 1 commit into from
Jun 27, 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
68 changes: 67 additions & 1 deletion api/openapi/zz_generated.openapi.go

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

13 changes: 13 additions & 0 deletions api/platform/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,19 @@ func (in *ClusterMachine) SSH() (*ssh.SSH, error) {
DialTimeOut: time.Second,
Retry: 0,
}
switch in.Proxy.Type {
case SSHJumpServer:
proxy := ssh.JumpServer{}
proxy.Host = in.Proxy.IP
proxy.Port = int(in.Proxy.Port)
proxy.User = in.Proxy.Username
proxy.Password = string(in.Proxy.Password)
proxy.PrivateKey = in.Proxy.PrivateKey
proxy.PassPhrase = in.Proxy.PassPhrase
proxy.DialTimeOut = time.Second
proxy.Retry = 0
sshConfig.Proxy = proxy
}
return ssh.New(sshConfig)
}

Expand Down
21 changes: 21 additions & 0 deletions api/platform/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,29 @@ type ClusterMachine struct {
PassPhrase []byte
Labels map[string]string
Taints []corev1.Taint
Proxy ClusterMachineProxy
}

// ClusterMachine is the proxy definition of ClusterMachine.
type ClusterMachineProxy struct {
Type ProxyType
IP string
Port int32
Username string
Password []byte
PrivateKey []byte
PassPhrase []byte
}

// ProxyType describes diffirent type of proxy
type ProxyType string

const (
// SSH jumper server proxy
SSHJumpServer ProxyType = "SSHJumpServer"
// SOCKS5 ProxyType = "SOCKS5"
)

// 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
13 changes: 13 additions & 0 deletions api/platform/v1/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,19 @@ func (in *ClusterMachine) SSH() (*ssh.SSH, error) {
DialTimeOut: time.Second,
Retry: 0,
}
switch in.Proxy.Type {
case SSHJumpServer:
proxy := ssh.JumpServer{}
proxy.Host = in.Proxy.IP
proxy.Port = int(in.Proxy.Port)
proxy.User = in.Proxy.Username
proxy.Password = string(in.Proxy.Password)
proxy.PrivateKey = in.Proxy.PrivateKey
proxy.PassPhrase = in.Proxy.PassPhrase
proxy.DialTimeOut = time.Second
proxy.Retry = 0
sshConfig.Proxy = proxy
}
return ssh.New(sshConfig)
}

Expand Down
Loading