Skip to content

Commit 1dbf15e

Browse files
committed
feat: run embedded discovery service in Omni
Run a discovery service instance inside Omni, which can be disabled but is enabled by default. When enabled, it will listen only on the SideroLink interface on port 8093. When enabled, all new clusters will by default have the feature enabled, which means they will use the embedded discovery service instead of the public one. Existing clusters will have the feature disabled until it is enabled for them explicitly. Closes #20. Signed-off-by: Utku Ozdemir <[email protected]>
1 parent 1b64824 commit 1dbf15e

File tree

26 files changed

+1152
-695
lines changed

26 files changed

+1152
-695
lines changed

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

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

client/api/omni/specs/omni.proto

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,10 @@ message ClusterSpec {
215215
bool enable_workload_proxy = 1;
216216
// DiskEncryption enables disk encryption on all nodes.
217217
bool disk_encryption = 2;
218+
// UseEmbeddedDiscoveryService enables the use of the Omni's embedded discovery service instead of the public one.
219+
//
220+
// If the discovery service feature is disabled in the machine config, this field is ignored.
221+
bool use_embedded_discovery_service = 3;
218222
}
219223

220224
// InstallImage the installer image to use.

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

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

client/pkg/template/internal/models/cluster.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626
const KindCluster = "Cluster"
2727

2828
// Cluster is a top-level template object.
29-
type Cluster struct { //nolint:govet
29+
type Cluster struct {
3030
Meta `yaml:",inline"`
3131
SystemExtensions `yaml:",inline"`
3232

@@ -50,11 +50,15 @@ type Cluster struct { //nolint:govet
5050
}
5151

5252
// Features defines cluster-wide features.
53-
type Features struct {
53+
type Features struct { //nolint:govet
5454
// DiskEncryption enables KMS encryption.
5555
DiskEncryption bool `yaml:"diskEncryption,omitempty"`
5656
// EnableWorkloadProxy enables workload proxy.
5757
EnableWorkloadProxy bool `yaml:"enableWorkloadProxy,omitempty"`
58+
// UseEmbeddedDiscoveryService enables the use of embedded discovery service.
59+
//
60+
// Defaults to true when not set.
61+
UseEmbeddedDiscoveryService *bool `yaml:"useEmbeddedDiscoveryService,omitempty"`
5862
// BackupConfiguration contains backup configuration settings.
5963
BackupConfiguration BackupConfiguration `yaml:"backupConfiguration,omitempty"`
6064
}
@@ -155,7 +159,8 @@ func (cluster *Cluster) Translate(ctx TranslateContext) ([]resource.Resource, er
155159
cluster.Descriptors.Apply(clusterResource)
156160

157161
clusterResource.TypedSpec().Value.Features = &specs.ClusterSpec_Features{
158-
EnableWorkloadProxy: cluster.Features.EnableWorkloadProxy,
162+
EnableWorkloadProxy: cluster.Features.EnableWorkloadProxy,
163+
UseEmbeddedDiscoveryService: cluster.Features.UseEmbeddedDiscoveryService == nil || *cluster.Features.UseEmbeddedDiscoveryService,
159164
}
160165

161166
clusterResource.TypedSpec().Value.KubernetesVersion = strings.TrimLeft(cluster.Kubernetes.Version, "v")

client/pkg/template/operations/export.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,12 @@ func transformClusterToModel(cluster *omni.Cluster, patches []*omni.ConfigPatch)
322322
return models.Cluster{}, err
323323
}
324324

325+
var useEmbeddedDiscoveryService *bool
326+
327+
if !spec.GetFeatures().GetUseEmbeddedDiscoveryService() {
328+
useEmbeddedDiscoveryService = pointer.To(false)
329+
}
330+
325331
return models.Cluster{
326332
Meta: models.Meta{
327333
Kind: models.KindCluster,
@@ -335,8 +341,9 @@ func transformClusterToModel(cluster *omni.Cluster, patches []*omni.ConfigPatch)
335341
Version: "v" + spec.GetTalosVersion(),
336342
},
337343
Features: models.Features{
338-
DiskEncryption: spec.GetFeatures().GetDiskEncryption(),
339-
EnableWorkloadProxy: spec.GetFeatures().GetEnableWorkloadProxy(),
344+
DiskEncryption: spec.GetFeatures().GetDiskEncryption(),
345+
EnableWorkloadProxy: spec.GetFeatures().GetEnableWorkloadProxy(),
346+
UseEmbeddedDiscoveryService: useEmbeddedDiscoveryService,
340347
BackupConfiguration: models.BackupConfiguration{
341348
Interval: backupIntervalDuration,
342349
},

client/pkg/template/operations/testdata/export/cluster-resources.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ spec:
2525
features:
2626
enableworkloadproxy: true
2727
diskencryption: true
28+
useembeddeddiscoveryservice: true
2829
backupconfiguration:
2930
interval:
3031
seconds: 7200

client/pkg/template/testdata/cluster-valid-bootstrapspec-resources.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ spec:
1616
features:
1717
enableworkloadproxy: false
1818
diskencryption: false
19+
useembeddeddiscoveryservice: true
1920
backupconfiguration: null
2021
---
2122
metadata:

client/pkg/template/testdata/cluster1-resources.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ spec:
1616
features:
1717
enableworkloadproxy: false
1818
diskencryption: true
19+
useembeddeddiscoveryservice: false
1920
backupconfiguration: null
2021
---
2122
metadata:

client/pkg/template/testdata/cluster1.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ talos:
66
version: v1.3.0
77
features:
88
diskEncryption: true
9+
useEmbeddedDiscoveryService: false
910
patches:
1011
- file: patches/my-cluster-patch.yaml
1112
- file: ../testdata/patches/my-registry-mirrors.yaml

client/pkg/template/testdata/cluster2-resources.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ spec:
1616
features:
1717
enableworkloadproxy: true
1818
diskencryption: false
19+
useembeddeddiscoveryservice: true
1920
backupconfiguration: null
2021
---
2122
metadata:

0 commit comments

Comments
 (0)