3CX on Google Compute Engine – Part 2

In the first part of this 2-part article, we had completed most of the back-end preparation work. Here we will see how to create your “gold” image for eventual multiple deployments of 3CX on Google Compute Engine.

Prepare your Instance for 3CX V15

Google Compute Engine

  • Connect to your instance using the “SSH” button in the console
  • Elevate to the root user with “sudo su -“
  • Update the Operating System with
    • “apt update” to allow the system to update the list of available packages
    • “apt upgrade” to upgrade all packages
  • Install package tcpdump for eventual troubleshooting tasks with “apt-get install tcpdump”
  • Add prerequisites for 3CX by running the following commands:
    • wget -O- http://downloads.3cx.com/downloads/3cxpbx/public.key | apt-key add –
    • echo “deb http://downloads.3cx.com/downloads/3cxpbx/ /” | tee /etc/apt/sources.list.d/3cxpbx.list
    • apt update
    • apt-get install -y $(apt-cache depends 3cxpbx | grep Depends | sed “s/.*ends:\ //” | tr ‘\n’ ‘ ‘)
  • Install port-forwarding rules with the following commands:
    • apt-get install iptables-persistent
    • iptables -A INPUT -p tcp –dport 80 -j ACCEPT
    • iptables -A INPUT -p tcp –dport 443 -j ACCEPT
    • iptables -A INPUT -p tcp –dport 5015 -j ACCEPT
    • iptables -A INPUT -p tcp –dport 5090 -j ACCEPT
    • iptables -A INPUT -p udp –dport 5090 -j ACCEPT
    • iptables -A INPUT -p tcp –dport 5060:5061 -j ACCEPT
    • iptables -A INPUT -p udp –dport 5060 -j ACCEPT
    • iptables -A INPUT -p udp –dport 9000:9500 -j ACCEPT
    • iptables-save >/etc/iptables/rules.v4
  • Shut down the instance from the VM Instances page
  • Delete the VM but RETAIN the disk:
    • Go the the VM Instances page
    • Delete the instance, making sure that there IS NO WARNING about deleting the attached disk
  • Create your Custom Image:
    • Go to the Images node
    • Click on “Create Image”
      • Set the name to “image-3cx-template”
      • Set the Source Disk to the disk that was previously attached to the template VM (in this example “instance-3cx-template”)
      • Click the “Create” button
    • Your new image will show up in the list of available images

Create an Instance from the Template

  • Go to the Images node, and select your template image
  • Click the “Create Instance” button at the top of the page
    • Set the name for the instance (in this example “instance-3cx-001”)
    • Select the zone (typically the zone closest to where your phones are located to minimize latency)
    • Select the Machine type (should be related to the number of extensions and the number of simultaneous calls, but your first pilot instance should be fine with “micro (1 shared vCPU, 0.6Gb memory)”
    • Identity and API access:
      • Service Account = Compute Engine default service account
      • Access scopes = Allow full access to all Cloud APIs
    • Expand the Management, disk, networking, SSH keys section
      • Navigate to Disks => Deletion rule
        • UNSELECT the “Delete boot disk when instance is deleted” option (this is for safety reasons, allowing you to recover should you delete a VM instance by mistake)
      • Navigate to Networking => External IP, and assign an already-existing Static IP Address (you may need to reserve one if you do not have any unallocated Static External IP Addresses; note that an Ephemeral address will not be sufficient)
    • Click the “Create” button at the bottom of the page.
  • Once the instance is running, we can proceed to install 3CX on it

Install 3CX on the New Instance

  • Connect to your instance using the “SSH” button in the console
  • Start the installation for 3CX using “sudo apt-get install 3cxpbx” (at the time of writing, this will install Version 15.0.60903.0)
  • Proceed with the installation following the regular 3CX documentation