Huiwen a5021da396
[installer] make sure dashboard is deployed after server and papi-server (#19042)
* [installer] make sure dashboard is deployed after server and papi-server

* fix build

* Add unit tests

* address feedback

* wait feature flag until get actual value of timed out

* default config cat client nil

* log avg fetch time

* 1

* mock feature flag hang

* Add metric

* fixup
2023-11-14 15:20:52 +02:00

112 lines
3.6 KiB
Go

// 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 proxy
import (
"fmt"
"github.com/gitpod-io/gitpod/common-go/baseserver"
"github.com/gitpod-io/gitpod/installer/pkg/common"
networkingv1 "k8s.io/api/networking/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/intstr"
)
func networkpolicy(ctx *common.RenderContext) ([]runtime.Object, error) {
labels := common.DefaultLabels(Component)
return []runtime.Object{&networkingv1.NetworkPolicy{
TypeMeta: common.TypeMetaNetworkPolicy,
ObjectMeta: metav1.ObjectMeta{
Name: fmt.Sprintf("%s-deny-all-allow-explicit", Component),
Namespace: ctx.Namespace,
Labels: labels,
},
Spec: networkingv1.NetworkPolicySpec{
PodSelector: metav1.LabelSelector{MatchLabels: labels},
PolicyTypes: []networkingv1.PolicyType{"Ingress"},
Ingress: []networkingv1.NetworkPolicyIngressRule{{
Ports: []networkingv1.NetworkPolicyPort{{
Protocol: common.TCPProtocol,
Port: &intstr.IntOrString{IntVal: ContainerHTTPPort},
}, {
Protocol: common.TCPProtocol,
Port: &intstr.IntOrString{IntVal: ContainerHTTPSPort},
}, {
Protocol: common.TCPProtocol,
Port: &intstr.IntOrString{IntVal: ContainerSSHPort},
}},
}, {
Ports: []networkingv1.NetworkPolicyPort{{
Protocol: common.TCPProtocol,
Port: &intstr.IntOrString{IntVal: baseserver.BuiltinMetricsPort},
}},
From: []networkingv1.NetworkPolicyPeer{{
NamespaceSelector: &metav1.LabelSelector{MatchLabels: map[string]string{
"chart": common.MonitoringChart,
}},
PodSelector: &metav1.LabelSelector{MatchLabels: map[string]string{
"component": common.ServerComponent,
}},
}},
}, {
Ports: []networkingv1.NetworkPolicyPort{{
Protocol: common.TCPProtocol,
Port: &intstr.IntOrString{IntVal: ContainerAnalyticsPort},
}},
From: []networkingv1.NetworkPolicyPeer{{
PodSelector: &metav1.LabelSelector{MatchLabels: map[string]string{
"component": common.ServerComponent,
}},
}, {
PodSelector: &metav1.LabelSelector{MatchLabels: map[string]string{
"component": common.WSManagerBridgeComponent,
}},
}, {
PodSelector: &metav1.LabelSelector{MatchLabels: map[string]string{
"component": common.WSProxyComponent,
}},
}},
}, {
Ports: []networkingv1.NetworkPolicyPort{{
Protocol: common.TCPProtocol,
Port: &intstr.IntOrString{IntVal: ContainerConfigcatPort},
}},
From: []networkingv1.NetworkPolicyPeer{{
PodSelector: &metav1.LabelSelector{MatchLabels: map[string]string{
"component": common.ServerComponent,
}},
}, {
PodSelector: &metav1.LabelSelector{MatchLabels: map[string]string{
"component": common.WSManagerBridgeComponent,
}},
}, {
PodSelector: &metav1.LabelSelector{MatchLabels: map[string]string{
"component": common.IDEServiceComponent,
}},
}, {
PodSelector: &metav1.LabelSelector{MatchLabels: map[string]string{
"component": common.PublicApiComponent,
}},
}, {
PodSelector: &metav1.LabelSelector{MatchLabels: map[string]string{
"component": common.UsageComponent,
}},
}, {
PodSelector: &metav1.LabelSelector{MatchLabels: map[string]string{
"component": common.OpenVSXProxyComponent,
}},
}, {
PodSelector: &metav1.LabelSelector{MatchLabels: map[string]string{
"component": common.DashboardComponent,
}},
}},
}},
},
}}, nil
}