From 64557d1568a95950f1f0bdb43942dcf411e35afc Mon Sep 17 00:00:00 2001 From: Periklis Tsirakidis Date: Tue, 26 Sep 2023 12:21:46 +0200 Subject: [PATCH 1/4] operator: Allow endpoint_suffix in azure object storage secret --- .../internal/handlers/internal/storage/secrets.go | 12 ++++++++---- .../handlers/internal/storage/secrets_test.go | 14 +++++++++++++- .../manifests/internal/config/loki-config.yaml | 1 + operator/internal/manifests/storage/options.go | 9 +++++---- 4 files changed, 27 insertions(+), 9 deletions(-) diff --git a/operator/internal/handlers/internal/storage/secrets.go b/operator/internal/handlers/internal/storage/secrets.go index b74589bebb5ae..78f3e64c259bb 100644 --- a/operator/internal/handlers/internal/storage/secrets.go +++ b/operator/internal/handlers/internal/storage/secrets.go @@ -56,11 +56,15 @@ func extractAzureConfigSecret(s *corev1.Secret) (*storage.AzureStorageConfig, er return nil, kverrors.New("missing secret field", "field", "account_key") } + // Extract and validate optional fields + endpointSuffix := s.Data["endpoint_suffix"] + return &storage.AzureStorageConfig{ - Env: string(env), - Container: string(container), - AccountName: string(name), - AccountKey: string(key), + Env: string(env), + Container: string(container), + AccountName: string(name), + AccountKey: string(key), + EndpointSuffix: string(endpointSuffix), }, nil } diff --git a/operator/internal/handlers/internal/storage/secrets_test.go b/operator/internal/handlers/internal/storage/secrets_test.go index e080c870b1aed..f06ef5ba2c376 100644 --- a/operator/internal/handlers/internal/storage/secrets_test.go +++ b/operator/internal/handlers/internal/storage/secrets_test.go @@ -52,7 +52,7 @@ func TestAzureExtract(t *testing.T) { wantErr: true, }, { - name: "all set", + name: "all mandatory set", secret: &corev1.Secret{ Data: map[string][]byte{ "environment": []byte("here"), @@ -62,6 +62,18 @@ func TestAzureExtract(t *testing.T) { }, }, }, + { + name: "all set including optional", + secret: &corev1.Secret{ + Data: map[string][]byte{ + "environment": []byte("here"), + "container": []byte("this,that"), + "account_name": []byte("id"), + "account_key": []byte("secret"), + "endpoint_suffix": []byte("suffix"), + }, + }, + }, } for _, tst := range table { tst := tst diff --git a/operator/internal/manifests/internal/config/loki-config.yaml b/operator/internal/manifests/internal/config/loki-config.yaml index 015e701fc25c1..7087bb66cc1ad 100644 --- a/operator/internal/manifests/internal/config/loki-config.yaml +++ b/operator/internal/manifests/internal/config/loki-config.yaml @@ -14,6 +14,7 @@ common: container_name: {{ .Container }} account_name: {{ .AccountName }} account_key: {{ .AccountKey }} + endpoint_suffix: {{ .EndpointSuffix }} {{- end }} {{- with .ObjectStorage.GCS }} gcs: diff --git a/operator/internal/manifests/storage/options.go b/operator/internal/manifests/storage/options.go index 76bb7a45b396e..3d4355b8dc1c1 100644 --- a/operator/internal/manifests/storage/options.go +++ b/operator/internal/manifests/storage/options.go @@ -22,10 +22,11 @@ type Options struct { // AzureStorageConfig for Azure storage config type AzureStorageConfig struct { - Env string - Container string - AccountName string - AccountKey string + Env string + Container string + AccountName string + AccountKey string + EndpointSuffix string } // GCSStorageConfig for GCS storage config From 15206c776d6feb9bcd7d6d6a72d1b156a78d1845 Mon Sep 17 00:00:00 2001 From: Periklis Tsirakidis Date: Tue, 26 Sep 2023 13:45:38 +0200 Subject: [PATCH 2/4] Add changelog entry --- operator/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/operator/CHANGELOG.md b/operator/CHANGELOG.md index 1d7e542af56cf..9766fe6410ac5 100644 --- a/operator/CHANGELOG.md +++ b/operator/CHANGELOG.md @@ -1,5 +1,6 @@ ## Main +- [10715](https://github.com/grafana/loki/pull/10715) **periklis**: Allow endpoint_suffix in azure object storage secret - [10600](https://github.com/grafana/loki/pull/10600) **periklis**: Update Loki operand to v2.9.1 - [10545](https://github.com/grafana/loki/pull/10545) **xperimental**: Update gateway arguments to enable namespace extraction - [10558](https://github.com/grafana/loki/pull/10558) **periklis**: Upgrade dashboards for for Loki v2.9.0 From 17c71a98766a166ea6efe5d4f7109e3a15f587fd Mon Sep 17 00:00:00 2001 From: Periklis Tsirakidis Date: Tue, 26 Sep 2023 13:46:53 +0200 Subject: [PATCH 3/4] Amend azure object storage operator docs --- operator/docs/lokistack/object_storage.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/operator/docs/lokistack/object_storage.md b/operator/docs/lokistack/object_storage.md index d690f53d6fddc..4829644466d68 100644 --- a/operator/docs/lokistack/object_storage.md +++ b/operator/docs/lokistack/object_storage.md @@ -67,7 +67,8 @@ _Note_: Upon setting up LokiStack for any object storage provider, you should co --from-literal=container="" \ --from-literal=environment="" \ --from-literal=account_name="" \ - --from-literal=account_key="" + --from-literal=account_key="" \ + --from-literal=endpoint_suffix="" ``` where `lokistack-dev-azure` is the secret name. @@ -303,4 +304,4 @@ _Note_: Upon setting up LokiStack for any object storage provider, you should co secret: name: lokistack-dev-alibabacloud type: alibabacloud - ``` \ No newline at end of file + ``` From 344275e3f27fe56032347851530f6eba0b1b3841 Mon Sep 17 00:00:00 2001 From: Periklis Tsirakidis Date: Mon, 2 Oct 2023 13:29:27 +0200 Subject: [PATCH 4/4] Update operator/internal/manifests/internal/config/loki-config.yaml Co-authored-by: Robert Jacob --- operator/internal/manifests/internal/config/loki-config.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/operator/internal/manifests/internal/config/loki-config.yaml b/operator/internal/manifests/internal/config/loki-config.yaml index 7087bb66cc1ad..7b4c2c14dd4d2 100644 --- a/operator/internal/manifests/internal/config/loki-config.yaml +++ b/operator/internal/manifests/internal/config/loki-config.yaml @@ -14,7 +14,9 @@ common: container_name: {{ .Container }} account_name: {{ .AccountName }} account_key: {{ .AccountKey }} - endpoint_suffix: {{ .EndpointSuffix }} + {{- with .EndpointSuffix }} + endpoint_suffix: {{ . }} + {{- end }} {{- end }} {{- with .ObjectStorage.GCS }} gcs: