osism / k8s-capi-images

Images intended for use with Kubernetes CAPI providers
https://www.osism.tech
14 stars 2 forks source link

question: set cloudinit manually #240

Closed cybercoder closed 5 months ago

cybercoder commented 5 months ago

Is it possible to set cloudinit manually? I need to set a password and so on.

apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1
kind: KubevirtMachineTemplate
.
.
.
              volumes:
                - name: disk0
                  dataVolume:
                    name: disk0
                - name: cinit
                  cloudInitNoCloud:
                    userData: |-
                      #cloud-config
                      apt:
                        primary:
                          - arches: [default]
                            uri: http://de.archive.ubuntu.com/ubuntu/
                      package_update: true
                      packages:
                        - qemu-guest-agent
                      runcmd:
                        - - systemctl
                          - enable
                          - --now
                          - qemu-guest-agent.service
                      user: myuser
                      password: mypassword
                      ssh_pwauth: True
                      chpasswd:
                        expire: false

But it seems it doesn't apply

batistein commented 5 months ago

please check out the bootstrap provider you use. e.g for kubeadm in clusterapi. There you can set custom cloud-init commands via pre- & postKubeadmCommands

https://doc.crds.dev/github.com/kubernetes-sigs/cluster-api/bootstrap.cluster.x-k8s.io/KubeadmConfigTemplate/v1beta1@v1.7.0-beta.0#spec-template-spec-postKubeadmCommands