Skip to content

[feature] restic and azure workload identity #1901

Description

@sybnex

I was the last weeks hardly working on our backup solution using volsync and restic using azure workload identity in our AKS environment.

I found, that restic can do so since: restic/restic#4029
But there are some missing values in volsync to archive the full flow with managed identites with a AKS setup.

There are three env variables missing:

AZURE_TENANT_ID
AZURE_CLIENT_ID
AZURE_FEDERATED_TOKEN_FILE

AZURE_TENANT_ID and AZURE_CLIENT_ID have to be configured by the user and must be transferred to the scheduling pod from the restic_config secret.

The AZURE_FEDERATED_TOKEN_FILE points to the service account token in the pod and could be fixed in the backup pod template like:

    - name: AZURE_FEDERATED_TOKEN_FILE
      value: "/var/run/secrets/kubernetes.io/serviceaccount/token"

What is the value to the end user? (why is it a priority?)
The main value to use workload identity is, that u don't have any passwords or token in Kubernetes at all. Our CISO would love to see that.

How will we know we have a good solution? (acceptance criteria)
Backup in AKS without credentials

Additional context
I'll try to make a pull request, especially for the azure setup documentation

Workaround

apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
  name: inject-env-from-sa-label
spec:
  rules:
  - name: inject-backup-mode
    match:
      any:
      - resources:
          kinds:
          - Pod
          selector:
            matchLabels:
              app.kubernetes.io/created-by: volsync
    context:
    - name: clientID
      apiCall:
        urlPath: "/api/v1/namespaces/{{request.namespace}}/serviceaccounts/backup"
        jmesPath: "metadata.annotations.\"azure.workload.identity/client-id\""
    - name: tenantID
      variable:
        value: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
    - name: tokenFile
      variable:
        value: "/var/run/secrets/kubernetes.io/serviceaccount/token"
    mutate:
      patchStrategicMerge:
        spec:
          containers:
          - (name): "*"
            env:
            - name: AZURE_CLIENT_ID
              value: "{{ clientID }}"
            - name: AZURE_TENANT_ID
              value: "{{ tenantID }}"
            - name: AZURE_FEDERATED_TOKEN_FILE
              value: "{{ tokenFile }}"

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions