-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Configure account_key as secret for Loki with Azure storage #9143
Comments
The same issue exists for s3 storage configuration as well. |
I got this working for s3 storage by setting The same approach might work for Azure (I'm unable to test with Azure). Based on the Azure Go SDK docs, you can set helm values: write:
extraEnvFrom:
- secretRef:
name: loki-s3-credentials # contains AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY
read:
extraEnvFrom:
- secretRef:
name: loki-s3-credentials
backend:
extraEnvFrom:
- secretRef:
name: loki-s3-credentials Secret config: apiVersion: v1
kind: Secret
metadata:
name: loki-s3-credentials
type: Opaque
data:
AWS_ACCESS_KEY_ID: YOUR_ACCESS_KEY_ID_HERE
AWS_SECRET_ACCESS_KEY: YOUR_AWS_SECRET_ACCESS_KEY_HERE Alternatively, you could try using environment variable expansion in the configuration by passing in helm values (untested): loki:
storage:
bucketNames:
chunks: chunks
ruler: ruler
admin: admin
type: azure
azure:
accountName: ${AZURE_ACCOUNT_NAME}
accountKey: ${AZURE_ACCOUNT_KEY}
useManagedIdentity: false
useFederatedToken: false
userAssignedId: null
requestTimeout: null
read:
extraArgs:
- "-config.expand-env=true"
write:
extraArgs:
- "-config.expand-env=true"
backend:
extraArgs:
- "-config.expand-env=true" Secret config: apiVersion: v1
kind: Secret
metadata:
name: loki-azure-credentials
type: Opaque
stringData:
AZURE_ACCOUNT_NAME: YOUR_AZURE_ACCOUNT_NAME_HERE
AZURE_ACCOUNT_KEY: YOUR_AZURE_ACCOUNT_KEY_HERE |
Thanks @slyt, I have tested it, and it works! 🎉 |
@slyt please change example to use |
Hi, I tried to configure the secrets for an azure blob storage the last few days and ran into issues with the configuration as described.
I tried with I have tried it with putting the AZURE_ACCOUNT_KEY directly into the helm chart, this works well, but as soon as I use a secret, I get a base64 error. Do you have any suggesetions on why this could still be? |
@lausserl Hi, did you solve it? I have the exact same issue. I have put many hours into trying to solve this but could not. |
@slyt @lausserl @Aangbaeck I am facing the same problem using the loki-stack chart. Do any of you have any idea how to configure the Like @Aangbaeck, I've also have put many hours into trying to solve this but could not. |
Hi, for me the explanation from @slyt works with Azure Storage. This is how I did it using Step 1: Store Secrets in Azure Key VaultEnsure your Azure storage account name and key are securely stored in an Azure Key Vault. Step 2: Define AzureKeyVaultSecret in Helm TemplateGo to the Helm Templates directory and create a file that defines the Here's the Helm template for the Azure Key Vault secret: # Template for the storage account key
apiVersion: spv.no/v1
kind: AzureKeyVaultSecret
metadata:
name: loki-az-storage-account-key
namespace: {{ .Release.Namespace }}
annotations:
argocd.argoproj.io/sync-wave: "-5"
spec:
vault:
name: {{ .Values.kvAzName }}
object:
name: {{ .Values.kvAzStorageAccountKey }}
type: secret
output:
secret:
name: loki-az-storage-account-key
dataKey: AZURE_ACCOUNT_KEY
---
# Template for the storage account name
apiVersion: spv.no/v1
kind: AzureKeyVaultSecret
metadata:
name: loki-az-storage-account-name
namespace: {{ .Release.Namespace }}
annotations:
argocd.argoproj.io/sync-wave: "-5"
spec:
vault:
name: {{ .Values.kvAzName }}
object:
name: {{ .Values.kvAzStorageAccountName }}
type: secret
output:
secret:
name: loki-az-storage-account-name
dataKey: AZURE_ACCOUNT_NAME Step 3: Configure values.yaml for Each EnvironmentFor each environment, such as staging or production, update the values-{env}.yaml file with the following parameters: kvAzName: "YOUR_KEYVAULT_NAME"
kvAzStorageAccountKey: "THE_SECRET_NAME_FOR_ACCOUNT_KEY"
kvAzStorageAccountName: "THE_SECRET_NAME_FOR_ACCOUNT_NAME" Step 4: Update Loki's values.yamlUpdate the loki:
storage:
azure:
accountName: ${AZURE_ACCOUNT_NAME}
accountKey: ${AZURE_ACCOUNT_KEY} And in each Loki component add: extraArgs:
- "-config.expand-env=true"
extraEnvFrom:
- secretRef:
name: loki-az-storage-account-name
- secretRef:
name: loki-az-storage-account-key I hope this help! 🙏🏼 |
For anyone looking for a solution using loki-stack chart, the problem is that apparently declaring the argument this way:
Doesn't work and ends up resulting in a manifest with corrupted flags, like this:
Somehow, What solved it for me was defining the yaml values like this:
|
still unable to get this working due to the |
Problem solved! Now I'm using the basic loki helm chart. My setup: kustomization.yaml
values.yaml
|
The document of Loki should be enhanced like Tempo (https://grafana.com/docs/tempo/latest/configuration/hosted-storage/azure/#sample-configuration-for-tempo-distributed-mode) and mention the need to specify |
To use Loki with Azure I need to set an
account_key
attribute when using Helm.Shouldn't we be able to to set this setting from an environment variable or a secret? Currently I need to keep my
accountKey
inside myvalues.yaml
file and this is not secure.Grafana Tempo, for example, accepts the
AZURE_STORAGE_KEY
variable. I tried to use it with Loki and had the following error:Is there any workaround?
The text was updated successfully, but these errors were encountered: