Skip to content

Commit 6338ab2

Browse files
committed
feat: add a way to switch gRPC tunnel mode for the connected machines
Fixes: #1816 This change also deprecates `omnictl machine-logs` command and introduces a new command group `omnictl machine ...`. Now the logs can be read by using `omnictl machine logs --id <id>`. For the tunnel mode management there is now command: ``` omnictl machine configure --id <id> grpc-tunnel-mode [enabled|disabled|auto] ``` Signed-off-by: Artem Chernyshev <[email protected]>
1 parent 5e8ef87 commit 6338ab2

File tree

19 files changed

+570
-17
lines changed

19 files changed

+570
-17
lines changed

client/api/omni/specs/siderolink.pb.go

Lines changed: 59 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/api/omni/specs/siderolink.proto

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,3 +166,8 @@ message JoinTokenUsageSpec {
166166
message DefaultJoinTokenSpec {
167167
string token_id = 1;
168168
}
169+
170+
// GRPCTunnelConfig is the user managed resource that allows configuring gRPC tunnel per machine.
171+
message GRPCTunnelConfigSpec {
172+
bool enabled = 1;
173+
}

client/api/omni/specs/siderolink_vtproto.pb.go

Lines changed: 163 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/pkg/omni/resources/common/common.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ var UserManagedResourceTypes = []resource.Type{
2222
authres.SAMLLabelRuleType,
2323
siderolink.JoinTokenType,
2424
siderolink.DefaultJoinTokenType,
25+
siderolink.GRPCTunnelConfigType,
2526
omni.ClusterType,
2627
omni.ConfigPatchType,
2728
omni.EtcdManualBackupType,
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// This Source Code Form is subject to the terms of the Mozilla Public
2+
// License, v. 2.0. If a copy of the MPL was not distributed with this
3+
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
4+
5+
package siderolink
6+
7+
import (
8+
"github.com/cosi-project/runtime/pkg/resource"
9+
"github.com/cosi-project/runtime/pkg/resource/meta"
10+
"github.com/cosi-project/runtime/pkg/resource/protobuf"
11+
"github.com/cosi-project/runtime/pkg/resource/typed"
12+
13+
"github.com/siderolabs/omni/client/api/omni/specs"
14+
"github.com/siderolabs/omni/client/pkg/omni/resources"
15+
)
16+
17+
// NewGRPCTunnelConfig creates new GRPCTunnelConfig state.
18+
func NewGRPCTunnelConfig(id string) *GRPCTunnelConfig {
19+
return typed.NewResource[GRPCTunnelConfigSpec, GRPCTunnelConfigExtension](
20+
resource.NewMetadata(resources.DefaultNamespace, GRPCTunnelConfigType, id, resource.VersionUndefined),
21+
protobuf.NewResourceSpec(&specs.GRPCTunnelConfigSpec{}),
22+
)
23+
}
24+
25+
// GRPCTunnelConfigType is the type of GRPCTunnelConfig resource.
26+
//
27+
// tsgen:GRPCTunnelConfigType
28+
const GRPCTunnelConfigType = resource.Type("GRPCTunnelConfigs.omni.sidero.dev")
29+
30+
// GRPCTunnelConfig resource is the per machine gRPC tunnel mode config.
31+
type GRPCTunnelConfig = typed.Resource[GRPCTunnelConfigSpec, GRPCTunnelConfigExtension]
32+
33+
// GRPCTunnelConfigSpec wraps specs.GRPCTunnelConfigSpec.
34+
type GRPCTunnelConfigSpec = protobuf.ResourceSpec[specs.GRPCTunnelConfigSpec, *specs.GRPCTunnelConfigSpec]
35+
36+
// GRPCTunnelConfigExtension providers auxiliary methods for GRPCTunnelConfig resource.
37+
type GRPCTunnelConfigExtension struct{}
38+
39+
// ResourceDefinition implements [typed.Extension] interface.
40+
func (GRPCTunnelConfigExtension) ResourceDefinition() meta.ResourceDefinitionSpec {
41+
return meta.ResourceDefinitionSpec{
42+
Type: GRPCTunnelConfigType,
43+
Aliases: []resource.Type{},
44+
DefaultNamespace: resources.DefaultNamespace,
45+
PrintColumns: nil,
46+
}
47+
}

client/pkg/omni/resources/siderolink/siderolink.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ func init() {
3434
registry.MustRegisterResource(DefaultJoinTokenType, &DefaultJoinToken{})
3535
registry.MustRegisterResource(NodeUniqueTokenType, &NodeUniqueToken{})
3636
registry.MustRegisterResource(NodeUniqueTokenStatusType, &NodeUniqueTokenStatus{})
37+
registry.MustRegisterResource(GRPCTunnelConfigType, &GRPCTunnelConfig{})
3738

3839
// NOTE: this resource is not used anymore, but still used in the migration code.
3940
registry.MustRegisterResource(DeprecatedLinkCounterType, &DeprecatedLinkCounter{})

0 commit comments

Comments
 (0)