Skip to content

bootstrap-provider: allow the content of a file to come from a configmap or secret #1846

@richardcase

Description

@richardcase

User Story

As an operator I would like to be able to be able to get the contents of a file from a configmap or secret so that i don't have to embed the contents directly within the KubeadmConfig. This is especially useful for custom configuration using PreKubeadmCommands and PostKubeadmCommands.

Detailed Description

I would like to see Contents changed with the File struct so that you can specify the contents in 3 ways:

  • Explicit value (how you currently do it)
  • Reference a config map and get the contents from there when creating the bootstrap data
  • Reference a secret and get the contents from the secret when creating the bootstrap data

This is the current situation:

apiVersion: bootstrap.cluster.x-k8s.io/v1alpha2
kind: KubeadmConfig
metadata:
  name: capi-quickstart-controlplane-0
spec:
  clusterConfiguration:
    apiServer:
      extraArgs:
        cloud-config: /etc/kubernetes/azure.json
        cloud-provider: azure
      extraVolumes:
      - hostPath: /etc/kubernetes/azure.json
        mountPath: /etc/kubernetes/azure.json
        name: cloud-config
        readOnly: true
      timeoutForControlPlane: 20m
    controllerManager:
      extraArgs:
        allocate-node-cidrs: "false"
        cloud-config: /etc/kubernetes/azure.json
        cloud-provider: azure
      extraVolumes:
      - hostPath: /etc/kubernetes/azure.json
        mountPath: /etc/kubernetes/azure.json
        name: cloud-config
        readOnly: true
  files:
  - content: |
      {
        "cloud": "AzurePublicCloud",
        "tenantId": "${AZURE_TENANT_ID}",
        "subscriptionId": "${AZURE_SUBSCRIPTION_ID}",
        "aadClientId": "${AZURE_CLIENT_ID}",
        "aadClientSecret": "${AZURE_CLIENT_SECRET}",
        ....
      }
    owner: root:root
    path: /etc/kubernetes/azure.json
    permissions: "0644"

And it could be changed to something like this:

  files:
  - content
        valueFrom:
            secretKeyRef:
                   name: azurecreds
                   key: azure.json
    owner: root:root
    path: /etc/kubernetes/azure.json
    permissions: "0644"

Or using an ObjectReference

Anything else you would like to add:

/kind feature

Metadata

Metadata

Labels

kind/featureCategorizes issue or PR as related to a new feature.priority/backlogHigher priority than priority/awaiting-more-evidence.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions