forked from cr7258/kubernetes-guide
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1.client.go
More file actions
37 lines (34 loc) · 730 Bytes
/
1.client.go
File metadata and controls
37 lines (34 loc) · 730 Bytes
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
package main
/**
* @description
* @author chengzw
* @since 2023/7/29
* @link
*/
import (
"context"
"fmt"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/types"
"my-controller-runtime/lib"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/manager"
"time"
)
func main() {
mgr, err := manager.New(lib.K8sRestConfig(),
manager.Options{
Logger: logf.Log.WithName("test"),
})
lib.Check(err)
go func() {
time.Sleep(time.Second * 3)
pod := &v1.Pod{}
err = mgr.GetClient().Get(context.TODO(),
types.NamespacedName{Namespace: "default", Name: "wiremock-84d49c989c-8jl29"}, pod)
lib.Check(err)
fmt.Println(pod)
}()
err = mgr.Start(context.Background())
lib.Check(err)
}