Skip to content

[v1beta2] Improve AdditionalUserData API #717

@anmazzotti

Description

@anmazzotti

The current definition of additionalUserData in RKE2ControlPlane and RKE2Config has two main issues:

  1. additionalUserData.config (Ignition) and additionalUserData.data (cloud-init) have different types (string vs map[string]string) and implementation
  2. both implementations (string and map[string]string) are sub-optimal to represent a schemaless nested object, but of the two, map[string]string is absolutely the most confusing and hard to work with (see cloud-init arbitraryTemplate handling)

The most appropriate and straightforward implementation would be map[string]runtime.RawExtension, like this example. This can support cloud-init and ignition equally, with a better user experience and simpler deserialization and (strict: true) validation (no more template complexity):

Old

apiVersion: controlplane.cluster.x-k8s.io/v1beta1
kind: RKE2ControlPlane
metadata:
  name: cloud-init
spec:
  agentConfig:
    format: cloud-init
    additionalUserData:
      strict: true
      data:
        bootcmd: |
          - touch /foo.bar
          - touch /bar.foo
---
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
kind: RKE2ControlPlane
metadata:
  name: ignition
spec:
  agentConfig:
    format: ignition
    additionalUserData:
      strict: true
      config: |
        storage:
          luks:
            - name: data
              device: /dev/disk/by-partlabel/USR-B

New

apiVersion: controlplane.cluster.x-k8s.io/v1beta2
kind: RKE2ControlPlane
metadata:
  name: cloud-init
spec:
  agentConfig:
    format: cloud-init
    additionalUserData:
      strict: true
      cloudConfig:
        bootcmd:
          - touch /foo.bar
          - touch /bar.foo
---
apiVersion: controlplane.cluster.x-k8s.io/v1beta2
kind: RKE2ControlPlane
metadata:
  name: ignition
spec:
  agentConfig:
    format: ignition
    additionalUserData:
      strict: true
      cloudConfig:
        storage:
          luks:
            - name: data
              device: /dev/disk/by-partlabel/USR-B

The new cloudConfig key is just a quick suggestion to have 1 seamless definition, instead of unnecessarily splitting between config and data, since the user can already configure the format field.
Warning: API conversion is going to be the biggest challenge of this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    lifecycle/staleDenotes an issue or PR has remained open with no activity and has become stale.

    Type

    No fields configured for Task.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions