|
|
|
@ -8,7 +8,6 @@ import ( |
|
|
|
|
"github.com/stretchr/testify/require" |
|
|
|
|
|
|
|
|
|
lokiv1beta1 "github.com/grafana/loki/operator/api/v1beta1" |
|
|
|
|
"github.com/grafana/loki/operator/internal/manifests/internal/gateway" |
|
|
|
|
"github.com/grafana/loki/operator/internal/manifests/openshift" |
|
|
|
|
|
|
|
|
|
appsv1 "k8s.io/api/apps/v1" |
|
|
|
@ -132,19 +131,19 @@ func TestApplyGatewayDefaultsOptions(t *testing.T) { |
|
|
|
|
TenantName: "application", |
|
|
|
|
TenantID: "", |
|
|
|
|
ServiceAccount: "lokistack-ocp-gateway", |
|
|
|
|
RedirectURL: "http://lokistack-ocp-stack-ns.apps.example.com/openshift/application/callback", |
|
|
|
|
RedirectURL: "https://lokistack-ocp-stack-ns.apps.example.com/openshift/application/callback", |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
TenantName: "infrastructure", |
|
|
|
|
TenantID: "", |
|
|
|
|
ServiceAccount: "lokistack-ocp-gateway", |
|
|
|
|
RedirectURL: "http://lokistack-ocp-stack-ns.apps.example.com/openshift/infrastructure/callback", |
|
|
|
|
RedirectURL: "https://lokistack-ocp-stack-ns.apps.example.com/openshift/infrastructure/callback", |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
TenantName: "audit", |
|
|
|
|
TenantID: "", |
|
|
|
|
ServiceAccount: "lokistack-ocp-gateway", |
|
|
|
|
RedirectURL: "http://lokistack-ocp-stack-ns.apps.example.com/openshift/audit/callback", |
|
|
|
|
RedirectURL: "https://lokistack-ocp-stack-ns.apps.example.com/openshift/audit/callback", |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
Authorization: openshift.AuthorizationSpec{ |
|
|
|
@ -258,8 +257,8 @@ func TestConfigureDeploymentForMode(t *testing.T) { |
|
|
|
|
"--logs.tail.endpoint=http://example.com", |
|
|
|
|
"--logs.write.endpoint=http://example.com", |
|
|
|
|
fmt.Sprintf("--web.healthchecks.url=https://localhost:%d", gatewayHTTPPort), |
|
|
|
|
"--tls.server.cert-file=/var/run/tls/tls.crt", |
|
|
|
|
"--tls.server.key-file=/var/run/tls/tls.key", |
|
|
|
|
"--tls.server.cert-file=/var/run/tls/http/tls.crt", |
|
|
|
|
"--tls.server.key-file=/var/run/tls/http/tls.key", |
|
|
|
|
"--tls.healthchecks.server-ca-file=/var/run/ca/service-ca.crt", |
|
|
|
|
fmt.Sprintf("--tls.healthchecks.server-name=%s", "test-gateway-http.test-ns.svc.cluster.local"), |
|
|
|
|
}, |
|
|
|
@ -267,7 +266,7 @@ func TestConfigureDeploymentForMode(t *testing.T) { |
|
|
|
|
{ |
|
|
|
|
Name: tlsSecretVolume, |
|
|
|
|
ReadOnly: true, |
|
|
|
|
MountPath: gateway.LokiGatewayTLSDir, |
|
|
|
|
MountPath: httpTLSDir, |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
ReadinessProbe: &corev1.Probe{ |
|
|
|
@ -380,7 +379,7 @@ func TestConfigureDeploymentForMode(t *testing.T) { |
|
|
|
|
{ |
|
|
|
|
Name: tlsSecretVolume, |
|
|
|
|
ReadOnly: true, |
|
|
|
|
MountPath: gateway.LokiGatewayTLSDir, |
|
|
|
|
MountPath: httpTLSDir, |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
ReadinessProbe: &corev1.Probe{ |
|
|
|
@ -428,8 +427,8 @@ func TestConfigureDeploymentForMode(t *testing.T) { |
|
|
|
|
"--logs.tail.endpoint=http://example.com", |
|
|
|
|
"--logs.write.endpoint=http://example.com", |
|
|
|
|
fmt.Sprintf("--web.healthchecks.url=https://localhost:%d", gatewayHTTPPort), |
|
|
|
|
"--tls.server.cert-file=/var/run/tls/tls.crt", |
|
|
|
|
"--tls.server.key-file=/var/run/tls/tls.key", |
|
|
|
|
"--tls.server.cert-file=/var/run/tls/http/tls.crt", |
|
|
|
|
"--tls.server.key-file=/var/run/tls/http/tls.key", |
|
|
|
|
"--tls.healthchecks.server-ca-file=/var/run/ca/service-ca.crt", |
|
|
|
|
fmt.Sprintf("--tls.healthchecks.server-name=%s", "test-gateway-http.test-ns.svc.cluster.local"), |
|
|
|
|
}, |
|
|
|
@ -437,7 +436,7 @@ func TestConfigureDeploymentForMode(t *testing.T) { |
|
|
|
|
{ |
|
|
|
|
Name: tlsSecretVolume, |
|
|
|
|
ReadOnly: true, |
|
|
|
|
MountPath: gateway.LokiGatewayTLSDir, |
|
|
|
|
MountPath: httpTLSDir, |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
ReadinessProbe: &corev1.Probe{ |
|
|
|
@ -465,8 +464,8 @@ func TestConfigureDeploymentForMode(t *testing.T) { |
|
|
|
|
"--web.listen=:8082", |
|
|
|
|
"--web.internal.listen=:8083", |
|
|
|
|
"--web.healthchecks.url=http://localhost:8082", |
|
|
|
|
"--tls.internal.server.cert-file=/var/run/tls/tls.crt", |
|
|
|
|
"--tls.internal.server.key-file=/var/run/tls/tls.key", |
|
|
|
|
"--tls.internal.server.cert-file=/var/run/tls/http/tls.crt", |
|
|
|
|
"--tls.internal.server.key-file=/var/run/tls/http/tls.key", |
|
|
|
|
`--openshift.mappings=application=loki.grafana.com`, |
|
|
|
|
`--openshift.mappings=infrastructure=loki.grafana.com`, |
|
|
|
|
`--openshift.mappings=audit=loki.grafana.com`, |
|
|
|
@ -511,7 +510,7 @@ func TestConfigureDeploymentForMode(t *testing.T) { |
|
|
|
|
{ |
|
|
|
|
Name: tlsSecretVolume, |
|
|
|
|
ReadOnly: true, |
|
|
|
|
MountPath: gateway.LokiGatewayTLSDir, |
|
|
|
|
MountPath: httpTLSDir, |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
@ -562,7 +561,7 @@ func TestConfigureDeploymentForMode(t *testing.T) { |
|
|
|
|
{ |
|
|
|
|
Name: "tls-secret", |
|
|
|
|
ReadOnly: true, |
|
|
|
|
MountPath: "/var/run/tls", |
|
|
|
|
MountPath: "/var/run/tls/http", |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
ReadinessProbe: &corev1.Probe{ |
|
|
|
@ -609,8 +608,8 @@ func TestConfigureDeploymentForMode(t *testing.T) { |
|
|
|
|
"--logs.write.endpoint=https://example.com", |
|
|
|
|
fmt.Sprintf("--web.healthchecks.url=https://localhost:%d", gatewayHTTPPort), |
|
|
|
|
"--logs.tls.ca-file=/var/run/ca/service-ca.crt", |
|
|
|
|
"--tls.server.cert-file=/var/run/tls/tls.crt", |
|
|
|
|
"--tls.server.key-file=/var/run/tls/tls.key", |
|
|
|
|
"--tls.server.cert-file=/var/run/tls/http/tls.crt", |
|
|
|
|
"--tls.server.key-file=/var/run/tls/http/tls.key", |
|
|
|
|
"--tls.healthchecks.server-ca-file=/var/run/ca/service-ca.crt", |
|
|
|
|
fmt.Sprintf("--tls.healthchecks.server-name=%s", "test-gateway-http.test-ns.svc.cluster.local"), |
|
|
|
|
}, |
|
|
|
@ -618,10 +617,10 @@ func TestConfigureDeploymentForMode(t *testing.T) { |
|
|
|
|
{ |
|
|
|
|
Name: "tls-secret", |
|
|
|
|
ReadOnly: true, |
|
|
|
|
MountPath: "/var/run/tls", |
|
|
|
|
MountPath: "/var/run/tls/http", |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
Name: "gateway-ca-bundle", |
|
|
|
|
Name: "test-ca-bundle", |
|
|
|
|
ReadOnly: true, |
|
|
|
|
MountPath: "/var/run/ca", |
|
|
|
|
}, |
|
|
|
@ -651,8 +650,8 @@ func TestConfigureDeploymentForMode(t *testing.T) { |
|
|
|
|
"--web.listen=:8082", |
|
|
|
|
"--web.internal.listen=:8083", |
|
|
|
|
"--web.healthchecks.url=http://localhost:8082", |
|
|
|
|
"--tls.internal.server.cert-file=/var/run/tls/tls.crt", |
|
|
|
|
"--tls.internal.server.key-file=/var/run/tls/tls.key", |
|
|
|
|
"--tls.internal.server.cert-file=/var/run/tls/http/tls.crt", |
|
|
|
|
"--tls.internal.server.key-file=/var/run/tls/http/tls.key", |
|
|
|
|
`--openshift.mappings=application=loki.grafana.com`, |
|
|
|
|
`--openshift.mappings=infrastructure=loki.grafana.com`, |
|
|
|
|
`--openshift.mappings=audit=loki.grafana.com`, |
|
|
|
@ -697,7 +696,7 @@ func TestConfigureDeploymentForMode(t *testing.T) { |
|
|
|
|
{ |
|
|
|
|
Name: tlsSecretVolume, |
|
|
|
|
ReadOnly: true, |
|
|
|
|
MountPath: gateway.LokiGatewayTLSDir, |
|
|
|
|
MountPath: httpTLSDir, |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
@ -707,12 +706,12 @@ func TestConfigureDeploymentForMode(t *testing.T) { |
|
|
|
|
Name: "tls-secret-volume", |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
Name: "gateway-ca-bundle", |
|
|
|
|
Name: "test-ca-bundle", |
|
|
|
|
VolumeSource: corev1.VolumeSource{ |
|
|
|
|
ConfigMap: &corev1.ConfigMapVolumeSource{ |
|
|
|
|
DefaultMode: &defaultConfigMapMode, |
|
|
|
|
LocalObjectReference: corev1.LocalObjectReference{ |
|
|
|
|
Name: "gateway-ca-bundle", |
|
|
|
|
Name: "test-ca-bundle", |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
@ -728,7 +727,7 @@ func TestConfigureDeploymentForMode(t *testing.T) { |
|
|
|
|
tc := tc |
|
|
|
|
t.Run(tc.desc, func(t *testing.T) { |
|
|
|
|
t.Parallel() |
|
|
|
|
err := configureDeploymentForMode(tc.dpl, tc.mode, tc.flags, "test", "test-ns") |
|
|
|
|
err := configureDeploymentForMode(tc.dpl, tc.mode, tc.flags, tc.stackName, tc.stackNs) |
|
|
|
|
require.NoError(t, err) |
|
|
|
|
require.Equal(t, tc.want, tc.dpl) |
|
|
|
|
}) |
|
|
|
|