-3
我想随机关闭kubernetes集群中的集群并使用go。我已经编写了代码,可以登录到服务器并运行代码。go:随机终止kubernetes集群中的集群
现在我需要读取集群中所有可用的pod,随机选择一些并终止它们。 (我是新来的)
你能帮我做这个吗?
这是我在集群/服务器上运行命令 cli.ExecuteCmd("kubectl get pods")
// Use one connection per command.
// Catch in the client when required.
func (cli *SSHClient)ExecuteCmd(command string){
conn, err := ssh.Dial("tcp", cli.Hostname+":22", cli.Config)
if err!=nil {
logrus.Infof("%[email protected]%s", cli.Config.User, cli.Hostname)
logrus.Info("Hint: Add you key to the ssh agent: 'ssh-add ~/.ssh/id_rsa'")
logrus.Fatal(err)
}
session, _ := conn.NewSession()
defer session.Close()
var stdoutBuf bytes.Buffer
session.Stdout = &stdoutBuf
err = session.Run(command)
if err != nil {
logrus.Fatalf("Run failed:%v", err)
}
logrus.Infof(">%s", stdoutBuf.Bytes())
}
你正在努力的是哪一部分? –
我不知道如何编写随机选择豆荚的函数。 – user6942447
因为我必须先阅读它们,然后随机选择它们 – user6942447