Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

operator: Allow endpoint_suffix in azure object storage secret #10715

Merged
merged 5 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions operator/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## Main

- [10715](https://github.com/grafana/loki/pull/10715) **periklis**: Allow endpoint_suffix in azure object storage secret
- [10562](https://github.com/grafana/loki/pull/10562) **periklis**: Add memberlist IPv6 support
- [10720](https://github.com/grafana/loki/pull/10720) **JoaoBraveCoding**: Change default replication factor of 1x.medium to 2
- [10600](https://github.com/grafana/loki/pull/10600) **periklis**: Update Loki operand to v2.9.1
Expand Down
5 changes: 3 additions & 2 deletions operator/docs/lokistack/object_storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ _Note_: Upon setting up LokiStack for any object storage provider, you should co
--from-literal=container="<AZURE_CONTAINER_NAME>" \
--from-literal=environment="<AZURE_ENVIRONMENTs>" \
--from-literal=account_name="<AZURE_ACCOUNT_NAME>" \
--from-literal=account_key="<AZURE_ACCOUNT_KEY>"
--from-literal=account_key="<AZURE_ACCOUNT_KEY>" \
--from-literal=endpoint_suffix="<OPTIONAL_AZURE_ENDPOINT_SUFFIX>"
```

where `lokistack-dev-azure` is the secret name.
Expand Down Expand Up @@ -303,4 +304,4 @@ _Note_: Upon setting up LokiStack for any object storage provider, you should co
secret:
name: lokistack-dev-alibabacloud
type: alibabacloud
```
```
12 changes: 8 additions & 4 deletions operator/internal/handlers/internal/storage/secrets.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Comment on lines +59 to +60
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit confused by the comment, we are only extracting the field correct?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just a hint to make the section more human readable. I imagine that we extra more optional fields if requested.


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
}

Expand Down
14 changes: 13 additions & 1 deletion operator/internal/handlers/internal/storage/secrets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ common:
container_name: {{ .Container }}
account_name: {{ .AccountName }}
account_key: {{ .AccountKey }}
{{- with .EndpointSuffix }}
endpoint_suffix: {{ . }}
{{- end }}
{{- end }}
{{- with .ObjectStorage.GCS }}
gcs:
Expand Down
9 changes: 5 additions & 4 deletions operator/internal/manifests/storage/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down