|
33 | 33 | # https://github.com/CentOS/centos-bootc/issues/393 |
34 | 34 | mkdir -p /var/opt |
35 | 35 |
|
36 | | -# this is where all the real work happens |
37 | | -rpm-ostree experimental compose treefile-apply \ |
38 | | - --var "osversion=${ID}-${VERSION_ID}" /run/src/packages-openshift.yaml |
| 36 | +# Install the OCP packages. Repos have been configured above. |
| 37 | +rpm-ostree install \ |
| 38 | + cri-o cri-tools conmon-rs \ |
| 39 | + openshift-clients openshift-kubelet \ |
| 40 | + openvswitch3.5 \ |
| 41 | + NetworkManager-ovs \ |
| 42 | + ose-aws-ecr-image-credential-provider \ |
| 43 | + ose-azure-acr-image-credential-provider \ |
| 44 | + ose-gcp-gcr-image-credential-provider \ |
| 45 | + ose-crio-credential-provider |
| 46 | + |
| 47 | +# --- postprocess steps --- |
| 48 | +# These were previously in the `postprocess` section of packages-openshift.yaml. |
| 49 | + |
| 50 | +# Disable any built-in repos. We need to work in disconnected environments by |
| 51 | +# default, and default-enabled repos will be attempted to be fetched by |
| 52 | +# rpm-ostree when doing node-local kernel overrides today for e.g. kernel-rt. |
| 53 | +mkdir -p /etc/yum.repos.d |
| 54 | +for x in $(find /etc/yum.repos.d/ -name '*.repo'); do |
| 55 | + # ignore repo files that are mountpoints since they're likely secrets |
| 56 | + if ! mountpoint "$x"; then |
| 57 | + sed -i -e 's/enabled\s*=\s*1/enabled=0/g' "$x" |
| 58 | + fi |
| 59 | +done |
| 60 | + |
| 61 | +# Enable librhsm which enables host subscriptions to work in containers |
| 62 | +# https://github.com/rpm-software-management/librhsm/blob/fcd972cbe7c8a3907ba9f091cd082b1090231492/rhsm/rhsm-context.c#L30 |
| 63 | +ln -sr /run/secrets/etc-pki-entitlement /etc/pki/entitlement-host |
| 64 | +ln -sr /run/secrets/rhsm /etc/rhsm-host |
| 65 | + |
| 66 | +# Manually modify SELinux booleans that are needed for OCP use cases |
| 67 | +semanage boolean --modify --on container_use_cephfs # RHBZ#1694045 |
| 68 | +semanage boolean --modify --on virt_use_samba # RHBZ#1754825 |
| 69 | + |
| 70 | +# https://gitlab.cee.redhat.com/coreos/redhat-coreos/merge_requests/812 |
| 71 | +# https://bugzilla.redhat.com/show_bug.cgi?id=1796537 |
| 72 | +mkdir -p /usr/share/containers/oci/hooks.d |
| 73 | + |
| 74 | +# crio conmon symlink |
| 75 | +mkdir -p /usr/libexec/crio |
| 76 | +ln -sr /usr/bin/conmon /usr/libexec/crio/conmon |
| 77 | + |
| 78 | +# Inject OpenShift-specific release fields |
| 79 | +cat >> /usr/lib/os-release <<EOF |
| 80 | +OPENSHIFT_VERSION="5.0" |
| 81 | +EOF |
| 82 | + |
| 83 | +# Generate MOTD |
| 84 | +. /etc/os-release |
| 85 | +# Detect variant based on the Containerfile metadata. In the absence of |
| 86 | +# rpm-ostree treefile metadata, we use a heuristic: centos-10 builds are SCOS. |
| 87 | +if [ "$ID" = "centos" ] && [ "$VERSION_ID" = "10" ]; then |
| 88 | + colloquial_name=SCOS |
| 89 | + project_name=OKD |
| 90 | +else |
| 91 | + colloquial_name=RHCOS |
| 92 | + project_name=OpenShift |
| 93 | +fi |
| 94 | +# in the el-only variants, we already have CoreOS in the NAME, so don't |
| 95 | +# re-add it when building the node image |
| 96 | +if [[ $NAME != *CoreOS* ]]; then |
| 97 | + NAME="$NAME CoreOS" |
| 98 | +fi |
| 99 | +cat > /etc/motd <<EOF |
| 100 | +$NAME $OSTREE_VERSION |
| 101 | + Part of ${project_name} ${OPENSHIFT_VERSION}, ${colloquial_name} is a Kubernetes-native operating system |
| 102 | + managed by the Machine Config Operator (\`clusteroperator/machine-config\`). |
| 103 | +
|
| 104 | +WARNING: Direct SSH access to machines is not recommended; instead, |
| 105 | +make configuration changes via \`machineconfig\` objects: |
| 106 | + https://docs.openshift.com/container-platform/${OPENSHIFT_VERSION}/architecture/architecture-rhcos.html |
| 107 | +
|
| 108 | +--- |
| 109 | +EOF |
| 110 | + |
| 111 | +# Delete leftover files in the layering path |
| 112 | +if [ -f /run/.containerenv ]; then |
| 113 | + # lockfiles and backup files |
| 114 | + rm -f /etc/.pwd.lock /etc/group- /etc/gshadow- /etc/shadow- /etc/passwd- |
| 115 | + rm -f /etc/selinux/targeted/*.LOCK |
| 116 | + # cache, logs, etc... |
| 117 | + rm -rf /var && mkdir /var |
| 118 | + # All the entries here should instead be part of their respective |
| 119 | + # packages. But we carry them here for now to maintain compatibility. |
| 120 | + cat > /usr/lib/tmpfiles.d/openshift.conf << EOF |
| 121 | +L /opt/cni - - - - ../../usr/lib/opt/cni |
| 122 | +d /var/lib/cni 0755 root root - - |
| 123 | +d /var/lib/cni/bin 0755 root root - - |
| 124 | +d /var/lib/containers 0755 root root - - |
| 125 | +d /var/lib/openvswitch 0755 root root - - |
| 126 | +d /var/lib/openvswitch/pki 0755 root root - - |
| 127 | +d /var/log/openvswitch 0750 openvswitch hugetlbfs - - |
| 128 | +d /var/lib/unbound 0755 unbound unbound - - |
| 129 | +EOF |
| 130 | +fi |
| 131 | + |
| 132 | +# --- end postprocess steps --- |
39 | 133 |
|
40 | 134 | # cleanup any repo files we injected |
41 | 135 | rm -f /etc/yum.repos.d/{ocp,git,okd}.repo |
|
0 commit comments