|
| 1 | +# MacStadium Orka VPN setup for Jenkins |
| 2 | + |
| 3 | + |
| 4 | +The following steps will guide you through setting up a VPN connection to the MacStadium Orka environment for Jenkins. |
| 5 | + |
| 6 | +This process is done manually, but it can be automated in the future. |
| 7 | + |
| 8 | +Currently our Orka cluster is hosted in the MacStadium datacenter. The VPN connection is required to access the Orka environment from the Jenkins server using the plugin [Orka by MacStadium](https://plugins.jenkins.io/macstadium-orka/). |
| 9 | + |
| 10 | + |
| 11 | +--- |
| 12 | + |
| 13 | +**IMPORTANT** |
| 14 | + |
| 15 | +Before you start, you need to have a clear understanding of the networking setup in the Jenkins server and the VPN connection. If you are not familiar with these topics, please ask for help from the Build team. |
| 16 | + |
| 17 | +You can collect information about current setup and the changes that the VPN performs by running the following commands: |
| 18 | + |
| 19 | +```bash |
| 20 | +ip addr |
| 21 | +ip route |
| 22 | +cat /etc/resolv.conf |
| 23 | +sudo iptables -L -n -v |
| 24 | +``` |
| 25 | + |
| 26 | +--- |
| 27 | + |
| 28 | +## Steps |
| 29 | + |
| 30 | +1. You need to ssh to the Jenkins server and install the OpenVPN client. You can do this by running the following commands: |
| 31 | + |
| 32 | +```bash |
| 33 | +sudo apt-get update |
| 34 | +sudo apt-get install openconnect |
| 35 | +``` |
| 36 | + |
| 37 | +2. In the secrets repo you can find the information needed to connect to the VPN and also the content for the connection script file. |
| 38 | + |
| 39 | +3. Create a new file in the Jenkins server with the content from the secrets repo. |
| 40 | + |
| 41 | +```bash |
| 42 | +touch /root/orka-vpn-connect.sh |
| 43 | +nano /root/orka-vpn-connect.sh |
| 44 | +chmod +x /root/orka-vpn-connect.sh |
| 45 | +``` |
| 46 | + |
| 47 | +4. Execute the script to connect to the VPN and ensure that is working correctly. |
| 48 | + |
| 49 | +```bash |
| 50 | +./root/orka-vpn-connect.sh |
| 51 | +``` |
| 52 | + |
| 53 | +5. You need to add firewall rules to allow the Jenkins server to access the Orka environment. You can do this by running the following commands: |
| 54 | + |
| 55 | +```bash |
| 56 | +# Check the current firewall rules |
| 57 | +sudo iptables -L -n -v |
| 58 | +# Add the new rules |
| 59 | +sudo iptables -A INPUT -s 10.221.190.0/24 -j ACCEPT -m comment --comment "Orka MacOS VPN" |
| 60 | +# Check the new rules |
| 61 | +sudo iptables -L -n -v |
| 62 | +``` |
| 63 | + |
| 64 | + |
| 65 | +5. In a new terminal using ssh, you can check the VPN connection by running the following command: |
| 66 | + |
| 67 | +```bash |
| 68 | +curl <ORKA_ENDOPINT> |
| 69 | +``` |
| 70 | + |
| 71 | +If you got an html response, the VPN connection is working correctly. If you got an error, please ask for help from the Build team. |
| 72 | + |
| 73 | +6. Stop the script running in the other terminal, so your VPN connection is closed. |
| 74 | + |
| 75 | +7. Now we will create a systemd service to start the VPN connection when the Jenkins server boots, that will also ensure the connection is re-established if it is lost. |
| 76 | + |
| 77 | +```bash |
| 78 | +touch /etc/systemd/system/orka-vpn.service |
| 79 | +``` |
| 80 | + |
| 81 | +8. Add the following content to the file `nano /etc/systemd/system/orka-vpn.service`: |
| 82 | + |
| 83 | +``` |
| 84 | +[Unit] |
| 85 | +Description=OpenConnect VPN for Orka |
| 86 | +After=network.target |
| 87 | +
|
| 88 | +[Service] |
| 89 | +Type=simple |
| 90 | +ExecStart=/root/orka-vpn-connect.sh |
| 91 | +Restart=always |
| 92 | +RestartSec=10 |
| 93 | +
|
| 94 | +[Install] |
| 95 | +WantedBy=multi-user.target |
| 96 | +``` |
| 97 | + |
| 98 | +8. Enable the service and start it. |
| 99 | + |
| 100 | +```bash |
| 101 | +sudo systemctl enable orka-vpn |
| 102 | +sudo systemctl start orka-vpn |
| 103 | +``` |
| 104 | + |
| 105 | +9. Check the status of the service. |
| 106 | + |
| 107 | +```bash |
| 108 | +sudo systemctl status orka-vpn |
| 109 | +``` |
| 110 | + |
| 111 | +10. Check the VPN connection by running the following command: |
| 112 | + |
| 113 | +```bash |
| 114 | +curl <ORKA_ENDOPINT> |
| 115 | +``` |
0 commit comments