Setup Domjudge with Openshift Origin 3.11
See my blog for full explanation.
Having at least 5 hosts: 1 openshift master node, 1 openshift infra node with DNS, and 3 or more openshift compute nodes for judges. Use 1 of the computers listed above or any other computer that is connected to all hosts as the main system. The main system will be controlling all the hosts and setup their environment.
- Fedora/Centos/RHEL(Any Red Hat based distro with SELinux Enabled)
- All hosts meet the requirements of Ansible
- Ansible installed on your main system
- SSH server enabled and accepting interactive challenge on all openshift hosts
- All hosts connected via internet
- All hosts have an user with the same username
git clone --recurse-submodules -j8 https://github.com/Superdanby/Openshift-Ansible-Domjudge.git
Set DNS record for hosts in tasks/files/hosts_domjudge
.
- In
inventory
:- Set the user in the line:
ansible_user='[username]'
- Set host mappings in
inventory
. Make sure the mappings are consistent with those oftasks/files/hosts_domjudge
- Make sure
ansible_python_interpreter='[path to python3]'
is present under[all:vars]
if your distro usespython3
instead ofpython2
- Set the user in the line:
- Create an ansible vault with
ansible-vault create [path to vault file]
and writepass: [password for the user on all hosts]
- In
openshift_install_config/hosts.domjudge
:- Set host mappings in
inventory
. Make sure the mappings are consistent with those ofinventory
- Change the line:
openshift_pkg_version=-[3.11.1]
to match the version number of the Openshift packages provided by your distro- On Fedora, you can check the version with
dnf info origin
- On Fedora, you can check the version with
- If your hosts don't meet the minimum hardware requirements of Openshift, disable the corresponding checks in the end of the file with these options
- Set host mappings in
- Go to
origin
andgit checkout release-3.11
deploy_config
:domserver
: setnodeName
to the FQDN of 1 of the compute nodes, set the mariadb credentialsmariadb
: setnodeName
to the FQDN of 1 of the compute nodes, set the mariadb credentials, set persistent volumejudge-with-init
: setJUDGEDAEMON_PASSWORD
, setmemory
judge-with-init-core-unbound
: setJUDGEDAEMON_PASSWORD
, setmemory
services
:- set
externalIPs
to access your domjudge server.
- set
- Send ssh public key to all hosts:
./send-ssh-keys.sh
- Ensure machine ID is different on all hosts:
ansible-playbook -i inventory --ask-vault-pass --extra-vars '@[path to vault file]' tasks/01.change_mahcine_id.yml
- Setup DNS:
ansible-playbook -i inventory --ask-vault-pass --extra-vars '@[path to vault file]' tasks/02.setup_dns.yml
- Set DNS IP for all hosts:
ansible-playbook -i inventory --ask-vault-pass --extra-vars '@[path to vault file]' tasks/03.set_dns_lookup.yml
- Set hostname for all hosts according to DNS records:
ansible-playbook -i inventory --ask-vault-pass --extra-vars '@[path to vault file]' tasks/04.set_hostname.yml
- Upgrade all hosts:
ansible-playbook -i inventory --ask-vault-pass --extra-vars '@[path to vault file]' tasks/05.upgrade_all_packages.yml
- Enable dnsmasq on master to prevent System Resolv occupying port 53:
ansible-playbook -i inventory --ask-vault-pass --extra-vars '@[path to vault file]' tasks/06.enable_dnsmasq.yml
- Reboot all hosts:
ansible-playbook -i inventory --ask-vault-pass --extra-vars '@[path to vault file]' tasks/07.reboot.yml
- If the main system is one of the cluster hosts, remember to exclude it from 07.reboot.yml and reboot it manually after the others finished their reboots. For instance, if the main system is on the DNS machine, change the command to
ansible-playbook -i inventory --ask-vault-pass --extra-vars '@[path to vault file]' --extra-vars 'hosts=master:compute' tasks/07.reboot.yml
- Rebooting all hosts ensures
journactl
works normally after a machine id change.
- If the main system is one of the cluster hosts, remember to exclude it from 07.reboot.yml and reboot it manually after the others finished their reboots. For instance, if the main system is on the DNS machine, change the command to
- Stop
dnsmasq
on master node:ansible-playbook -i inventory --ask-vault-pass --extra-vars '@[path to vault file]' tasks/08.stop_dns.yml
- Step 6 ~ 8 is intended to prevent System Resolv occupying port 53 on master node.
- Execute
ansible-playbook -i openshift_install_config/hosts.domjudge origin/playbooks/prerequisites.yml
- Execute
ansible-playbook -i openshift_install_config/hosts.domjudge origin/playbooks/deploy_cluster.yml
On openshift master node:
- Create a user:
sudo htpasswd /etc/origin/master/htpasswd [username]
- Give the user super powers:
sudo oc adm policy add-cluster-role-to-user cluster-admin [username] --rolebinding-name=cluster-admins
- Login to master node web console from
[master FQDN/IP]:8443
- Select
Cluster Console
on the upper left screen and login with the same credentials - In
Administration > Projects
, create a new project withdomjudge
as its name - Under the
domjudge
project:- In
Administration > Service Account
, create a new service account and modify the name line toname: privrun
- Back in terminal, give
privrun
super powers:sudo oc adm policy add-scc-to-user privileged -z privrun -n domjudge
- In
Builds > Image Streams
, create Image Streams with the files ofopenshift_domjudge_config/image_stream
- In
Builds > Build Configs
, create Build Configs with the files ofopenshift_domjudge_config/build_config
- In
Workloads > Deployment Configs
, create Deployment Configs with the files inopenshift_domjudge_config/deploy_config
- In
Networking > Services
, create Services with the files inopenshift_domjudge_config/services
- In
- Select
Application Console
on the upper left screen, and selecrdomjudge
project - Adjust the pods to suit your needs by selecting the pod entries and click the up and down arrow on the right hand side
-
Login from the external IP(s) set in
openshift_domjudge_config/services/domserver.yaml
to setup judgehost password -
Well done! All components should be running now.
- All hosts meet the prerequisites.
- Add DNS record for new hosts in
tasks/files/hosts_domjudge
. - Add hosts ansible setup in
inventory
. - Add host mappings to Openshift configuration file in
openshift_install_config/hosts.domjudge
- Send ssh public key to all hosts:
./send-ssh-keys.sh
- Enter 2 to use the original ssh key pair
- Run
ansible-playbook -i inventory --ask-vault-pass --extra-vars '@[path to vault file]' --extra-vars 'hosts=new_nodes' tasks/add_nodes.yml
- Run
ansible-playbook -i inventory --ask-vault-pass --extra-vars '@[path to vault file]' --extra-vars 'hosts=new_masters' tasks/add_masters.yml
ansible-playbook -i openshift_install_config/hosts.domjudge origin/playbooks/openshift-node/scaleup.yml
ansible-playbook -i openshift_install_config/hosts.domjudge origin/playbooks/openshift-master/scaleup.yml
- DNF upgrade may take significant amount of time. It may also fail in some cases. I would recommend to give it some time and re-run or even do it manually on failure.
- Merge all openshift_domjudge_config files into 1 template
- Better documentation for DEBUGGING