Skip to content

Commit 3085c3f

Browse files
committed
fix: remove required config validation from k8s proxy cert and key
- With the config rewrite, it is possible to pass cert and key file paths for the Kubernetes Proxy component specifically (only to the Kubernetes proxy), just like all the other http server components. These fields are marked as required and we validate them. - They can only be passed through the config file, there is no command line arg defined for those. - When they are not defined, they will fall back to the `--cert` and `--key` passed to Omni itself - to the whole Omni API cert and key. - This is wrong, as Omni might be run without `--cert` and `--key` flags, e.g., if it is running behind a reverse proxt that handling TLS termination. Fix this by removing the required validation annotation, and add a test for it. Signed-off-by: Utku Ozdemir <[email protected]>
1 parent bf6c38a commit 3085c3f

File tree

3 files changed

+42
-2
lines changed

3 files changed

+42
-2
lines changed

internal/pkg/config/config_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ var backups []byte
3030
//go:embed testdata/unknown-keys.yaml
3131
var unknownKeys []byte
3232

33+
//go:embed testdata/config-no-tls-certs.yaml
34+
var configNoTLSCerts []byte
35+
3336
func TestValidateConfig(t *testing.T) {
3437
for _, tt := range []struct {
3538
name string
@@ -66,6 +69,12 @@ func TestValidateConfig(t *testing.T) {
6669
config: unknownKeys,
6770
loadErr: "unknown keys found",
6871
},
72+
{
73+
// Having no TLS cert/key neither for the API nor for Kubernetes Proxy Server is NOT an error,
74+
// as Omni might be running behind a reverse proxy that handles the TLS termination.
75+
name: "no tls certs",
76+
config: configNoTLSCerts,
77+
},
6978
} {
7079
t.Run(tt.name, func(t *testing.T) {
7180
cfg, err := config.FromBytes(tt.config)

internal/pkg/config/services.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,9 @@ type KubernetesProxyService struct {
106106
// This value is used in the machine join config, kernel params and schematics generation.
107107
AdvertisedURL string `yaml:"advertisedURL"`
108108
// CertFile is the TLS cert.
109-
CertFile string `yaml:"certFile" validate:"required"`
109+
CertFile string `yaml:"certFile"`
110110
// KeyFile is the TLS key.
111-
KeyFile string `yaml:"keyFile" validate:"required"`
111+
KeyFile string `yaml:"keyFile"`
112112
}
113113

114114
// GetBindEndpoint implements HTTPService.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
account:
2+
id: some-id
3+
name: some-name
4+
5+
services:
6+
api:
7+
endpoint: localhost:8080
8+
siderolink:
9+
joinTokensMode: strict
10+
kubernetesProxy:
11+
endpoint: 0.0.0.0:8095
12+
13+
auth:
14+
keyPruner:
15+
interval: 10m
16+
17+
logs:
18+
audit:
19+
path: _out/audit
20+
21+
storage:
22+
secondary:
23+
path: _out/secondary-storage/bolt.db
24+
default:
25+
kind: etcd
26+
etcd:
27+
privateKeySource: some-source
28+
registries:
29+
talos: factory.talos.dev
30+
kubernetes: registry.k8s.io
31+
imageFactoryBaseURL: https://factory.talos.dev

0 commit comments

Comments
 (0)