cloudbase / cloudbase-init

Cross-platform instance initialization
http://openstack.org
Apache License 2.0
421 stars 149 forks source link

Modifies userdata plugin to support jinja templating #29

Closed gab-satchi closed 4 years ago

gab-satchi commented 4 years ago

We're working on adding Windows support for Kubernetes cluster-api and it uses cloud-init for bootstrapping with kubeadm. Cloud init relies on jinja to template the user data with values from the instance data (e.g: hostname).

A sample cloud-init metadata:

## template: jinja
#cloud-config

write_files:
-   path: /tmp/kubeadm-node.yaml
    owner: root:root
    permissions: '0640'
    content: |
      ---
      apiVersion: kubeadm.k8s.io/v1beta1
      discovery:
        bootstrapToken:
          apiServerEndpoint: capi-quickstart-apiserver-748134055.us-east-1.elb.amazonaws.com:6443
          caCertHashes:
          - sha256:1234
          token: some_token
          unsafeSkipCAVerification: false
      kind: JoinConfiguration
      nodeRegistration:
        kubeletExtraArgs:
          cloud-provider: aws
        name: '{{ ds.meta_data.hostname }}'

We only exposed the hostname as that was the only thing needed to complete the template above. The cloud providers don't expose much else in the current implementation. To provide all of the metadata across all cloud providers will be a much larger undertaking.

Note:

ader1990 commented 4 years ago

@gab-satchi the instance-data, jinja templating and cloud-config users/groups/runcmd/ntp have been merged.

gab-satchi commented 4 years ago

Thanks @ader1990