mirror of
https://github.com/gitpod-io/gitpod.git
synced 2025-12-08 17:36:30 +00:00
* [public-api] add dummy service for testing * [public-api] proxy dummy to server * [public-api] hello service server impl * [server] fix API contribution bindings * [dashboard] emulate unary call * only if actually called * [dummy] auth * fix tests * [server] add interceptor to public api * add server side observability * fix port name * change to unimplemented for unknown methods * [public-api] client metrics * fix metrics imports * align server metrics * actually fix metrics * add feature flags * fix server side streams * [dashboard] hook error reporting * rebase and fix imports * feature flagged metrics from dashboard * revert GRPC_TYPE * address feedback
159 lines
4.1 KiB
Go
159 lines
4.1 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 server
|
|
|
|
import (
|
|
"github.com/gitpod-io/gitpod/common-go/baseserver"
|
|
"github.com/gitpod-io/gitpod/installer/pkg/common"
|
|
"github.com/gitpod-io/gitpod/installer/pkg/components/gitpod"
|
|
|
|
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, component string) ([]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"},
|
|
Ingress: []networkingv1.NetworkPolicyIngressRule{
|
|
{
|
|
Ports: []networkingv1.NetworkPolicyPort{
|
|
{
|
|
Protocol: common.TCPProtocol,
|
|
Port: &intstr.IntOrString{IntVal: ContainerPort},
|
|
},
|
|
{
|
|
Protocol: common.TCPProtocol,
|
|
Port: &intstr.IntOrString{IntVal: PublicAPIPort},
|
|
},
|
|
},
|
|
From: []networkingv1.NetworkPolicyPeer{
|
|
{
|
|
PodSelector: &metav1.LabelSelector{
|
|
MatchLabels: map[string]string{
|
|
"component": common.ProxyComponent,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
Ports: []networkingv1.NetworkPolicyPort{
|
|
{
|
|
Protocol: common.TCPProtocol,
|
|
Port: &intstr.IntOrString{IntVal: ContainerPort},
|
|
},
|
|
},
|
|
From: []networkingv1.NetworkPolicyPeer{
|
|
{
|
|
PodSelector: &metav1.LabelSelector{
|
|
MatchLabels: map[string]string{
|
|
"component": common.PublicApiComponent,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
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.ProxyComponent,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
Ports: []networkingv1.NetworkPolicyPort{
|
|
{
|
|
Protocol: common.TCPProtocol,
|
|
Port: &intstr.IntOrString{IntVal: InstallationAdminPort},
|
|
},
|
|
},
|
|
From: []networkingv1.NetworkPolicyPeer{
|
|
{
|
|
PodSelector: &metav1.LabelSelector{
|
|
MatchLabels: map[string]string{
|
|
"component": gitpod.Component,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
Ports: []networkingv1.NetworkPolicyPort{
|
|
{
|
|
Protocol: common.TCPProtocol,
|
|
Port: &intstr.IntOrString{IntVal: IAMSessionPort},
|
|
},
|
|
},
|
|
From: []networkingv1.NetworkPolicyPeer{
|
|
{
|
|
PodSelector: &metav1.LabelSelector{
|
|
MatchLabels: map[string]string{
|
|
"app": "gitpod",
|
|
"component": common.PublicApiComponent,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
Ports: []networkingv1.NetworkPolicyPort{
|
|
{
|
|
Protocol: common.TCPProtocol,
|
|
Port: &intstr.IntOrString{IntVal: GRPCAPIPort},
|
|
},
|
|
},
|
|
From: []networkingv1.NetworkPolicyPeer{
|
|
{
|
|
PodSelector: &metav1.LabelSelector{
|
|
MatchLabels: map[string]string{
|
|
"app": "gitpod",
|
|
"component": common.PublicApiComponent,
|
|
},
|
|
},
|
|
},
|
|
{
|
|
PodSelector: &metav1.LabelSelector{
|
|
MatchLabels: map[string]string{
|
|
"app": "gitpod",
|
|
"component": common.UsageComponent,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
}, nil
|
|
}
|