Aprovisionando Fedora CoreOS sobre IBM Cloud

Esta guía le muestra como aprovisionar instancias nuevas de Fedora CoreOS (FCOS) en IBM Cloud para las arquitecturas o bien x86_64 o bien s390x.

FCOS no es compatible con IBM Cloud Classic Infrastructure.

Pre-requisitos

Antes de aprovisionar una máquina FCOS, usted debe tener un fichero de configuración Ignition que contenga sus personalizaciones. Si no tiene uno vea Produciendo un Fichero Ignition.

Fedora CoreOS tiene un usuario core predeterminado que puede ser usado para explorar el SO. Si usted desea utilizarlo finalice su configuración proporcionando una clave SSH.

Si no desea usar Ignition para empezar, puede usar Soporte Afterburn.

También necesita tener acceso a una Cuenta IBM Cloud. El ejemplo de abajo utiliza la herramienta de línea de comando ibmcloud, que debe instalarse y configurarse por separado de antemano. Siga las instrucciones en https://cloud.ibm.com/docs/cli?topic=cli-install-ibmcloud-cli para instalar la CLI de ibmcloud. Necesitará tener instalados los complementos cloud-object-storage e infrastructure-service. Esto se puede hacer con:

  • ibmcloud plugin install cloud-object-storage

  • ibmcloud plugin install infrastructure-service

After you’ve logged in using ibmcloud login you can set a target region:

Target a specific region
REGION='us-east' # run `ibmcloud regions` to view options
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

Hay otras diversas cosas que es necesario hacer en lugar, como una VPC, claves SSH, redes, permisos, etc. Desafortunadamente esta guía no es una guía IBM Cloud completa. Si es nuevo en IBM Cloud primero familiarícese con ella usando la documentación para IBM Cloud VPC networks.

Creating an Image

The following sets of commands will show you how to download the most recent image for a stream, upload it to cloud storage, and then create the cloud image in IBM Cloud. It is worth noting that Fedora CoreOS comes in three streams, with different update schedules per stream. These steps show the stable stream as an example, but can be used for other streams too.

Obtenga la última imagen adecuada para su flujo objetivo (o descárguela y verifíquela desde la red).
STREAM='stable'
ARCH='x86_64' # or 's390x'
coreos-installer download -s $STREAM -a $ARCH -p ibmcloud -f qcow2.xz --decompress
Create a Service Account for uploading and an Authorization Policy to allow creating images from the uploaded objects.
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
Upload the fetched image file to IBM Cloud Object Storage.
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}"
Create the image from the storage object.
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.

You’ll have to wait for the image creation process to finish and go from pending to available before you can use the image. Monitor with the following command:

Monitor image creation progress by viewing the images in your account
ibmcloud is images --visibility private --status pending,available

Lanzar una instancia de Máquina Virtual

Now that you have an image created in your account you can launch a VM instance. You’ll have to specify several pieces of information in the command. Embedded in the example below are tips for how to grab that information before launching an instance.

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.

Lanzar una instancia de Máquina Virtual
INSTANCE_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 $INSTANCE_NAME $VPC $ZONE $PROFILE $SUBNET \
   --allow-ip-spoofing=true --image $IMAGE --keys $SSHKEY --user-data @example.ign
If needed you may have to first create a subnet with a command like 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 targeting s390x.

Next, if you’d like to SSH into the instance from outside IBM Cloud, you can assign a public IP to the instance:

Crear y Asignar una IP Flotante
FIP_NAME='floating-ip-1'
ibmcloud is floating-ip-reserve $FIP_NAME --zone=$ZONE
VNIC=$(ibmcloud is instance $INSTANCE_NAME --output json |
       jq --raw-output .primary_network_attachment.virtual_network_interface.id)
ibmcloud is virtual-network-interface-floating-ip-add $VNIC $FIP_NAME

And you now should be able to SSH into the instance using the IP address associated with the floating IP.

Ejemplo al conectar
ssh core@<dirección ip>