Skip to content

Developer Guide

Ana-Maria Moga edited this page Aug 2, 2022 · 11 revisions

Docker Machine Driver is a 3rd party plugin for Docker/Rancher Machine to manage your containers on the servers on IONOS Cloud.

This page is meant to provide a guideline for developing the IONOS Cloud Docker Machine Driver, a guideline in sync with decisions took inside the SDKs & Tooling Team regarding this product. 🥇

New proposals are always welcomed in order to improve the Docker Machine Driver!

Structure of the project

  • ionoscloud.go - the driver, which contains the options the user can set, the default values for the option, the pre-check or validations on the values set, the create, remove functions;
  • ionoscloud_test.go - unit tests for the driver;
  • utils - containing the interaction with the SDK Go and the mocks for it;
  • docs - containing the official documentation, also displayed on GitBook;
  • vendor - containing copies of dependencies.

Testing Setup

To install Rancher and Log in to Rancher UI, follow the first 3 steps from here.

First important step

You need to provision a Linux host. Your host can be: a cloud-host virtual machine, an on-prem VM, a bare-metal server. For this step, we will use a VM on IONOS Cloud. In order to create a VM, you can use a docker-machine locally that will act as a remote server for testing.

Set-up credentials:

export IONOSCLOUD_USERNAME=
export IONOSCLOUD_PASSWORD=

or

export IONOSCLOUD_TOKEN=

Create docker-machine:

docker-machine create --driver ionoscloud test-machine

or install a specific version of docker engine from an URL:

docker-machine --debug create --driver ionoscloud --engine-install-url "https://releases.rancher.com/install-docker/19.03.9.sh" test-machine

Note: docker-machine is not compatible with the latest docker since it is not actively maintained. That is why it is recommended to use --engine-install-url option.

Or you can use rancher-machine directly:

rancher-machine create --driver ionoscloud test-machine

Next step is to enter the Linux host:

docker-machine ssh test-machine
rancher-machine ssh test-machine

Second important step

Second important step is to install rancher. In your terminal, after logging into the provisioned Linux host, run:

sudo docker run -d --restart=unless-stopped -p 80:80 -p 443:443 --privileged rancher/rancher:v2.6.4

Note: Right now, version 2.6.x of Rancher is not currently supported, nor tested.

Use the following command to install specific rancher version:

sudo docker run -d --restart=unless-stopped -p 80:80 -p 443:443 --privileged rancher/rancher:v2.5-head
sudo docker run -d --restart=unless-stopped -p 80:80 -p 443:443 --privileged rancher/rancher:v2.4.9

You can check out specific versions/tags for rancher docker images here.

For debugging purposes, you can use the following commands in the terminal of your provisioned Linux Host:

  • list containers:
docker ps
  • list logs of a specific container:
docker logs CONTAINER_ID
  • kill a specific container:
docker kill CONTAINER_ID
  • more commands here.

Third important step

Last important step from the testing setup is to log in to Rancher to begin using the application. After rancher is installed in the provisioned Linux host, you can open a web browser and enter the IP address of your host: htttps://<SERVER_IP>.

From this point, you should be able to follow the steps from our official documentation.

  1. Install Node Driver;

The Download URL (replace version):

https://github.com/ionos-cloud/docker-machine-driver/releases/download/v6.0.0/docker-machine-driver-6.0.0-linux-amd64.tar.gz
  1. Install Node Template (specify options);

  2. Install New Rancher Cluster based on the new template.

Happy Testing! 🎉

Release a new version

In order to release a new version of IONOS Cloud Docker Machine Driver, a new tag will be created.

  • from the terminal, make sure you have the master branch up to date. Use git pull
  • note: it is recommended to update the docs/changelog.md file with the new version and merge it (optional step if the documentation is already updated)
  • it is recommended to use the following commit message when updating docs/changelog.md file: "doc: update version MAJOR.MINOR.PATCH" to be able to track the commit history and see when the release was created and what has been changed since
  • from the terminal, create a new tag using git tag command. (e.g.: git tag -a "vMAJOR.MINOR.PATCH" -m "IONOS Cloud Docker Machine Driver version MAJOR.MINOR.PATCH"
  • push the new tag and a CD workflow will be triggered
  • after the CD workflow is successfully done, create a new release from the new tag, adding the corresponding release notes

Done with the release of a new version of IONOS Cloud Docker Machine Driver! 🎉

General Recommendations

  • "format" go imports aligned with best practices, using goimports -l -w before merging (you can use sudo apt install golang-golang-x-tools for installation of the tool)
  • use feat/fix/doc/test as prefix for new commits and for names in PRs - this helps keeping a clean history of the commits and on the updates when releasing a new version of the tool;
  • for PRs, use squash and merge option - this helps keeping a clean history of the commits;
  • for PRs, try to make a PR for a change, not adding multiple changes to the same PR - this helps keeping a transparent history of the updates to the users and other developers as well;
  • make sure to follow SonarCloud recommendations when possible;
  • consistency over the code base and documents is highly encouraged.

Happy Developing! 🎉