RawCloudConfig should respect bootstrap data deployed from v1a1 ConfigMap
What steps did you take and what happened?
- Deploy a
Secretcontaining some cloud-init bootstrap user data:
$ cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Secret
metadata:
name: bootstrap-data
namespace: sdiliyaer-test
type: Opaque
stringData:
user-data: |
#cloud-config
ssh_pwauth: true
users:
- name: test-1
plain_text_passwd: test-1
lock_passwd: false
sudo: ALL=(ALL) NOPASSWD:ALL
shell: /bin/bash
EOF
secret/bootstrap-data created
- Deploy a
ConfigMapwith the same name and namespace as the above Secret but containing different user-data:
$ cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: ConfigMap
metadata:
name: bootstrap-data
namespace: sdiliyaer-test
data:
user-data: |
#cloud-config
ssh_pwauth: true
users:
- name: test-2
plain_text_passwd: test-2
lock_passwd: false
sudo: ALL=(ALL) NOPASSWD:ALL
shell: /bin/bash
EOF
configmap/bootstrap-data created
- Deploy a
v1a1 VMusing cloud-init and the aboveConfigMapas its bootstrap-data:
$ cat <<EOF | kubectl apply -f -
apiVersion: vmoperator.vmware.com/v1alpha1
kind: VirtualMachine
metadata:
name: my-vm
namespace: sdiliyaer-test
spec:
imageName: ubuntu-impish-21.10-cloudimg
className: best-effort-small
storageClass: wcpglobal-storage-profile
vmMetadata:
transport: CloudInit
configMapName: bootstrap-data
EOF
virtualmachine.vmoperator.vmware.com/my-vm created
What did you expect to happen?
The VM is booted with the user-data from the ConfigMap (test-2 user) as specified in the v1a1 VM YAML spec.
However, it actually boots with the user-data from the Secret (test-1 user), as verified by the SSH user credentials below:
$ kubectl get vm -A -o wide
NAMESPACE NAME POWER-STATE CLASS IMAGE PRIMARY-IP4 AGE
sdiliyaer-test my-vm PoweredOn best-effort-small vmi-d88f64306b7a6a392 192.168.128.9 5m13s
$ ssh [email protected]
[email protected]'s password:
Welcome to Ubuntu Impish Indri (development branch) (GNU/Linux 5.13.0-14-generic x86_64)
...
test-1@my-vm:~$ exit
logout
Connection to 192.168.128.9 closed.
$ ssh [email protected]
[email protected]'s password:
Permission denied, please try again.
Is there anything else you would like to add?
As discussed internally with the team:
In the up conversion lets add an annotation to indicate to use a CM during reconcile. And on down conversion use the annotation to fill in the right field in https://github.com/vmware-tanzu/vm-operator/blob/main/api/v1alpha1/virtualmachine_conversion.go#L209
And mark ConfigMapName as deprecated in the v1a1 api
WIP branch: https://github.com/sreyasn/vm-operator/commit/ed3696279139ed955c9b3501948ecb57ea3a8b26