Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
水淹萌龙
kubesphere
提交
e6365c62
K
kubesphere
项目概览
水淹萌龙
/
kubesphere
与 Fork 源项目一致
Fork自
KubeSphere / kubesphere
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
kubesphere
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
e6365c62
编写于
1月 25, 2021
作者:
K
KubeSphere CI Bot
提交者:
GitHub
1月 25, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #3214 from yuswift/feature/support_configurable_cluster_resync_perioud
Configurable cluster resync perioud
上级
3c795482
9e0a4b69
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
34 addition
and
22 deletion
+34
-22
cmd/controller-manager/app/controllers.go
cmd/controller-manager/app/controllers.go
+6
-2
cmd/controller-manager/app/server.go
cmd/controller-manager/app/server.go
+1
-1
pkg/controller/cluster/cluster_controller.go
pkg/controller/cluster/cluster_controller.go
+8
-13
pkg/simple/client/multicluster/options.go
pkg/simple/client/multicluster/options.go
+19
-6
未找到文件。
cmd/controller-manager/app/controllers.go
浏览文件 @
e6365c62
...
...
@@ -48,6 +48,7 @@ import (
"kubesphere.io/kubesphere/pkg/simple/client/devops"
"kubesphere.io/kubesphere/pkg/simple/client/k8s"
ldapclient
"kubesphere.io/kubesphere/pkg/simple/client/ldap"
"kubesphere.io/kubesphere/pkg/simple/client/multicluster"
"kubesphere.io/kubesphere/pkg/simple/client/network"
ippoolclient
"kubesphere.io/kubesphere/pkg/simple/client/network/ippool"
"kubesphere.io/kubesphere/pkg/simple/client/openpitrix"
...
...
@@ -66,7 +67,7 @@ func addControllers(
options
*
k8s
.
KubernetesOptions
,
authenticationOptions
*
authoptions
.
AuthenticationOptions
,
openpitrixClient
openpitrix
.
Client
,
multiCluster
Enabled
bool
,
multiCluster
Options
*
multicluster
.
Options
,
networkOptions
*
network
.
Options
,
serviceMeshEnabled
bool
,
kubectlImage
string
,
...
...
@@ -76,6 +77,8 @@ func addControllers(
istioInformer
:=
informerFactory
.
IstioSharedInformerFactory
()
kubesphereInformer
:=
informerFactory
.
KubeSphereSharedInformerFactory
()
multiClusterEnabled
:=
multiClusterOptions
.
Enable
var
vsController
,
drController
manager
.
Runnable
if
serviceMeshEnabled
{
vsController
=
virtualservice
.
NewVirtualServiceController
(
kubernetesInformer
.
Core
()
.
V1
()
.
Services
(),
...
...
@@ -229,7 +232,8 @@ func addControllers(
client
.
Config
(),
kubesphereInformer
.
Cluster
()
.
V1alpha1
()
.
Clusters
(),
client
.
KubeSphere
()
.
ClusterV1alpha1
()
.
Clusters
(),
openpitrixClient
)
openpitrixClient
,
multiClusterOptions
.
ClusterControllerResyncSecond
)
}
var
nsnpController
manager
.
Runnable
...
...
cmd/controller-manager/app/server.go
浏览文件 @
e6365c62
...
...
@@ -251,7 +251,7 @@ func run(s *options.KubeSphereControllerManagerOptions, stopCh <-chan struct{})
s
.
KubernetesOptions
,
s
.
AuthenticationOptions
,
openpitrixClient
,
s
.
MultiClusterOptions
.
Enable
,
s
.
MultiClusterOptions
,
s
.
NetworkOptions
,
servicemeshEnabled
,
s
.
AuthenticationOptions
.
KubectlImage
,
stopCh
);
err
!=
nil
{
...
...
pkg/controller/cluster/cluster_controller.go
浏览文件 @
e6365c62
...
...
@@ -158,6 +158,8 @@ type clusterController struct {
mu
sync
.
RWMutex
clusterMap
map
[
string
]
*
clusterData
resyncPeriod
time
.
Duration
}
func
NewClusterController
(
...
...
@@ -166,6 +168,7 @@ func NewClusterController(
clusterInformer
clusterinformer
.
ClusterInformer
,
clusterClient
clusterclient
.
ClusterInterface
,
openpitrixClient
openpitrix
.
Client
,
resyncPeriod
time
.
Duration
,
)
*
clusterController
{
broadcaster
:=
record
.
NewBroadcaster
()
...
...
@@ -185,23 +188,18 @@ func NewClusterController(
queue
:
workqueue
.
NewNamedRateLimitingQueue
(
workqueue
.
DefaultControllerRateLimiter
(),
"cluster"
),
workerLoopPeriod
:
time
.
Second
,
clusterMap
:
make
(
map
[
string
]
*
clusterData
),
resyncPeriod
:
resyncPeriod
,
}
c
.
clusterLister
=
clusterInformer
.
Lister
()
c
.
clusterHasSynced
=
clusterInformer
.
Informer
()
.
HasSynced
clusterInformer
.
Informer
()
.
AddEventHandler
(
cache
.
ResourceEventHandlerFuncs
{
clusterInformer
.
Informer
()
.
AddEventHandler
WithResyncPeriod
(
cache
.
ResourceEventHandlerFuncs
{
AddFunc
:
c
.
addCluster
,
UpdateFunc
:
func
(
oldObj
,
newObj
interface
{})
{
newCluster
:=
newObj
.
(
*
clusterv1alpha1
.
Cluster
)
oldCluster
:=
oldObj
.
(
*
clusterv1alpha1
.
Cluster
)
if
newCluster
.
ResourceVersion
==
oldCluster
.
ResourceVersion
{
return
}
c
.
addCluster
(
newObj
)
},
DeleteFunc
:
c
.
addCluster
,
})
}
,
resyncPeriod
)
return
c
}
...
...
@@ -227,15 +225,11 @@ func (c *clusterController) Run(workers int, stopCh <-chan struct{}) error {
// refresh cluster configz every 2 minutes
go
wait
.
Until
(
func
()
{
if
err
:=
c
.
syncStatus
();
err
!=
nil
{
klog
.
Errorf
(
"Error periodically sync cluster status, %v"
,
err
)
}
if
err
:=
c
.
reconcileHostCluster
();
err
!=
nil
{
klog
.
Errorf
(
"Error create host cluster, error %v"
,
err
)
}
},
2
*
time
.
Minute
,
stopCh
)
},
c
.
resyncPeriod
,
stopCh
)
<-
stopCh
return
nil
...
...
@@ -355,6 +349,7 @@ func (c *clusterController) reconcileHostCluster() error {
}
func
(
c
*
clusterController
)
syncCluster
(
key
string
)
error
{
klog
.
V
(
5
)
.
Infof
(
"starting to sync cluster %s"
,
key
)
startTime
:=
time
.
Now
()
_
,
name
,
err
:=
cache
.
SplitMetaNamespaceKey
(
key
)
...
...
pkg/simple/client/multicluster/options.go
浏览文件 @
e6365c62
...
...
@@ -16,7 +16,13 @@ limitations under the License.
package
multicluster
import
"github.com/spf13/pflag"
import
(
"time"
"github.com/spf13/pflag"
)
const
DefaultResyncPeriod
=
time
.
Duration
(
120
)
*
time
.
Second
type
Options
struct
{
// Enable
...
...
@@ -36,16 +42,20 @@ type Options struct {
// AgentImage is the image used when generating deployment for all cluster agents.
AgentImage
string
`json:"agentImage,omitempty"`
// ClusterControllerResyncSecond is the resync period used by cluster controller.
ClusterControllerResyncSecond
time
.
Duration
`json:"clusterControllerResyncSecond,omitempty" yaml:"clusterControllerResyncSecond"`
}
// NewOptions() returns a default nil options
func
NewOptions
()
*
Options
{
return
&
Options
{
Enable
:
false
,
EnableFederation
:
false
,
ProxyPublishAddress
:
""
,
ProxyPublishService
:
""
,
AgentImage
:
"kubesphere/tower:v1.0"
,
Enable
:
false
,
EnableFederation
:
false
,
ProxyPublishAddress
:
""
,
ProxyPublishService
:
""
,
AgentImage
:
"kubesphere/tower:v1.0"
,
ClusterControllerResyncSecond
:
DefaultResyncPeriod
,
}
}
...
...
@@ -67,4 +77,7 @@ func (o *Options) AddFlags(fs *pflag.FlagSet, s *Options) {
fs
.
StringVar
(
&
o
.
AgentImage
,
"agent-image"
,
s
.
AgentImage
,
""
+
"This field is used when generating deployment yaml for agent."
)
fs
.
DurationVar
(
&
o
.
ClusterControllerResyncSecond
,
"cluster-controller-resync-second"
,
s
.
ClusterControllerResyncSecond
,
"Cluster controller resync second to sync cluster resource."
)
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录