Skip to content

Commit

Permalink
feat(platform): support set ssh jump server in cls (#2001)
Browse files Browse the repository at this point in the history
  • Loading branch information
Leo Ryu committed Jun 27, 2022
1 parent fd09358 commit 7a6737b
Show file tree
Hide file tree
Showing 17 changed files with 1,262 additions and 421 deletions.
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

0 comments on commit 7a6737b

Please sign in to comment.