Provisionando o Fedora CoreOS na IBM Cloud

This guide shows how to provision new Fedora CoreOS (FCOS) instances in IBM Cloud VPC Generation 2 for either the x86_64 or s390x architectures.

Pré-Requisitos

Antes de provisionar uma máquina FCOS, você deve ter um arquivo de configuração do Ignition contendo suas personalizações. Se você não tiver um, consulte Produzindo um arquivo de Ignition.

Fedora CoreOS has a default core user that can be used to explore the OS. If you want to use it, finalize its configuration by providing e.g. an SSH key.

If you do not want to use Ignition to get started, you can make use of the Afterburn support.

You also need to have access to an IBM Cloud account. The examples below use the ibmcloud command-line tool, which must be separately installed and configured beforehand. Folow the directions at https://cloud.ibm.com/docs/cli?topic=cli-install-ibmcloud-cli to install the ibmcloud CLI. You’ll need both the cloud-object-storage and infrastructure-service plugins installed. This can be done with:

  • ibmcloud plugin install cloud-object-storage

  • ibmcloud plugin install infrastructure-service

Depois de logar usando ibmcloud login, você pode colocar uma região alvo:

Escolha uma região específica
REGION='us-east' #rode `ibmcloud regions` para ver opções
ibmcloud target -r $REGION
Target a specific resource group
RESOURCE_GROUP='my-resource-group'
ibmcloud resource group-create $RESOURCE_GROUP # Create the resource group if it doesn't exist
ibmcloud target -g $RESOURCE_GROUP

There are also several other pieces that need to be in place, like a VPC, SSH keys, networks, permissions, etc. Unfortunately, this guide is not a comprehensive IBM Cloud guide. If you are new to IBM Cloud please familiarize yourself using the documentation for VPC Gen2 first.

Criando uma imagem

Os seguintes conjuntos de comandos vão mostrar para você como fazer o download da imagem mais recentes para um fluxo, realizar um upload para o armazenamento em nuvem, e então criar a imagem em nuvem na IBM Cloud. Vale a pena notar que o Fedora CoreOS vem em três fluxos, com diferentes rotinas de atualizações por fluxo. Esses passos mostram o fluxo stable como exemplo, mas pode ser usado para outros fluxos também.

Obtenha a imagem mais recente adequada para o seu fluxo alvo (ou baixe e verifique na web).
STREAM='stable'
ARCH='x86_64' # or 's390x'
coreos-installer download -s $STREAM -a $ARCH -p ibmcloud -f qcow2.xz --decompress
Crie uma conta de serviço para realizar uploads e uma Política de Autorização que permitem criar imagens para os objetos que sofreram upload.
BUCKET='my-unique-bucket'
ibmcloud resource service-instance-create "${BUCKET}-service-instance" cloud-object-storage standard global

SERVICE_INSTANCE_ID='25df0db0-89a4-4cb8-900f-ed8b44259f80' # from just created service account
ibmcloud iam authorization-policy-create is --source-resource-type image cloud-object-storage Reader --target-service-instance-id $SERVICE_INSTANCE_ID
Realize o upload da imagem obtida para o armazenamento de objeto da IBM Cloud.
FCOS_VERSION='...'
FILE="fedora-coreos-${FCOS_VERSION}-ibmcloud.${ARCH}.qcow2"
ibmcloud cos create-bucket --bucket $BUCKET --ibm-service-instance-id $SERVICE_INSTANCE_ID
ibmcloud cos upload --bucket=$BUCKET --key=$FILE --file=$FILE
Crie uma imagem pelo objeto de armazenamento.
IMAGE=${FILE:0:-6}     # pull off .qcow2
IMAGE=${IMAGE//[._]/-} # replace . and _ with -
[ $ARCH == 'x86_64' ] && OSNAME='fedora-coreos-stable-amd64'
[ $ARCH == 's390x' ] && OSNAME='red-8-s390x-byol'
ibmcloud is image-create $IMAGE --file "cos://${REGION}/${BUCKET}/${FILE}" --os-name $OSNAME
For s390x we use --os-name=red-8-s390x-byol (a RHEL 8 profile) here because there is not currently a fedora-coreos-stable-s390x profile to use.

Você terá que esperar o processo de criação da imagem terminar de pending para available antes que você consiga usar a imagem. Monitore com o seguinte comando:

Monitore o processo de criação de imagens vendo as imagens na sua conta
ibmcloud is images --visibility private

Lançando uma instância de VM

Agora que você tem uma imagem criada na sua conta você pode lançar uma instância de VM. Você terá que especificar várias informações no comando. Dicas estão embutidas no exemplo abaixo sobre como conseguir essas informações antes de lançar uma instância.

You’ll also need the Ignition config you created earlier. Here it is represented in the example command as @example.ign, which indicates a file in the current directory named example.ign. The @ is required before the path to the ignition file.

Lançando uma instância de VM
NAME='instance1'
ZONE="${REGION}-1" # view more with `ibmcloud is zones`
PROFILE='bx2-2x8' # view more with `ibmcloud is instance-profiles`
VPC='r014-c9c65cc4-cfd3-44de-ad54-865aac182ea1'    # `ibmcloud is vpcs`
IMAGE='r014-1823b4cf-9c63-499e-8a27-b771be714ad8'  # `ibmcloud is images --visibility private`
SUBNET='0777-bf99cbf4-bc82-4c46-895a-5b7304201182' # `ibmcloud is subnets`
SSHKEY='r014-b44c37d0-5c21-4c2b-aba2-438a5b0a228d' # `ibmcloud is keys`
ibmcloud is instance-create $NAME $VPC $ZONE $PROFILE $SUBNET --image $IMAGE --keys $SSHKEY --user-data @example.ign
Se necessário você deverá criar primeiro uma subnet com um comando como 'ibmcloud is subnet-create my-subnet $VPC --ipv4-address-count 256 --zone $ZONE'.
Make sure you choose an appropriate instance type based on your architecture. For example, you may want to use bz2-2x8 instead of bx2-2x8 above if you are targetting s390x.

Próximo, se você gostaria de realizar um acesso SSH para a instância por fora da IBM Cloud, você pode assinalar um IP Público para a instância:

Crie e assinale um IP flutuante
ibmcloud is floating-ip-reserve floating-ip-1 --zone=$ZONE
FIP='72251a2e-d6c5-42b4-97b0-b5f8e8d1f479'
NIC='0777-dd174c80-dbd9-41b1-b221-39bbcef8a481' # find from `ibmcloud is instance` output
ibmcloud is floating-ip-update $FIP --nic $NIC

Agora você deve conseguir acessar a instância por SSH usando o endereço IP associado com o IP flutuante.

Example connecting
ssh core@<ip address>