-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[usage] Implement initial gRPC API #11224
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
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
05816a8
Placeholder implementation of usage gRPC server
e3a1a58
Add gRPC config to usage configmap
a05bbfe
Add service for usage component
b681cc1
Remove unnecessary method
ca861c2
Add networkpolicy for the usage component
7b25556
Add `omitempty` struct tag
22f51dd
Remove json key from test expectation
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,10 @@ | ||
{ | ||
"controllerSchedule": "1h" | ||
"controllerSchedule": "1h", | ||
"server": { | ||
"services": { | ||
"grpc": { | ||
"address": ":9001" | ||
} | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright (c) 2022 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 apiv1 | ||
|
||
import ( | ||
v1 "github.com/gitpod-io/gitpod/usage-api/v1" | ||
) | ||
|
||
type UsageService struct { | ||
v1.UnimplementedUsageServiceServer | ||
} | ||
|
||
func NewUsageService() *UsageService { | ||
return &UsageService{} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Copyright (c) 2022 Gitpod GmbH. All rights reserved. | ||
// Licensed under the MIT License. See License-MIT.txt in the project root for license information. | ||
|
||
package usage | ||
|
||
import ( | ||
"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: 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: gRPCContainerPort}, | ||
}, | ||
}, | ||
From: []networkingv1.NetworkPolicyPeer{ | ||
{ | ||
PodSelector: &metav1.LabelSelector{ | ||
MatchLabels: map[string]string{ | ||
"component": common.ServerComponent, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, nil | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright (c) 2022 Gitpod GmbH. All rights reserved. | ||
// Licensed under the MIT License. See License-MIT.txt in the project root for license information. | ||
|
||
package usage | ||
|
||
import ( | ||
"github.com/gitpod-io/gitpod/installer/pkg/common" | ||
"k8s.io/apimachinery/pkg/runtime" | ||
) | ||
|
||
func service(ctx *common.RenderContext) ([]runtime.Object, error) { | ||
return common.GenerateService(Component, []common.ServicePort{ | ||
{ | ||
Name: gRPCPortName, | ||
ContainerPort: gRPCContainerPort, | ||
ServicePort: gRPCServicePort, | ||
}, | ||
})(ctx) | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.