Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better way to set the image mode versions #601

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions image-mode-basics/01-create-an-image/assignment.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,17 @@ tabs:
path: Containerfile
difficulty: basic
timelimit: 3000
enhanced_loading: null
---

Welcome to this lab experience for Red Hat Enterprise Linux.

The system displayed beside this text is a Red Hat Enterprise Linux 9
system registered with Subscription Manager.
The system displayed beside this text is a Red Hat Enterprise Linux 9 system registered with Subscription Manager.

Image mode uses standard container tools to define, build, and transport bootc images. Podman has already been installed on this host as a build environment, along with some additional files.
Image mode uses standard container tools to define, build, and transport bootc images. Podman has already been installed on this host as a build environment, along with some additional files and required images. If you see an error related to authentication like the one below, you can use the `reglogin` command provided to log into the Red Hat Container Registry and re-run the command.
```
unable to retrieve auth token: invalid username/password: unauthorized: Please login to the Red Hat Registry using your Customer Portal credentials.
```

Examine the containerfile
===
Expand Down
13 changes: 7 additions & 6 deletions image-mode-basics/02-deploy-an-image/assignment.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ tabs:
title: VM console
type: terminal
hostname: rhel
cmd: virsh console bootc
cmd: virsh console bootc-vm
difficulty: basic
timelimit: 1
enhanced_loading: null
---
Launch bootc-image-builder
===
Expand All @@ -41,7 +42,7 @@ There are several ways to deploy a bootc image to a host, depending on the targe
podman run --rm --privileged \
--volume .:/output \
--volume ./config.json:/config.json \
registry.redhat.io/rhel9/bootc-image-builder:latest \
registry.redhat.io/rhel9/bootc-image-builder:[[ Instruqt-Var key="BOOTC_RHEL_VERSION" hostname="rhel" ]] \
--type qcow2 \
--config config.json \
[[ Instruqt-Var key="CONTAINER_REGISTRY_ENDPOINT" hostname="rhel" ]]/test-bootc
Expand All @@ -55,14 +56,14 @@ Prepare and run the bootc image
To launch a KVM guest, copy the QCOW2 disk image we created to the default libvirt storage pool.

```bash,run
cp qcow2/disk.qcow2 /var/lib/libvirt/images/bootc-vm.qcow2
cp qcow2/disk.qcow2 /var/lib/libvirt/images/bootc[[ Instruqt-Var key="BOOTC_RHEL_VERSION" hostname="rhel" ]]-vm.qcow2
```

Using `virt-install` we can define a simple VM and import the new disk image.

```bash,run
virt-install --name bootc \
--disk /var/lib/libvirt/images/bootc-vm.qcow2 \
virt-install --name bootc-vm \
--disk /var/lib/libvirt/images/bootc[[ Instruqt-Var key="BOOTC_RHEL_VERSION" hostname="rhel" ]]-vm.qcow2 \
--import \
--memory 2048 \
--graphics none \
Expand All @@ -74,7 +75,7 @@ virt-install --name bootc \
Once the VM has been defined, we can start it.

```bash,run
virsh start bootc
virsh start bootc-vm
```

Attach to the console of the VM running our bootc image
Expand Down
8 changes: 2 additions & 6 deletions image-mode-basics/03-add-software-to-image/assignment.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,9 @@ tabs:
type: code
hostname: rhel
path: Containerfile
- id: knueqzeeypop
title: VM console
type: terminal
hostname: rhel
cmd: virsh console bootc
difficulty: basic
timelimit: 600
enhanced_loading: null
---

Click on the [button label="Containerfile" background="#ee0000" color="#c7c7c7"](tab-1) tab.
Expand Down Expand Up @@ -65,4 +61,4 @@ Once the updated image has been built, we can push it to the registry. Once agai
podman push [[ Instruqt-Var key="CONTAINER_REGISTRY_ENDPOINT" hostname="rhel" ]]/test-bootc
```

In the next step, we'll look at how to update a running system from the new image we just pushed to the registry.
In the next step, we'll look at how to update a running system from the new image we just pushed to the registry.
12 changes: 4 additions & 8 deletions image-mode-basics/04-apply-image/assignment.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,13 @@ tabs:
title: Terminal
type: terminal
hostname: rhel
- id: pzj6sgp9ncuu
title: Containerfile
type: code
hostname: rhel
path: Containerfile
- id: yr6lhrue8afd
title: VM console
type: terminal
hostname: rhel
cmd: virsh console bootc
cmd: virsh console bootc-vm
difficulty: ""
enhanced_loading: null
---
Exploring system status
===
Expand All @@ -41,7 +37,7 @@ The `bootc` command is what controls the state of the running host and the avail

The `spec` section provides the information about the image in use and where `bootc` is looking for it. Our host is pulling from a container registry.
```bash,run
sudo bootc status | grep spec: -A 10
sudo bootc status | grep spec: -A 4
```

The `staged` section provides information about what's been pulled down to disk for the next boot. Since we just did a fresh install, this is null at the moment.
Expand Down Expand Up @@ -129,4 +125,4 @@ Here's what you should see as output.

![](../assets/test_httpd_vim.png)

You've now created a new image mode system from a Containerfile and seen how to manage updates for the system. This should provide a good basis to explore image mode for RHEL with your own standard builds and applications. In later labs, we'll explore some of the other available life cycle options like `rollback` and `switch`.
You've now created a new image mode system from a Containerfile and seen how to manage updates for the system. This should provide a good basis to explore image mode for RHEL with your own standard builds and applications. In later labs, we'll explore some of the other available life cycle options like `rollback` and `switch`.
7 changes: 3 additions & 4 deletions image-mode-basics/track.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@ developers:
- [email protected]
show_timer: true
lab_config:
overlay: false
width: 33
position: right
feedback_recap_enabled: true
feedback_tab_enabled: false
loadingMessages: true
theme:
name: original
override_challenge_layout: false
hideStopButton: false
default_layout: AssignmentRight
default_layout_sidebar_size: 33
checksum: "760900542313485442"
checksum: "9483646692229430784"
enhanced_loading: false
9 changes: 6 additions & 3 deletions image-mode-basics/track_scripts/setup-rhel
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
#!/bin/bash
set -euxo pipefail

