在本文中,我们将介绍如何在OpenStack和KVM虚拟化环境中运行Fedora CoreOS(FCOS)的步骤:下载最新的QCOW2映像、创建Fedora CoreOS Config(FCC)、将FCC转换为Ignition配置、启动Fedora CoreOS计算机,包括在Fedora CoreOS上安装软件包。
步骤1:下载最新的QCOW2映像 转到FCOS下载页面以检索适合QEMU的最新image,地址:https://getfedora.org/coreos/download/。 OpenStack: wget https://builds.coreos.fedoraproject.org/prod/streams/stable/builds/31.20200113.3.1/x86_64/fedora-coreos-31.20200113.3.1-openstack.x86_64.qcow2.xz -O fedora-coreos-openstack.qcow2.xz unxz fedora-coreos-openstack.qcow2.xz QEMU/KVM: wget https://builds.coreos.fedoraproject.org/prod/streams/stable/builds/31.20200113.3.1/x86_64/fedora-coreos-31.20200113.3.1-qemu.x86_64.qcow2.xz -O fedora-coreos-qemu.qcow2.xz unxz fedora-coreos-qemu.qcow2.xz 对于Openstack,您需要将Fedora CoreOS image上传到OpenStack Glance服务: openstack image create "fcos" \ --file fedora-coreos-openstack.qcow2 \ --disk-format qcow2 --container-format bare \ --public 确认image已上传: $ openstack image list
步骤2:创建Fedora CoreOS Config(FCC) FCC是具有所需计算机配置的YAML文件,FCC支持所有Ignition功能,并提供其他语法(“sugar”),使指定典型配置更改更加容易。 这是我的基本YAML配置文件,用于将SSH密钥添加到默认核心用户: $ vim fcos.fcc variant: fcos version: 1.0.0 passwd: users: - name: core ssh_authorized_keys: - ssh-rsa xx... 注: core是FCOS用户的名称。 xx…是您的公钥的内容。
步骤3:将FCC转换为Ignition配置 现在,我们将使用Fedora CoreOS Config Transpiler来验证FCC并将其转换为Ignition配置: --- Podman --- $ podman pull quay.io/coreos/fcct:v0.2.0 $ podman run -i --rm quay.io/coreos/fcct:v0.2.0 -pretty -strict <fcos.fcc > fcos.ign --- Docker --- $ docker pull quay.io/coreos/fcct:v0.2.0 $ docker run -i --rm quay.io/coreos/fcct:v0.2.0 -pretty -strict <fcos.fcc > fcos.ign 将fcos.fcc替换为FCC文件的名称,将fcos.ign替换为要创建的ignition文件的名称。 您可以使用以下方法手动验证ignition配置文件: --- Podman --- $ podman run --rm -i quay.io/coreos/ignition-validate - < fcos.ign --- Docker --- $ docker run --rm -i quay.io/coreos/ignition-validate - < fcos.ign
步骤4:启动Fedora CoreOS计算机 准备好ignition文件后,您可以通过传递创建的Ignition配置来创建Fedora CoreOS计算机。 1、在OpenStack上 OpenStack CLI:在Linux系统上安装和配置OpenStack Client(客户端)的方法。 $ openstack server create \ --image fcos \ --key-name <your-openstack-key-name> \ --flavor m1.small \ --security-group <your-security-group> \ --network private \ --user-data fcos.ign \ fcos 注: <your-openstack-key-name>,其中包含您的SSH密钥的名称上传到OpenStack。 <your-security-group>,其安全组的ID已上传到OpenStack。 在构建开始时立即输出:
检查虚拟机状态: $ openstack server list --name fcos
让我们看看是否可以ping通VM: $ ping -c 3 10.10.1.126 PING 10.10.1.126 (10.10.1.126) 56(84) bytes of data. 64 bytes from 10.10.1.126: icmp_seq=1 ttl=64 time=0.320 ms 64 bytes from 10.10.1.126: icmp_seq=2 ttl=64 time=0.297 ms 64 bytes from 10.10.1.126: icmp_seq=3 ttl=64 time=0.373 ms --- 10.10.1.126 ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 1999ms rtt min/avg/max/mdev = 0.297/0.330/0.373/0.031 ms 我们可以SSH到实例吗? $ ssh core@10.10.1.126 Warning: Permanently added '10.10.1.126' (ECDSA) to the list of known hosts. Enter passphrase for key '/home/centos/.ssh/id_rsa': Fedora CoreOS 31.20200113.3.1 Tracker: https://github.com/coreos/fedora-coreos-tracker 检查操作系统版本: $ cat /etc/os-release NAME=Fedora VERSION="31.20200113.3.1 (CoreOS)" ID=fedora VERSION_ID=31 VERSION_CODENAME="" PLATFORM_ID="platform:f31" PRETTY_NAME="Fedora CoreOS 31.20200113.3.1" ANSI_COLOR="0;34" LOGO=fedora-logo-icon CPE_NAME="cpe:/o:fedoraproject:fedora:31" HOME_URL="https://getfedora.org/coreos/" DOCUMENTATION_URL="https://docs.fedoraproject.org/en-US/fedora-coreos/" SUPPORT_URL="https://github.com/coreos/fedora-coreos-tracker/" BUG_REPORT_URL="https://github.com/coreos/fedora-coreos-tracker/" REDHAT_BUGZILLA_PRODUCT="Fedora" REDHAT_BUGZILLA_PRODUCT_VERSION=31 REDHAT_SUPPORT_PRODUCT="Fedora" REDHAT_SUPPORT_PRODUCT_VERSION=31 PRIVACY_POLICY_URL="https://fedoraproject.org/wiki/Legal:PrivacyPolicy" VARIANT="CoreOS" VARIANT_ID=coreos OSTREE_VERSION='31.20200113.3.1' $ uname -a Linux host-10-10-1-126 5.4.8-200.fc31.x86_64 #1 SMP Mon Jan 6 16:44:18 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux 2、在KVM/QEMU上 将下载的image复制到虚拟机安装目录,例如: sudo cp fedora-coreos-qemu.qcow2 /var/lib/libvirt/images/fedora-coreos-qemu.qcow2 使用virt-install: $ virt-install -n fcos --vcpus 2 -r 2048 \ --os-variant=fedora31 --import \ --network bridge=virbr0 \ --disk=/var/lib/libvirt/images/fedora-coreos-qemu.qcow2,format=qcow2,bus=virtio \ --noautoconsole \ --qemu-commandline="-fw_cfg name=opt/com.coreos/config,file=/path/to/fcos.ign" 3、在Fedora CoreOS上安装软件包 可以在Fedora CoreOS上安装的软件包数量有限制,更新Fedora CoreOS和安装应用程序的主要方法是rpm-ostree。 rpm-ostree可以通过修改FCOS安装来扩展组成Silverblue的软件包,程序包分层会创建一个新的“deployment”或可引导文件系统根,在对程序包分层后必须重新引导系统,这样可以保留回滚和事务模型。 1]、首先,生成rpm repo元数据: $ sudo rpm-ostree refresh-md Enabled rpm-md repositories: updates fedora Updating metadata for 'updates'... done rpm-md repo 'updates'; generated: 2020-01-24T14:56:09Z Updating metadata for 'fedora'... done rpm-md repo 'fedora'; generated: 2019-10-23T22:52:47Z Importing rpm-md... done 2]、可以使用以下方法在Silverblue上安装软件包: $ sudo rpm-ostree install <package name> Example: $ sudo rpm-ostree install vim Checking out tree f480038... done Enabled rpm-md repositories: updates fedora rpm-md repo 'updates' (cached); generated: 2020-01-24T14:56:09Z rpm-md repo 'fedora' (cached); generated: 2019-10-23T22:52:47Z Importing rpm-md... done Resolving dependencies... done Will download: 13 packages (20.0 MB) Downloading from 'fedora'... done Downloading from 'updates'... done Importing packages... done Checking out packages... done Running pre scripts... done Running post scripts... done Running posttrans scripts... done Writing rpmdb... done Writing OSTree commit... done Staging deployment... done ...... 软件包安装后需要重新启动: $ sudo systemctl reboot 至此,讲解完成启动Fedora CoreOS计算机的内容。
相关主题 |