We've seen in the previous post how to enable and use VM Operator. We've also noticed that currently there are only 2 VM images that are supported to be deployed using VM Operator. What if we need to create our own image?
There is a way, but the way is not supported by VMware. So once going this path, you have to understand the risks.
What is so special about the VM image deployed using VM Operator? It is using cloud-init and OVF environment variables to initialize the VM.
Let's start with a new Linux VM template. We will install VMware Tools. Then we need to install cloud-init. Once cloud init is installed update the configuration as following:
- in /etc/cloud/cloud.cfg check the following value: disable_vmware_customization: true
- setting it to true invokes traditional Guest Operating System Customization script based workflow (GOSC); in case it is set to false, cloud-init customization will be used.
- create a new file /etc/cloud/cloud.cfg.d/99_vmservice.cfg and add the following line to it network: {config: disabled};
- this will actually prevent cloud-init to configure the network; you guessed, VMware Tools will be used to configure the network
<ProductSection ovf:required="false"> <Info>Cloud-Init customization</Info> <Product>Linux distribution for VMware VM Service</Product> <Property ovf:key="instance-id" ovf:type="string" ovf:userConfigurable="true" ovf:value="id-ovf"> <Label>A Unique Instance ID for this instance</Label> <Description>Specifies the instance id. This is required and used to determine if the machine should take "first boot" actions</Description> </Property> <Property ovf:key="hostname" ovf:type="string" ovf:userConfigurable="true" ovf:value="centosguest"> <Description>Specifies the hostname for the appliance</Description> </Property> <Property ovf:key="seedfrom" ovf:type="string" ovf:userConfigurable="true"> <Label>Url to seed instance data from</Label> <Description>This field is optional, but indicates that the instance should 'seed' user-data and meta-data from the given url. If set to 'http://tinyurl.com/sm-' is given, meta-data will be pulled from http://tinyurl.com/sm-meta-data and user-data from http://tinyurl.com/sm-user-data. Leave this empty if you do not want to seed from a url.</Description> </Property> <Property ovf:key="public-keys" ovf:type="string" ovf:userConfigurable="true" ovf:value=""> <Label>ssh public keys</Label> <Description>This field is optional, but indicates that the instance should populate the default user's 'authorized_keys' with this value</Description> </Property> <Property ovf:key="user-data" ovf:type="string" ovf:userConfigurable="true" ovf:value=""> <Label>Encoded user-data</Label> <Description>In order to fit into a xml attribute, this value is base64 encoded . It will be decoded, and then processed normally as user-data.</Description> </Property> <Property ovf:key="password" ovf:type="string" ovf:userConfigurable="true" ovf:value=""> <Label>Default User's password</Label> <Description>If set, the default user's password will be set to this value to allow password based login. The password will be good for only a single login. If set to the string 'RANDOM' then a random password will be generated, and written to the console.</Description> </Property> </ProductSection>
<vmw:ExtraConfig ovf:required="false" vmw:key="guestinfo.vmservice.defer-cloud-init" vmw:value="ready"/>
metadata: name: my-vm-name labels: app: db-server annotations: vmoperator.vmware.com/image-supported-check: disable
No comments:
Post a Comment