This is going to be a devlog of me figuring out machine learning deployments and building pipelines by attempting to build a sort of SaaS startup. Full disclosure I have already done some development just been too lazy to write about it. I haven't really written much before.
So a log recap:
- Got a domain from NameCheap
- Setup Cloudflare to manage the DNS records, I like the interface plus you get added security on your domain.
- Went ahead and got a VPS from Contabo, for $6.99 you get a pretty decent machine. I haven't experienced any issues with the service.
Note: before doing this make sure you have A records pointing to the VMs public IP address, if using Cloudflare this link should help you out
The first thing I went did was an upgrade of the packages and the distribution, using ubuntu but you can use any distro of choice.
I intend on running everything on docker containers so the next thing was to install docker using the official script, which makes the installation straightforward.
# Download Docker curl -fsSL get.docker.com -o get-docker.sh # Install Docker using the stable channel (instead of the default "edge") CHANNEL=stable sh get-docker.sh # Remove Docker install script rm get-docker.sh
I also intend to be using compose files so the next thing was to install docker-compose using the following command,
# download the 1.29.2 release and save the executable file at /usr/local/bin/docker-compose sudo curl -L "https://github.com/docker/compose/releases/download/1.29./docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose # set permissions for docker-compose to be executable sudo chmod +x /usr/local/bin/docker-compose # check the version docker-compose --version
Setup docker swarm mode
Not going to be using Kubernetes for this use but that might change later on if it becomes necessary. Currently going with docker swarm because I find it works without much setup and gets the job done.
In docker swarm, you have one or more manager nodes and one or more worker nodes, currently just setting up a node cluster and if the time comes adding more servers to the cluster is a single command.
The first step is to configure one (or more) manager nodes. accomplished by running
docker swarm init
Note: if you see an error like:
Error response from daemon: could not choose an IP address to advertise since this system has multiple addresses on interface eth0 (22.214.171.124 and 10.19.0.5) - specify one with --advertise-addr
select the public IP (for my case but in case you are using droplets on digital ocean running on the same network using the private network also works fine) and re-run the command with
docker swarm init --advertise-addr <public ip>
To add worker nodes, simply use
docker swarm join-token worker
add paste the generated command on the worker node.