Skip to content

[installer] Registry facade should not use a port from node ports range #8580

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 4, 2022
Merged
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
2 changes: 1 addition & 1 deletion install/installer/pkg/common/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const (
RegistryAuthSecret = "builtin-registry-auth"
RegistryTLSCertSecret = "builtin-registry-certs"
RegistryFacadeComponent = "registry-facade"
RegistryFacadeServicePort = 30000
RegistryFacadeServicePort = 20000
RegistryFacadeTLSCertSecret = "builtin-registry-facade-cert"
ServerComponent = "server"
ServerInstallationAdminPort = 9000
Expand Down
70 changes: 70 additions & 0 deletions install/installer/pkg/common/networkpolicies.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// Copyright (c) 2021 Gitpod GmbH. All rights reserved.
// Licensed under the GNU Affero General Public License (AGPL).
// See License-AGPL.txt in the project root for license information.

package common

import (
corev1 "k8s.io/api/core/v1"
v1 "k8s.io/api/networking/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
)

func AllowKubeDnsEgressRule() v1.NetworkPolicyEgressRule {
var tcp = corev1.ProtocolTCP
var udp = corev1.ProtocolUDP

dnsEgressRule := v1.NetworkPolicyEgressRule{
Ports: []v1.NetworkPolicyPort{
{
Protocol: &tcp,
Port: &intstr.IntOrString{
IntVal: 53,
},
},
{
Protocol: &udp,
Port: &intstr.IntOrString{
IntVal: 53,
},
},
},
To: []v1.NetworkPolicyPeer{{
PodSelector: &metav1.LabelSelector{
MatchLabels: map[string]string{
"k8s-app": "kube-dns",
},
},
NamespaceSelector: &metav1.LabelSelector{},
}},
}

return dnsEgressRule
}

func AllowWSManagerEgressRule() v1.NetworkPolicyEgressRule {
var tcp = corev1.ProtocolTCP

dnsEgressRule := v1.NetworkPolicyEgressRule{
Ports: []v1.NetworkPolicyPort{
{
Protocol: &tcp,
Port: &intstr.IntOrString{
IntVal: 8080,
},
},
},
To: []v1.NetworkPolicyPeer{{
PodSelector: &metav1.LabelSelector{
MatchLabels: map[string]string{
"app": AppName,
"component": WSManagerComponent,
},
},
NamespaceSelector: &metav1.LabelSelector{},
}},
}

return dnsEgressRule
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package cluster

import (
"fmt"

"github.com/gitpod-io/gitpod/installer/pkg/common"
corev1 "k8s.io/api/core/v1"
"k8s.io/api/policy/v1beta1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,34 +16,25 @@ import (
func networkpolicy(ctx *common.RenderContext) ([]runtime.Object, error) {
labels := common.DefaultLabels(Component)

return []runtime.Object{&networkingv1.NetworkPolicy{
TypeMeta: common.TypeMetaNetworkPolicy,
ObjectMeta: metav1.ObjectMeta{
Name: Component,
Namespace: ctx.Namespace,
Labels: labels,
},
Spec: networkingv1.NetworkPolicySpec{
PodSelector: metav1.LabelSelector{MatchLabels: labels},
PolicyTypes: []networkingv1.PolicyType{"Ingress", "Egress"},
Ingress: []networkingv1.NetworkPolicyIngressRule{{
From: []networkingv1.NetworkPolicyPeer{{
PodSelector: &metav1.LabelSelector{MatchLabels: map[string]string{
"component": server.Component,
return []runtime.Object{
&networkingv1.NetworkPolicy{
TypeMeta: common.TypeMetaNetworkPolicy,
ObjectMeta: metav1.ObjectMeta{
Name: Component,
Namespace: ctx.Namespace,
Labels: labels,
},
Spec: networkingv1.NetworkPolicySpec{
PodSelector: metav1.LabelSelector{MatchLabels: labels},
PolicyTypes: []networkingv1.PolicyType{"Ingress"},
Ingress: []networkingv1.NetworkPolicyIngressRule{{
From: []networkingv1.NetworkPolicyPeer{{
PodSelector: &metav1.LabelSelector{MatchLabels: map[string]string{
"component": server.Component,
}},
}},
}},
}},
Egress: []networkingv1.NetworkPolicyEgressRule{{
To: []networkingv1.NetworkPolicyPeer{{
IPBlock: &networkingv1.IPBlock{
CIDR: "0.0.0.0/0",
Except: []string{
// Google Compute engine special, reserved VM metadata IP
"169.254.169.254/32",
},
},
}},
}},
},
},
}}, nil
}, nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ func podsecuritypolicy(ctx *common.RenderContext) ([]runtime.Object, error) {
HostIPC: false,
HostPID: false,
HostPorts: []v1beta1.HostPortRange{{
Min: 30000,
Max: 33000,
Min: 20000,
Max: 20000,
}},
RunAsUser: v1beta1.RunAsUserStrategyOptions{
Rule: v1beta1.RunAsUserStrategyRunAsAny,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ func networkpolicy(ctx *common.RenderContext) ([]runtime.Object, error) {
},
},
},
common.AllowKubeDnsEgressRule(),
},
},
}}, nil
Expand Down