Container installation and execution on ACS

To install, and later execute our containers on ACS, we need a shell to log in. We can retrieve the FQDN information (fully qualified domain name) of our (Ubuntu Linux-based) VMs (docker swarm nodes), which hold our containers from the deployment information as shown in the last diagram.

These VMs are installed with Ubuntu Linux with Docker Engine. The agent docker nodes and the master node are stringed together by the virtual of Docker Swarm orchestration, which is why we now call them Docker Swarm Nodes instead of just docker nodes.

In your ACS deployment, and in the last screenshot, there is a field called SSHMASTER0, from where you can get the SSH settings to log in to the secure shell. You will need to use your private key, which you have supplied when creating the ACS resources to log in via SSH.

In our example case, this is the FQDN and port number to log in via SSH, eaamgmt.eastus.cloudapp.azure.com:2200

Using this information along with our certificate key, we can successfully log in to our master node in the ACS. Once logged in, you can execute the command docker info, and it gives an output as shown in this screenshot:

View of docker info command on master node

Now, from within the terminal, type this command:

export DOCKER_HOST=tcp://127.0.0.1:2375

With this last command in your terminal session, your Docker commands will be redirected to 2375, on which Docker Swarm is listening. Running docker info now gives a different output, as shown in this screenshot:

View of docker info command on master node from Docker Swarm

In this preceding screenshot, now you can see that docker info displays clearly the status of the two agents connected.

After exporting the docker port, that is, now using docker swarm, running the Docker commands will be executed on the docker agent nodes. Type the following commands:

docker run -name eea-spa-container -t -d -p 8080:80 habibcs/eea-spa
docker run -name eea-be-container -t -d -p 8081:80 habibcs/eea-be-mathwebapi

Running these commands means that Docker will pull the images from the docker hub public registry, install them, and execute the containers from these images, instructing to redirect port 80 to 8080, and to redirect from 80 to 8081 for the backend container. Remember, our index.html page in the frontend SPA container has the URL http://eaaagents.eastus.cloudapp.azure.com:8081. This is the URL to invoke the backend hosted in a container on the Azure Container Service. Since the docker swarm is in control, it automatically runs the containers on the agent nodes, and decides automatically which node(s) to run the given container. The frontend is now accessible over ACS, which we can use to test at http://eaaagents.eastus.cloudapp.azure.com:8080/.

But before we continue to test, we need to allow one of our ports to be accessed publicly. The ports which are opened by default on VMs are 80, 443, and 8080. So, we need to allow port 8081 to be opened as well so that our API can be accessed over this port. To do this, we need to go to the Azure Resource group for our ACS, which, in this case, is RG_ACS_EABook_Example; in the resource group, locate the load balancer for the agent nodes (in my case--swarm-agent-lb-580D48D8), select it, then go to Health Probes, and add the new HTTP port 8081. In addition to that, we also need to add a new load balancing rule in the load balancer for the newly added port:

Add a new rule to open a port (Load balancer - Health probes)

The following image shows the newly added load balancing rule for port 8081 in our load balancer for ACS:

Add a new load balancer rule (Load balancer - Load balancing rules)

Finally, we can execute our sample microservices-based Math Application from Docker containers, orchestrated by Docker Swarm, hosted by the Azure Container Service on the Azure cloud, and it looks like this:

Final view of app running from Azure Container Service
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.222.185