Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions deploy/chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,11 @@ networkPolicy:
port: 53
- protocol: UDP
port: 53
kubeAPIServer:
ports:
- protocol: TCP
port: 6443
port: 5353
- protocol: UDP
port: 5353
kubeAPIServer: {}
metrics:
ports:
- protocol: TCP
Expand Down
36 changes: 33 additions & 3 deletions pkg/controller/registry/reconciler/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,29 @@ func DesiredGRPCServerNetworkPolicy(catalogSource *v1alpha1.CatalogSource, match
},
}

// Allow egress to kube-apiserver from configmap backed catalog sources
// Allow egress to kube-apiserver and DNS from configmap backed catalog sources
if catalogSource.Spec.SourceType == v1alpha1.SourceTypeConfigmap || catalogSource.Spec.SourceType == v1alpha1.SourceTypeInternal {
np.Spec.Egress = []networkingv1.NetworkPolicyEgressRule{
// Wildcard allow all IPs/Ports for kube-apiserver
{},
// Wildcard allow all IPs with DNS ports
Comment on lines +52 to +54
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The {} seems to make the specific ports for DNS redundant.
It's either allow all through, or allow these specific DNS ports.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup this is intentional and adheres with the guidance from the networking team. The reasoning being that if we ever tighten the kube-apiserver rules in the future, we will have DNS rules already separated out and won't accidentally break DNS resolution.

But you're right that the DNS rules currently have no enforcement effect.

{
Ports: []networkingv1.NetworkPolicyPort{
{
Protocol: ptr.To(corev1.ProtocolTCP),
Port: ptr.To(intstr.FromInt32(6443)),
Port: ptr.To(intstr.FromInt32(53)),
},
{
Protocol: ptr.To(corev1.ProtocolUDP),
Port: ptr.To(intstr.FromInt32(53)),
},
{
Protocol: ptr.To(corev1.ProtocolTCP),
Port: ptr.To(intstr.FromInt32(5353)),
},
{
Protocol: ptr.To(corev1.ProtocolUDP),
Port: ptr.To(intstr.FromInt32(5353)),
},
},
},
Expand Down Expand Up @@ -90,11 +105,26 @@ func DesiredUnpackBundlesNetworkPolicy(catalogSource client.Object) *networkingv
},
PolicyTypes: []networkingv1.PolicyType{networkingv1.PolicyTypeIngress, networkingv1.PolicyTypeEgress},
Egress: []networkingv1.NetworkPolicyEgressRule{
// Wildcard allow all IPs/Ports for kube-apiserver
{},
// Wildcard allow all IPs with DNS ports
{
Ports: []networkingv1.NetworkPolicyPort{
{
Protocol: ptr.To(corev1.ProtocolTCP),
Port: ptr.To(intstr.FromInt32(6443)),
Port: ptr.To(intstr.FromInt32(53)),
},
{
Protocol: ptr.To(corev1.ProtocolUDP),
Port: ptr.To(intstr.FromInt32(53)),
},
{
Protocol: ptr.To(corev1.ProtocolTCP),
Port: ptr.To(intstr.FromInt32(5353)),
},
{
Protocol: ptr.To(corev1.ProtocolUDP),
Port: ptr.To(intstr.FromInt32(5353)),
},
},
},
Expand Down