Path: blob/main/install/installer/pkg/common/networkpolicies.go
2500 views
// Copyright (c) 2021 Gitpod GmbH. All rights reserved.1// Licensed under the GNU Affero General Public License (AGPL).2// See License.AGPL.txt in the project root for license information.34package common56import (7corev1 "k8s.io/api/core/v1"8v1 "k8s.io/api/networking/v1"9metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"10"k8s.io/apimachinery/pkg/util/intstr"11)1213func AllowKubeDnsEgressRule() v1.NetworkPolicyEgressRule {14var tcp = corev1.ProtocolTCP15var udp = corev1.ProtocolUDP1617dnsEgressRule := v1.NetworkPolicyEgressRule{18Ports: []v1.NetworkPolicyPort{19{20Protocol: &tcp,21Port: &intstr.IntOrString{22IntVal: 53,23},24},25{26Protocol: &udp,27Port: &intstr.IntOrString{28IntVal: 53,29},30},31},32// Enable access to DNS service in the cluster: kube-dns or coredns33To: []v1.NetworkPolicyPeer{34{35PodSelector: &metav1.LabelSelector{36MatchLabels: map[string]string{37"k8s-app": "kube-dns",38},39},40NamespaceSelector: &metav1.LabelSelector{},41}, {42PodSelector: &metav1.LabelSelector{43MatchLabels: map[string]string{44"k8s-app": "coredns",45},46},47NamespaceSelector: &metav1.LabelSelector{},48},49},50}5152return dnsEgressRule53}545556