37 Star 406 Fork 74

GVPrancher/rancher

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
register.go 2.57 KB
一键复制 编辑 原始数据 按行查看 历史
package networkpolicy
import (
"context"
"github.com/rancher/types/config"
"github.com/sirupsen/logrus"
)
// Register initializes the controllers and registers
func Register(ctx context.Context, cluster *config.UserContext) {
logrus.Infof("Registering project network policy")
pnpLister := cluster.Management.Management.ProjectNetworkPolicies("").Controller().Lister()
pnps := cluster.Management.Management.ProjectNetworkPolicies("")
projectLister := cluster.Management.Management.Projects("").Controller().Lister()
projects := cluster.Management.Management.Projects("")
clusterLister := cluster.Management.Management.Clusters("").Controller().Lister()
clusters := cluster.Management.Management.Clusters("")
nodeLister := cluster.Core.Nodes("").Controller().Lister()
nsLister := cluster.Core.Namespaces("").Controller().Lister()
nses := cluster.Core.Namespaces("")
serviceLister := cluster.Core.Services("").Controller().Lister()
services := cluster.Core.Services("")
podLister := cluster.Core.Pods("").Controller().Lister()
pods := cluster.Core.Pods("")
npLister := cluster.Networking.NetworkPolicies("").Controller().Lister()
npClient := cluster.Networking
npmgr := &netpolMgr{nsLister, nodeLister, pods, projects,
npLister, npClient, projectLister, cluster.ClusterName}
ps := &projectSyncer{pnpLister, pnps, projects, clusterLister, cluster.ClusterName}
nss := &nsSyncer{npmgr, clusterLister, serviceLister, podLister,
services, pods, cluster.ClusterName}
pnpsyncer := &projectNetworkPolicySyncer{npmgr}
podHandler := &podHandler{npmgr, pods, clusterLister, cluster.ClusterName}
serviceHandler := &serviceHandler{npmgr, clusterLister, cluster.ClusterName}
nodeHandler := &nodeHandler{npmgr, clusterLister, cluster.ClusterName}
clusterHandler := &clusterHandler{cluster, pnpLister, podLister,
serviceLister, projectLister, clusters, pnps, npmgr, cluster.ClusterName}
clusterNetAnnHandler := &clusterNetAnnHandler{clusters, cluster.ClusterName}
projects.Controller().AddClusterScopedHandler(ctx, "projectSyncer", cluster.ClusterName, ps.Sync)
pnps.AddClusterScopedHandler(ctx, "projectNetworkPolicySyncer", cluster.ClusterName, pnpsyncer.Sync)
nses.AddHandler(ctx, "namespaceLifecycle", nss.Sync)
pods.AddHandler(ctx, "podHandler", podHandler.Sync)
services.AddHandler(ctx, "serviceHandler", serviceHandler.Sync)
cluster.Management.Management.Nodes(cluster.ClusterName).Controller().AddHandler(ctx, "nodeHandler", nodeHandler.Sync)
clusters.AddHandler(ctx, "clusterHandler", clusterHandler.Sync)
clusters.AddHandler(ctx, "clusterNetAnnHandler", clusterNetAnnHandler.Sync)
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/rancher/rancher.git
git@gitee.com:rancher/rancher.git
rancher
rancher
rancher
v2.2.4-rc22

搜索帮助