diff --git a/99_master-create-users-symlink.yaml b/99_master-create-users-symlink.yaml deleted file mode 100644 index afe2d053..00000000 --- a/99_master-create-users-symlink.yaml +++ /dev/null @@ -1,60 +0,0 @@ -apiVersion: machineconfiguration.openshift.io/v1 -kind: MachineConfig -metadata: - labels: - machineconfiguration.openshift.io/role: master - name: 99-openshift-machineconfig-master-users-symlink -spec: - config: - ignition: - version: 3.4.0 - systemd: - units: - - contents: | - [Unit] - Description=Allow systemd to create mount points on / - DefaultDependencies=no - Before=remote-fs.target - - [Service] - Type=oneshot - ExecStart=chattr -i / - - [Install] - WantedBy=remote-fs.target - enabled: true - name: immutable-root-off.service - - contents: | - [Unit] - Description=Set / back to immutable after mounts are done - DefaultDependencies=no - After=remote-fs.target - - [Service] - Type=oneshot - ExecStart=chattr +i / - - [Install] - WantedBy=remote-fs.target - enabled: true - name: immutable-root-on.service - - contents: | - [Unit] - Description=Create Users directory and mount to var - After=immutable-root-off.service - Before=immutable-root-on.service - - [Service] - Type=oneshot - ExecStartPre=rm -f /Users - ExecStartPre=mkdir -p /var/Users - ExecStart=ln -sf /var/Users /Users - - [Install] - WantedBy=multi-user.target - enabled: true - name: create-symlink-users.service - networkd: {} - passwd: {} - storage: {} - osImageURL: "" diff --git a/snc.sh b/snc.sh index 10576eda..6547719f 100755 --- a/snc.sh +++ b/snc.sh @@ -147,10 +147,6 @@ cp cluster-network-03-config.yaml ${INSTALL_DIR}/manifests/ cp 99_master-chronyd-mask.yaml $INSTALL_DIR/openshift/ # Add dummy network unit file cp 99-openshift-machineconfig-master-dummy-networks.yaml $INSTALL_DIR/openshift/ -# Add unit file for creating /Users and symlink it to /var/Users -# It is used for mounting shared directory on Mac -# https://github.com/coreos/rpm-ostree/issues/337 -cp 99_master-create-users-symlink.yaml $INSTALL_DIR/openshift/ # Add kubelet config resource to make change in kubelet DYNAMIC_DATA=$(base64 -w0 node-sizing-enabled.env) envsubst < 99_master-node-sizing-enabled-env.yaml.in > $INSTALL_DIR/openshift/99_master-node-sizing-enabled-env.yaml # Add codeReadyContainer as invoker to identify it with telemeter @@ -245,6 +241,39 @@ retry ${OC} delete mc chronyd-mask # Wait for the cluster again to become stable because of all the patches/changes wait_till_cluster_stable +# This section is used to create a custom-os image which have `/Users` +# For more details check https://github.com/crc-org/snc/issues/1041#issuecomment-2785928976 +# This should be performed before removing pull secret +# Unsetting KUBECONFIG is required because it has default `system:admin` user which doesn't able to create +# token to login to registry and kubeadmin user is required for that. +unset KUBECONFIG +RHCOS_IMAGE=$(${OC} adm release info -a ${OPENSHIFT_PULL_SECRET_PATH} ${OPENSHIFT_INSTALL_RELEASE_IMAGE_OVERRIDE} --image-for=rhel-coreos) +cat << EOF > ${INSTALL_DIR}/Containerfile +FROM scratch +RUN ln -sf var/Users /Users && mkdir /var/Users +EOF +podman build --from ${RHCOS_IMAGE} --authfile ${OPENSHIFT_PULL_SECRET_PATH} -t default-route-openshift-image-registry.apps-crc.testing/openshift-machine-config-operator/rhcos:latest --file ${INSTALL_DIR}/Containerfile . +retry ${OC} login -u kubeadmin -p $(cat ${INSTALL_DIR}/auth/kubeadmin-password) --insecure-skip-tls-verify=true api.${SNC_PRODUCT_NAME}.${BASE_DOMAIN}:6443 +retry ${OC} registry login -a ${INSTALL_DIR}/reg.json +podman push --authfile ${INSTALL_DIR}/reg.json --tls-verify=false default-route-openshift-image-registry.apps-crc.testing/openshift-machine-config-operator/rhcos:latest +cat << EOF > ${INSTALL_DIR}/custom-os-mc.yaml +apiVersion: machineconfiguration.openshift.io/v1 +kind: MachineConfig +metadata: + labels: + machineconfiguration.openshift.io/role: master + name: custom-image +spec: + osImageURL: image-registry.openshift-image-registry.svc:5000/openshift-machine-config-operator/rhcos:latest +EOF +retry ${OC} apply -f ${INSTALL_DIR}/custom-os-mc.yaml +sleep 60 +# Wait till machine config pool is updated correctly +while retry ${OC} get mcp master -ojsonpath='{.status.conditions[?(@.type!="Updated")].status}' | grep True; do + echo "Machine config still in updating/degrading state" +done + +export KUBECONFIG=${INSTALL_DIR}/auth/kubeconfig mc_before_removing_pullsecret=$(retry ${OC} get mc --sort-by=.metadata.creationTimestamp --no-headers -oname) # Replace pull secret with a null json string '{}' retry ${OC} replace -f pull-secret.yaml @@ -277,3 +306,5 @@ ${SSH} core@api.${SNC_PRODUCT_NAME}.${BASE_DOMAIN} -- 'sudo crictl rmi --prune' # Remove the baremetal_runtimecfg container which is temp created ${SSH} core@api.${SNC_PRODUCT_NAME}.${BASE_DOMAIN} -- "sudo podman rm baremetal_runtimecfg" + +