diff --git a/assets/admission-webhook/deployment.yaml b/assets/admission-webhook/deployment.yaml index 63058e471a..0027f3e3c5 100644 --- a/assets/admission-webhook/deployment.yaml +++ b/assets/admission-webhook/deployment.yaml @@ -47,6 +47,7 @@ spec: - --web.key-file=/etc/tls/private/tls.key - --web.tls-cipher-suites=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305,TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305 - --web.tls-min-version=VersionTLS12 + - --name-validation-scheme=utf8 image: "" livenessProbe: httpGet: diff --git a/jsonnet/components/admission-webhook.libsonnet b/jsonnet/components/admission-webhook.libsonnet index 75f1cde135..8235918f82 100644 --- a/jsonnet/components/admission-webhook.libsonnet +++ b/jsonnet/components/admission-webhook.libsonnet @@ -42,6 +42,7 @@ function(params) args+: [ '--web.tls-cipher-suites=' + params.tlsCipherSuites, '--web.tls-min-version=VersionTLS12', + '--name-validation-scheme=utf8', ], livenessProbe: { httpGet: { diff --git a/test/e2e/validatingwebhook_test.go b/test/e2e/validatingwebhook_test.go index 36106fbb2e..c3b378a7d9 100644 --- a/test/e2e/validatingwebhook_test.go +++ b/test/e2e/validatingwebhook_test.go @@ -101,6 +101,30 @@ spec: webhookConfigs: - url: 'https://example.com' `, framework.E2eTestLabel) + + utf8PromRuleYaml = fmt.Sprintf(`--- +apiVersion: monitoring.coreos.com/v1 +kind: PrometheusRule +metadata: + name: cluster.monitoring-utf8 + labels: + %s +spec: + groups: + - name: cluster-nodes-äöü-ß + rules: + - record: cluster_node_cpu_usage_ñáéíóú + expr: 1 + - alert: ClusterNodeDown_äöü_ß + expr: up == 0 + labels: + severity: warning + cluster: "production-cluster-cé" + node: "worker-node-ñáéíóú" + annotations: + summary: "Cluster node down - UTF-8 characters" + description: "Node in cluster-cé is down with UTF-8 characters" +`, framework.E2eTestLabel) ) func TestPrometheusRuleValidatingWebhook(t *testing.T) { @@ -133,6 +157,24 @@ func TestPrometheusRuleValidatingWebhook(t *testing.T) { } +func TestPrometheusRuleValidatingWebhookUTF8Names(t *testing.T) { + ctx := context.Background() + + // Test PrometheusRule with UTF-8 names. + utf8PromRule := monitoringv1.PrometheusRule{} + err := yaml.Unmarshal([]byte(utf8PromRuleYaml), &utf8PromRule) + if err != nil { + t.Fatal("unable to unmarshal UTF-8 prometheus rule", err) + } + + _, err = f.MonitoringClient.PrometheusRules(f.Ns).Create(ctx, &utf8PromRule, metav1.CreateOptions{}) + if err != nil { + t.Fatalf("UTF-8 prometheus rule was rejected by validating webhook: %v", err) + } + + f.MonitoringClient.PrometheusRules(f.Ns).Delete(ctx, utf8PromRule.Name, metav1.DeleteOptions{}) +} + func TestAlertManagerConfigValidatingWebhook(t *testing.T) { ctx := context.Background()