mirror of
https://gitee.com/rainbond/Rainbond.git
synced 2024-12-03 04:07:51 +08:00
[ADD] add test code
This commit is contained in:
parent
04de79df61
commit
eafe732fab
32
appruntimesync/clean/clean.go
Normal file
32
appruntimesync/clean/clean.go
Normal file
@ -0,0 +1,32 @@
|
||||
package clean
|
||||
|
||||
import (
|
||||
"k8s.io/client-go/kubernetes"
|
||||
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"fmt"
|
||||
"github.com/Sirupsen/logrus"
|
||||
)
|
||||
|
||||
type CheanManager struct {
|
||||
kubeclient *kubernetes.Clientset
|
||||
}
|
||||
|
||||
func NewCheanManager(kubeclient *kubernetes.Clientset) *CheanManager {
|
||||
m := &CheanManager{
|
||||
kubeclient: kubeclient,
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
||||
func (c *CheanManager) Start() {
|
||||
logrus.Info("clean 开始工作...")
|
||||
go c.Run()
|
||||
}
|
||||
|
||||
func (c *CheanManager) Run() {
|
||||
Namespaces1, err := c.kubeclient.CoreV1().Namespaces().List(meta_v1.ListOptions{})
|
||||
if err != nil{
|
||||
fmt.Println(err)
|
||||
}
|
||||
fmt.Println("namespaces:",Namespaces1)
|
||||
}
|
@ -31,6 +31,7 @@ import (
|
||||
"golang.org/x/net/context"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
"k8s.io/client-go/tools/clientcmd"
|
||||
"github.com/goodrain/rainbond/appruntimesync/clean"
|
||||
)
|
||||
|
||||
//AppRuntimeSyncServer AppRuntimeSyncServer
|
||||
@ -42,6 +43,7 @@ type AppRuntimeSyncServer struct {
|
||||
Cancel context.CancelFunc
|
||||
ClientSet *kubernetes.Clientset
|
||||
podCache *pod.CacheManager
|
||||
clean *clean.CheanManager
|
||||
}
|
||||
|
||||
//NewAppRuntimeSyncServer create app runtime sync server
|
||||
@ -60,6 +62,7 @@ func NewAppRuntimeSyncServer(conf option.Config) *AppRuntimeSyncServer {
|
||||
statusManager := status.NewManager(ctx, clientset)
|
||||
stopChan := make(chan struct{})
|
||||
podCache := pod.NewCacheManager(clientset)
|
||||
Clean := clean.NewCheanManager(clientset)
|
||||
arss := &AppRuntimeSyncServer{
|
||||
c: conf,
|
||||
Ctx: ctx,
|
||||
@ -67,6 +70,7 @@ func NewAppRuntimeSyncServer(conf option.Config) *AppRuntimeSyncServer {
|
||||
Cancel: cancel,
|
||||
ClientSet: clientset,
|
||||
podCache: podCache,
|
||||
clean: Clean,
|
||||
}
|
||||
arss.StatusManager = statusManager
|
||||
return arss
|
||||
@ -137,6 +141,7 @@ func (a *AppRuntimeSyncServer) Start() error {
|
||||
a.stopChan,
|
||||
)
|
||||
a.podCache.Start()
|
||||
a.clean.Start()
|
||||
logrus.Info("app runtime sync server started...")
|
||||
return nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user