subscription-manager config --rhsm.manage_repos=1
subscription-manager register --activationkey=${ACTIVATION_KEY} --org=12451665 --force

# Log into terms based registry and stage bootc and bib images
BOOTC_RHEL_VER=9.4
agent variable set BOOTC_RHEL_VERSION $BOOTC_RHEL_VER
podman login -u='1979710|rhel-tmm' -p=${REG_SVC_ACCT} registry.redhat.io
podman pull registry.redhat.io/rhel9/rhel-bootc:latest registry.redhat.io/rhel9/bootc-image-builder:latest
podman pull registry.redhat.io/rhel9/rhel-bootc:$BOOTC_RHEL_VER registry.redhat.io/rhel9/bootc-image-builder:$BOOTC_RHEL_VER

# Some shortcuts for users
# reglogin - uses podman secret to log into the terms based registry in case creds time out or initial pull fails
Expand All @@ -28,7 +31,7 @@ dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarc
dnf install -y certbot

# stop the process that is using TCP port 80; we need that port open for certbot
fuser -k 80/tcp
# fuser -k 80/tcp

# request certificates
certbot certonly --standalone --preferred-challenges http -d ${HOSTNAME}.${INSTRUQT_PARTICIPANT_ID}.instruqt.io --non-interactive --agree-tos -m [email protected] -v
Expand Down Expand Up @@ -159,7 +162,7 @@ EOF

# create basic bootc containerfile
cat <<EOF> Containerfile
FROM registry.redhat.io/rhel9/rhel-bootc
FROM registry.redhat.io/rhel9/rhel-bootc:$BOOTC_RHEL_VER

ADD etc /etc

Expand Down
6 changes: 3 additions & 3 deletions image-mode-day2/02-switch-an-image/assignment.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ enhanced_loading: null
A word about tags
===

To this point, we've been letting podman automatically create tags for the images we've built. As a review, the naming convention for container images is `registry/name:tag`. We've been setting the registry and name in the command line, which means all of the tags are set to `latest` by default.
To this point, we've been letting podman automatically create tags for the images we've built. As a review, the naming convention for container images is `registry/name:tag`.

If you look at all of the images available in the lab, you'll see most of them have `latest` in the tag column. The `docker.io/library/registry` image is the only one that has a unique tag that tries to convey some information via it's tag.
If you look at all of the images available in the lab, you'll see most of them have a version number in the tag column. The image we've built is the only one that uses `latest`, which signals the most recent build and is auto-generated if you don't specify a tag.

```bash,run
podman images
```

While this is convenient, it can create a lot of confusion. Which `latest` was really created last? What in that `latest` container? Which updates did we provide? Have you seen the `latest` tag in any of the `bootc status` output so far?
While this is convenient, it can create a lot of confusion. What in that `latest` container? Which updates did we provide? Have you seen the `latest` tag in any of the `bootc status` output so far?


Using tags for identifying image contents
Expand Down
5 changes: 0 additions & 5 deletions image-mode-day2/03-rollback-a-host/assignment.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ tabs:
title: Terminal
type: terminal
hostname: rhel
- id: tpkjptwwk0eu
title: Containerfile
type: code
hostname: rhel
path: Containerfile
- id: fzmfm00uw2yp
title: VM console
type: terminal
Expand Down
2 changes: 1 addition & 1 deletion image-mode-day2/track.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ lab_config:
hideStopButton: false
default_layout: AssignmentRight
default_layout_sidebar_size: 33
checksum: "9200472003432348126"
checksum: "3198179653936879206"
enhanced_loading: false
9 changes: 6 additions & 3 deletions image-mode-day2/track_scripts/setup-rhel
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ subscription-manager config --rhsm.manage_repos=1
subscription-manager register --activationkey=${ACTIVATION_KEY} --org=12451665 --force

# Log into terms based registry and stage bootc and bib images
BOOTC_RHEL_VER=9.4
agent variable set BOOTC_RHEL_VERSION $BOOTC_RHEL_VER

podman login -u='1979710|rhel-tmm' -p=${REG_SVC_ACCT} registry.redhat.io
podman pull registry.redhat.io/rhel9/rhel-bootc:latest registry.redhat.io/rhel9/bootc-image-builder:latest
podman pull registry.redhat.io/rhel9/rhel-bootc:$BOOTC_RHEL_VER registry.redhat.io/rhel9/bootc-image-builder:$BOOTC_RHEL_VER

# Some shortcuts for users
# reglogin - uses podman secret to log into the terms based registry in case creds time out or initial pull fails
Expand Down Expand Up @@ -83,7 +86,7 @@ EOF

# create updated bootc containerfile from image-mode-basics
cat <<EOF> Containerfile
FROM registry.redhat.io/rhel9/rhel-bootc
FROM registry.redhat.io/rhel9/rhel-bootc:$BOOTC_RHEL_VER

ADD etc /etc

Expand All @@ -94,7 +97,7 @@ EOF

# create V3 index.html relocated containerfile
cat <<EOM> Containerfile.index
FROM registry.redhat.io/rhel9/rhel-bootc
FROM registry.redhat.io/rhel9/rhel-bootc:$BOOTC_RHEL_VER

ADD etc /etc

Expand Down