37 Star 411 Fork 76

GVPrancher/rancher

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
nssyncer.go 923 Bytes
一键复制 编辑 原始数据 按行查看 历史
Murali Paluru 提交于 2018-03-31 00:59 . fixes
package networkpolicy
import (
"github.com/rancher/rancher/pkg/controllers/user/nslabels"
"github.com/sirupsen/logrus"
corev1 "k8s.io/api/core/v1"
)
type nsSyncer struct {
npmgr *netpolMgr
}
// Sync invokes Policy Handler to program the native network policies
func (nss *nsSyncer) Sync(key string, ns *corev1.Namespace) error {
if ns == nil || ns.DeletionTimestamp != nil {
return nil
}
logrus.Debugf("nsSyncer: Sync: %v, %+v", ns.Name, *ns)
// program project isolation network policy
projectID, ok := ns.Labels[nslabels.ProjectIDFieldLabel]
if ok {
logrus.Debugf("nsSyncer: Sync: ns=%v projectID=%v", ns.Name, projectID)
if err := nss.npmgr.programNetworkPolicy(projectID); err != nil {
logrus.Errorf("nsSyncer: Sync: error programming network policy: %v (ns=%v, projectID=%v), ", err, ns.Name, projectID)
}
}
// handle if hostNetwork policy is needed
return nss.npmgr.handleHostNetwork()
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/rancher/rancher.git
git@gitee.com:rancher/rancher.git
rancher
rancher
rancher
v2.0.5-rc5

搜索帮助

0d507c66 1850385 C8b1a773 1850385