-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
57 lines (51 loc) · 1.34 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package hncclient
import (
"context"
"fmt"
"github.com/pkg/errors"
"github.com/whoisfisher/hncclient/versioned"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/rest"
)
type Host string
type Config struct {
Hosts []Host
Token string
}
func NewMonitoringClient(c *Config) (*versioned.Clientset, error) {
var aliveHost Host
aliveHost = "192.168.111.100"
kubeConf := &rest.Config{
Host: string(aliveHost),
BearerToken: c.Token,
TLSClientConfig: rest.TLSClientConfig{
Insecure: true,
},
}
client, err := versioned.NewForConfig(kubeConf)
if err != nil {
return client, errors.Wrap(err, fmt.Sprintf("new monitoring client with config failed: %v", err))
}
return client, nil
}
func getMonitorClient(clusterName string) (*versioned.Clientset, error) {
var client *versioned.Clientset
client, err := NewMonitoringClient(&Config{
Token: "eyJhbGciOiJSUzI1NiIsImtpZCI6ImtrcUdScWx1QS1LbFpicTl3cjhDN2xVd080Q185TmNSaVVrVEtOcUlTbUkifQ",
})
if err != nil {
return client, err
}
return client, nil
}
func main() {
client, err := getMonitorClient("mm")
if err != nil {
_ = fmt.Sprintf("====%s", err.Error())
}
snps, err := client.HNCV1Alpha2().SubnamespaceAnchors("parent-a").Get(context.TODO(), "child-b", metav1.GetOptions{})
if err != nil {
_ = fmt.Sprintf("====%s", err.Error())
}
_ = fmt.Sprintf("***%v", snps)
}