-
Notifications
You must be signed in to change notification settings - Fork 5
/
Containerfile
62 lines (55 loc) · 3.1 KB
/
Containerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# **Description:**
# > IMPORTANT NOTE: This is BOOTC. This is meant for bootable container applications. See: https://github.com/containers/podman-desktop-extension-bootc
#
# This Containerfile creates a MicroShift server on CentOS Stream 9. So you can run a Kubernetes-derivative server (OpenShift) by Red Hat. MicroShift is intended as an "Edge" version of OpenShift.
#
# **Pre-requisites:**
# * You must have a valid OpenShift Hybrid Cloud pull secret from https://console.redhat.com/openshift/install/pull-secret in order to build and use MicroShift
# * Podman Desktop installed
# * BootC extension installed for Podman Desktop (https://github.com/containers/podman-desktop-extension-bootc)
# * Public SSH key for easy access to the server
#
# **Running:**
# 1. Build the image with your SSH_PUBLIC_KEY and OPENSHIFT_PULL_SECRET arguments, either through the podman CLI or through Podman Desktop
# 2. Use bootc podman desktop extension to create an OS
# 3. Use your favourite VM tool to boot the raw file / qcow2 / etc.
# 4. SSH into the OS
# 5. Copy the kubeconfig file from `/var/lib/microshift/resources/kubeadmin/kubeconfig` to `~/.kube/config` on the remote machine.
# 6. Run `kubectl get pods -A` or `oc get pods -A` to see all the pods running.
#
# **Interacting with the server:**
#
# After following the above "Running" steps, you can now interact with the OpenShift server using `kubectl` or `oc` commands. This can also be done from your local machine if you
# copy the kubeconfig file from `/var/lib/microshift/resources/kubeadmin/kubeconfig` to `~/.kube/config` on your local machine. You may need to edit the file to change the remote server IP address.
#! RHEL 9 is the only OS supported by microshift (for now)
FROM registry.redhat.io/rhel9/rhel-bootc:9.4
#! Used for adding your SSH public key for easy access
#! Add the SSH key from SSH_PUBLIC_KEY so we can actually get the kubeconfig file
ARG SSH_PUBLIC_KEY
RUN set -eu; mkdir -p /usr/ssh && \
echo 'AuthorizedKeysFile /usr/ssh/%u.keys .ssh/authorized_keys .ssh/authorized_keys2' >> /etc/ssh/sshd_config.d/30-auth-system.conf && \
echo ${SSH_PUBLIC_KEY} > /usr/ssh/root.keys && chmod 0600 /usr/ssh/root.keys
#! Add the MicroShift repos
RUN echo -e '# OpenShift 4.17 release\n\
[ocp]\n\
name=OpenShift 4.17\n\
baseurl=https://mirror.openshift.com/pub/openshift-v4/$basearch/microshift/ocp/latest-4.17/el9/os/\n\
enabled=1\n\
gpgcheck=0\n\
\n\
# Dependencies\n\
[ocp-deps]\n\
name=OpenShift 4.17 dependencies\n\
baseurl=https://mirror.openshift.com/pub/openshift-v4/$basearch/dependencies/rpms/4.17-el9-beta/\n\
enabled=1\n\
gpgcheck=0' > /etc/yum.repos.d/minishift.repo
RUN cat /etc/yum.repos.d/minishift.repo
#! Install microshift
RUN dnf install -y microshift && systemctl enable microshift
#! Arguments are required to build this image which includes the OpenShift pull secret
#! Echo ARG OPENSHIFT_PULL_SECRET to /etc/crio/openshift-pull-secret so we can pull images from the OpenShift registry
ARG OPENSHIFT_PULL_SECRET
RUN echo $OPENSHIFT_PULL_SECRET > /etc/crio/openshift-pull-secret
RUN chmod 600 /etc/crio/openshift-pull-secret
#! REMOVE AFTER
#! RUN echo "root:root" | chpasswd