Fedora CoreOS入门
引言
溪流
有三个Fedora CoreOS(FCOS)更新流可用: stable
, testing
,及 next
。通常,您将希望使用 stable
,但建议在以下位置运行某些计算机 testing
和 next
以及提供反馈。
每个流都有一个以JSON格式表示其当前状态的规范URL,称为“流元数据”。例如,的流元数据URL stable
是: https://builds.coreos.fedoraproject.org/streams/stable.json
对于自动化Fedora CoreOS安装,预计您将与流元数据交互。虽然Fedora CoreOS会进行自动就地更新,但通常情况下,从最新映像开始配置新机器是一种良好的做法。
资源调配理念
Fedora CoreOS没有单独的安装盘。相反,每个实例都从一个通用磁盘镜像开始,该镜像在第一次引导时通过 Ignition 。
每个平台都有特定的逻辑来检索和应用第一个引导配置。对于云部署,Ignition通过用户数据机制收集配置。在裸机的情况下,Ignition可以从磁盘或远程源获取其配置。
有关配置的详细信息,请参阅的文档 生成Ignition文件 。
快速入门
在云VM上引导(AWS示例)
可以直接从公共FCOS镜像创建新的AWS实例。您可以从以下地址找到每个地区的最新AMI 下载页面 。
如果您只对探索FCOS感兴趣,而没有进一步的定制,那么您可以使用 已注册的SSH密钥对 对于默认设置 core
用户。
要以这种方式测试FCOS,您需要运行 aws ec2 run-instances
命令,并提供一些信息来启动和运行该实例。以下是您可以使用的命令示例:
NAME='instance1'
SSHKEY='my-key' # the name of your SSH key: `aws ec2 describe-key-pairs`
IMAGE='ami-xxx' # the AMI ID found on the download page
DISK='20' # the size of the hard disk
REGION='us-east-1' # the target region
TYPE='m5.large' # the instance type
SUBNET='subnet-xxx' # the subnet: `aws ec2 describe-subnets`
SECURITY_GROUPS='sg-xx' # the security group `aws ec2 describe-security-groups`
aws ec2 run-instances \
--region $REGION \
--image-id $IMAGE \
--instance-type $TYPE \
--key-name $SSHKEY \
--subnet-id $SUBNET \
--security-group-ids $SECURITY_GROUPS \
--tag-specifications "ResourceType=instance,Tags=[{Key=Name,Value=${NAME}}]" \
--block-device-mappings "VirtualName=/dev/xvda,DeviceName=/dev/xvda,Ebs={VolumeSize=${DISK}}"
您可以通过运行以下命令来查找分配给实例的IP aws ec2 describe-instances
|
现在,您应该能够使用关联的IP地址通过SSH连接到该实例。
为了启动自定义的FCOS实例,必须将有效的Ignition配置作为其 用户数据 在创造的时候。您可以从上面使用相同的命令,但添加 --user-data file://path/to/config.ign
论据:
NAME='instance1'
SSHKEY='my-key' # the name of your SSH key: `aws ec2 describe-key-pairs`
IMAGE='ami-xxx' # the AMI ID found on the download page
DISK='20' # the size of the hard disk
REGION='us-east-1' # the target region
TYPE='m5.large' # the instance type
SUBNET='subnet-xxx' # the subnet: `aws ec2 describe-subnets`
SECURITY_GROUPS='sg-xx' # the security group `aws ec2 describe-security-groups`
USERDATA='/path/to/config.ign' # path to your Ignition config
aws ec2 run-instances \
--region $REGION \
--image-id $IMAGE \
--instance-type $TYPE \
--key-name $SSHKEY \
--subnet-id $SUBNET \
--security-group-ids $SECURITY_GROUPS \
--user-data "file://${USERDATA}" \
--tag-specifications "ResourceType=instance,Tags=[{Key=Name,Value=${NAME}}]" \
--block-device-mappings "VirtualName=/dev/xvda,DeviceName=/dev/xvda,Ebs={VolumeSize=${DISK}}"
根据设计,FCOS不支持云初始化配置和启动脚本。相反,建议将任何启动逻辑编码为Ignition配置中的SYSTEM D服务单元。 |
在本地管理程序上引导(libvirt示例)
.
+
STREAM="stable"
# as an installed binary:
coreos-installer download -s "${STREAM}" -p qemu -f qcow2.xz --decompress -C ~/.local/share/libvirt/images/
# or as a container:
podman run --pull=always --rm -v $HOME/.local/share/libvirt/images/:/data -w /data \
quay.io/coreos/coreos-installer:release download -s "${STREAM}" -p qemu -f qcow2.xz --decompress
+
virt-install
,将Ignition文件与您的自定义设置一起使用。+
IGNITION_CONFIG="/path/to/example.ign"
IMAGE="/path/to/image.qcow2"
VM_NAME="fcos-test-01"
VCPUS="2"
RAM_MB="2048"
DISK_GB="10"
virt-install --connect="qemu:///system" --name="${VM_NAME}" --vcpus="${VCPUS}" --memory="${RAM_MB}" \
--os-variant="fedora-coreos-$STREAM" --import --graphics=none \
--disk="size=${DISK_GB},backing_store=${IMAGE}" \
--qemu-commandline="-fw_cfg name=opt/com.coreos/config,file=${IGNITION_CONFIG}"
virt-install 要求将操作系统映像和Ignition文件指定为绝对路径。
|
取决于您的版本 virt-install ,您可能无法使用 --os-variant=fedora-coreos-* 并将得到一个错误。在这种情况下,您应该选择一个较旧的Fedora变体( --os-variant=fedora31 例如)。您可以找到当前版本支持的变体 virt-install 使用 osinfo-query os | grep '^\s*fedora' 。
|
确保您的用户有权访问 /dev/kvm 。默认情况下,允许每个人访问,但在某些发行版上,您可能需要将自己添加到 kvm 一群人。
|
您可以通过按下退出串口控制台 CTRL + ] 。
|
探索操作系统
一旦VM完成引导,其IP地址将出现在串口控制台上。按照设计,没有硬编码的默认凭据。
如果您设置一个 SSH密钥 对于默认设置 core
用户,您可以通过SSH登录到虚拟机并浏览操作系统:
ssh core@<ip address>
保持联系
我们建议所有用户都订阅小批量的 CoreOS-状态邮件列表 获取与Fedora CoreOS相关的操作通知。
错误可以报告给 Fedora CoreOS追踪器 。
对于现场问题,请随时联系 #fedora-coreos
Libera.Chat上的IRC频道。