代码拉取完成,页面将自动刷新
package networkpolicy
import (
"fmt"
"github.com/rancher/norman/types/convert"
"github.com/rancher/rancher/pkg/controllers/user/nslabels"
"github.com/rancher/types/apis/core/v1"
"github.com/rancher/types/apis/management.cattle.io/v3"
corev1 "k8s.io/api/core/v1"
)
func isNetworkPolicyDisabled(clusterNamespace string, clusterLister v3.ClusterLister) (bool, error) {
cluster, err := clusterLister.Get("", clusterNamespace)
if err != nil {
return false, fmt.Errorf("error getting cluster %v", err)
}
return !convert.ToBool(cluster.Annotations[netPolAnnotation]), nil
}
func isNamespaceMoved(namespace string, nsLister v1.NamespaceLister) (bool, error) {
ns, err := nsLister.Get("", namespace)
if err != nil {
return false, fmt.Errorf("error getting ns %v", err)
}
if _, ok := ns.Annotations[nslabels.ProjectIDFieldLabel]; !ok {
return true, nil
}
return ns.Annotations[nslabels.ProjectIDFieldLabel] == "", nil
}
func nodePortService(service *corev1.Service) bool {
for _, port := range service.Spec.Ports {
if port.NodePort != 0 {
return true
}
}
return false
}
func hostPortPod(pod *corev1.Pod) bool {
for _, c := range pod.Spec.Containers {
for _, port := range c.Ports {
if port.HostPort != 0 {
return true
}
}
}
return false
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。