Skip to content
Khodayar Doustar edited this page Apr 27, 2020 · 1 revision

Welcome to the fcos-govc-vcenter wiki!

Download Fedora CoreOS (fcos)

wget https://builds.coreos.fedoraproject.org/prod/streams/stable/builds/31.20200407.3.0/x86_64/fedora-coreos-31.20200407.3.0-vmware.x86_64.ova

Download govc binary

wget https://github.com/vmware/govmomi/releases/download/v0.22.1/govc_linux_amd64.gz

Unzip, put it in path, a test and collect required data:

gunzip govc_linux_amd64.gz
mv govc_linux_amd64 /usr/local/bin/govc
chmod 755 /usr/local/bin/govc
govc about -k
govc session.login -k
govc find -k / -type p
#sample result:	/Datacenter/host/Cluster1/Resources
govc ls -k datastore
#sample result:	datastore1 (1)
govc ls -k 
#Put your desired folder in 'GOVC_FOLDER' env value]

Create your fcct ignition file.

You have to create your ssh-key and password hash separately. This file will create a user, set hostname and static ip address:

[root@okd4dns ~]# cat user.fcc 
variant: fcos
version: 1.0.0
passwd:
  users:
    - name: core
      password_hash: "$6$2QKuU....PDRFW"
      ssh_authorized_keys:
        - "ssh-rsa AAAAB3NzaC1yc.....efo3e7dQ=="
storage:
  files:
  - path: /etc/hostname
    overwrite: true
    mode: 0644
    contents:
      inline: fcos01.dom.tld
  - path: /etc/NetworkManager/system-connections/eth0.nmconnection
    mode: 0600
    overwrite: true
    contents:
      inline: |
        [connection]
        type=ethernet
        interface-name=eth0

        [ipv4]
        method=manual
        addresses=10.1.4.10/24
        gateway=10.1.4.1
        dns=10.1.4.1;1.1.1.1;8.8.8.8
        dns-search=dom.tld
[root@okd4dns ~]# 

Convert fcct file to ignition file using fcct docker image and validate it:

yum install podman docker
podman run -i --rm quay.io/coreos/fcct:release --pretty --strict < user.fcc > ign.ign
podman run --rm -i quay.io/coreos/ignition-validate - < ign.ign

Export env values.

export FCOS_OVA='fedora-coreos-31.20200407.3.0-vmware.x86_64.ova'
export LIBRARY='fcos-stable'
export TEMPLATE_NAME='fcos-31.20200407.3.0'
export GOVC_URL=''administrator@vsphere.local':'PASSWORD'@10.10.10.10'
export GOVC_DATASTORE='datastore1 (1)'
export VM_NAME='fcos-stable-node01'
export GOVC_RESOURCE_POOL='/Datacenter/host/Cluster1/Resources'
export CONFIG_B64=`cat ign.ign | base64 -w0 -`
export GOVC_FOLDER='/Datacenter/vm/Khodayar/'

Create the library in vCenter

govc library.create -k "${LIBRARY}"
govc library.import -k -n "${TEMPLATE_NAME}" "${LIBRARY}" "${FCOS_OVA}"

Create the machine

Put the ignition file and power it on, first time will take a few minutes.

govc library.deploy -k "${LIBRARY}/${TEMPLATE_NAME}" "${VM_NAME}"
govc vm.change -k -vm "${VM_NAME}" -e "guestinfo.ignition.config.data.encoding=base64"
govc vm.change -k -vm "${VM_NAME}" -e "guestinfo.ignition.config.data=${CONFIG_B64}"
govc vm.info -k -e "${VM_NAME}"
govc vm.power -k -on "${VM_NAME}"

In case you want to delete your machine:

govc vm.destroy -k "${VM_NAME}"