Skip to content

Instantly share code, notes, and snippets.

@danpawlik
Last active July 13, 2023 06:55
Show Gist options
  • Save danpawlik/4b28031e5d9cc9a9fcdbafd84176e4be to your computer and use it in GitHub Desktop.
Save danpawlik/4b28031e5d9cc9a9fcdbafd84176e4be to your computer and use it in GitHub Desktop.
Create CRC qcow2 image
#!/bin/bash
# Helpful link: https://crc.dev/blog/posts/2023-06-05-create-okd-bundle/
export PASS_DEVELOPER=123456789
export PASS_KUBEADMIN=123456789
export PASS_REDHAT=123456789
export OPENSHIFT_PULL_SECRET_PATH=${OPENSHIFT_PULL_SECRET_PATH:-''}
# export BUNDLED_PULL_SECRET_PATH=${BUNDLED_PULL_SECRET_PATH:-$OPENSHIFT_PULL_SECRET_PATH}
# https://origin-release.apps.ci.l2s4.p1.openshiftapps.com/ and https://github.com/okd-project/okd/releases/
export OKD_VERSION=4.12.0-0.okd-2023-04-16-041331
export DOMAIN="crc.testing"
if [ -z "$OPENSHIFT_PULL_SECRET_PATH" ]; then
echo "Please export OPENSHIFT_PULL_SECRET_PATH"
exit 1
fi
# https://github.com/openshift/installer/blob/master/docs/dev/dependencies.md
sudo dnf install -y golang-bin gcc-c++ git vim
# https://github.com/openshift/installer/blob/master/docs/dev/libvirt/README.md#one-time-setup
sudo yum install -y libvirt-daemon-kvm libvirt-client libvirt-daemon
echo "net.ipv4.ip_forward = 1" | sudo tee /etc/sysctl.d/99-ipforward.conf
sudo sysctl -p /etc/sysctl.d/99-ipforward.conf
# should be 1
sysctl net.ipv4.ip_forward
cat << 'EOF' | sudo tee -a /etc/libvirt/libvirtd.conf
listen_tls = 0
listen_tcp = 1
auth_tcp = "none"
tcp_port = "16509"
listen_addr = "0.0.0.0"
EOF
sudo systemctl stop libvirtd
sudo systemctl disable libvirtd
sudo systemctl start libvirtd-tcp.socket
sudo systemctl enable libvirtd-tcp.socket
# the CRC will be running on that ip address
echo -e "[main]\ndns=dnsmasq" | sudo tee /etc/NetworkManager/conf.d/openshift.conf
echo server=/$DOMAIN/192.168.126.1 | sudo tee /etc/NetworkManager/dnsmasq.d/openshift.conf
# sudo iptables -I INPUT -p tcp -s 192.168.126.0/24 -d 192.168.122.1 --dport 16509 -j ACCEPT -m comment --comment "Allow insecure libvirt clients"
# sudo firewall-cmd --zone=dmz --change-interface=tt0
# sudo firewall-cmd --zone=dmz --add-service=libvirt
# sudo firewall-cmd --zone=dmz --add-service=dns
# sudo firewall-cmd --zone=dmz --add-service=dhcp
sudo systemctl reload NetworkManager
if grep -q '#options kvm_intel nested=1' /etc/modprobe.d/kvm.conf && grep -q '#options kvm_amd nested=1' /etc/modprobe.d/kvm.conf; then
echo -e "Nested virt is not enabled! Run command on Intel CPU: \n\nsudo sed -i 's/#options kvm_intel nested=1/options kvm_intel nested=1/g' /etc/modprobe.d/kvm.conf"
echo -e "\n\n or run below on AMD CPU \n\n sudo sed -i 's/#options kvm_amd nested=1/options kvm_amd nested=1/g' /etc/modprobe.d/kvm.conf"
echo -e "\n\nDO NOT FORGET TO REBOOT HOST!"
exit 1
fi
git clone https://github.com/crc-org/snc && cd snc
git checkout origin/release-4.12
./snc.sh
./createdisk.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment