Containerise everything!! : using docker in Ethiopia
Posted On 23 May 2021 ( 8.3 Minute Read )
You might have come across buzzwords such as containerization, docker and wondered what all the fuss was about. And why it is important to use docker in Ethiopia. Well, This tutorial series is just what you need to join the conversation. We will look through the basics of docker and why it might be useful to your workflow. Not only that by the end of this series you will be able to containerize your applications and get them ready for deployment.
What exactly is Docker?
Docker is a containerization platform that packages your app and all its dependencies together in the form called a docker container to ensure that your application works seamlessly in any environment. This environment might be a production or staging server. Docker pulls the dependencies needed for your application to run from the cloud and configures them automatically. You don’t need to do any extra work. Below are some benefits of Using docker
1. It is cost-effective: It takes fewer resources to run your production application. And an even fewer team of developers to maintain it. The biggest driver of most management decisions when selecting a new product is the return on investment. And docker has proven to be a very efficient option.
2. Standardization & productivity: Docker containers ensure consistency across multiple developments, release cycles and standardizing your environment. One of the biggest advantages of a Docker-based architecture is standardization. Docker provides repeatable development, build, test, and production environments. Standardizing service infrastructure across the entire pipeline allows every team member to work on a production parity environment. By doing this, engineers are more equipped to efficiently analyze and fix bugs within the application. This reduces the amount of time wasted on defects and increases the amount of time available for feature development. Another key use for docker in Ethiopia
3. Compatibility & maintainability: Eliminate the “it works on my machine” problem once and for all. One of the benefits that the entire team will appreciate is parity. Parity, in terms of Docker, means that your images run the same no matter which server or whose laptop they are running on. For your developers, this means less time spent setting up environments, debugging environment-specific issues, and a more portable and easy-to-set-up codebase. Parity also means your production infrastructure will be more reliable and easier to maintain.
4. Rapid Deployment: Docker manages to reduce deployment to seconds. This is because it creates a container for every process and does not boot an OS, unlike virtual machines. Data can be created and destroyed without worry that the cost to bring it up again would be higher than affordable. Also by sharing container reduce dependency install time while using slow network making more use of docker in Ethiopia
5. Continuous Deployment & Testing: If you need to perform an upgrade during a product’s release cycle, you can easily make the necessary changes to Docker containers, test them, and implement the same changes to your existing containers. This sort of flexibility is another key advantage of using Docker. Docker allows you to build, test and release images that can be deployed across multiple servers and cloud services like Kubernetes. Even if a new security patch is available, the process remains the same. You can apply the patch, test it and release it to production.
6. Security: And the last benefit of using docker is — security. From a security point of view, Docker ensures that applications that are running on containers are completely segregated and isolated from each other, granting you complete control over traffic flow and management. No Docker container can look into processes running inside another container. From an architectural point of view, each container gets its own set of resources ranging from processing to network stacks.
Now it’s time to get our hands dirty. The first thing you need to do is install Docker on your own system and to do that just follow the official guidelines here.
After you have done that clone this sample Project locally. It is a simple Nodejs express server that we are going to containerize using docker. Run the following instructions to clone the repo and start it locally
#clone repo git clone https://gitlab.com/Dagmawi-A/starterproject.git #cd into project directory cd starterProject #install project dependencies npm install
The next step is going to be to build our docker image and run it. Don’t be intimidated if the terms seem unfamiliar. We will go in-depth in part two of this tutorial.
Run the commands below
#build our docker image docker build -t <your-name-here>/sampleproject:v1 #run our docker image and expose ports docker run -p 8000:8000 <your-name-here>/sampleproject:v1
Now that we have got our application running in our Docker container we can access it locally in our browser. Just go to this link.
Congrats you’ve just created your first docker container. Stay tuned for part 2 !!
Web development in Ethiopia using Kubernetes
Posted On 23 May 2021 ( 8.7 Minute Read )
Why is it important we discuss Kubernetes in Ethiopia.
The main struggle in Web development in Ethiopia is a proper server infrastructure. If you have been at any governmental agencies to get any kind of work approved you probably have stayed for hours waiting for a system to get back online. One of the main reason for this kind of issue is the servers running one version of application. Whenever a bug or uncaught error is found in the server the entire city waits for the servers to restart. This phenomenon is also known as system shortage(system yelem). By creating a stable infrastructure we can minimize the number of hour spent waiting in line.
What is Kubernetes ?
The name Kubernetes originated from Greek meaning pilot, This software released by google as an open-source software in 2014 allows one to freely manage containerized applications and services.
A simple way to view it is to compare it to a symphony orchestra. Where there is one conductor instructing in who, how high and when each musician and instrument should play. Each instrument and musician represents a containerized application or service.
The conductor also called the master node will instruct the musicians in kubernetes terminology called pods, services, ingress to work together in a perfect harmony.
Kubernetes makes it easy to manage hardware resources, scale applications and manage release. With almost no downtime it is a good way to roll out a new version without system shortage. It also solves the Hardware shortage by only allocating resources to the application that is currently in need of it. No more system shortage and smoother web development in Ethiopia.
Without going deep into how it works we will discuss the main idea of kubernetes and why we use it in our development process in Addis software.
Recommend to installing minikube for testing kubernetes on local development.
A cluster is network of virtual or physical machines known as nodes. Nodes are designated hardware space to run the kubernetes application and all the applications running on each node. Each application runs wrapped within temporary VMs called pods. A promotion assigned to one of the nodes to be a master node. A kubernetes cluster contains a masted node, at least one worker node, pods running inside each node
Main task is to automatically handles scheduling the pods across the Nodes in the cluster from a given rule
kubectl describe node <insert-node-name-here>
Is Kubernetes api to manage a deployment and allows you to describe an application’s life cycle, such as which images to use for the app. An example of a simple configuration file.
apiVersion: apps/v1 kind: Deployment metadata: name: my-app spec: replicas: 3 selector: matchLabels: run: my-app template: metadata: labels: run: my-app spec: containers: - name: hello-app image: gcr.io/google-samples/hello-app:1.0
To run the above deployment save the above snippet in a yaml file and run kubectl apply -f deploymentFileName , now you have created a deployment
To check the status of the deployment run kubectl describe deployment [DEPLOYMENT_NAME]. If you have forgotten your deployment name then you can run kubectl get deployments to view a list of deployments. When a deployment is done it will create a pod running your application. When it’s time for you to scale up your application you can simply run the following command with the number of replicas you want to create kubectl scale deployment [DEPLOYMENT_NAME] –replicas [NUMBER_OF_REPLICAS] and to remove a deployment kubectl delete deployment [DEPLOYMENT_NAME]
A pod is an isolated space where a containerized application runs in, it is viewed as a minimal running unit. it’s also mostly viewed as a temporary unit rather than a permanent one. It is also considered as the final resting place for your application code. Each pod is assigned an id, internal and external ip, and the containers will share the pods networks space.
Once a deployment is done, you should be able to see the pod list by running kubectl get pods.
- Pending: a pod have been accepted by kubernetes master and is in progress
- Running: a deployment successfully started a pod
- Succeeded: a pod is successfully terminated and will not be started
- Failed: a container within the pod have some kind of error and could not be started
- Unknown: the status of the pod is unknown
Service is kubernetes api to manage a running containers network, as pods are created and destroyed depending on the master node instruction a service main task id to track and manage the network for each pod or set of replicas.
apiVersion: v1 kind: Service metadata: name: my-service spec: selector: app: MyApp ports: - protocol: TCP port: 80 targetPort: 9376
The above example shows a simple service that looks into all pods running with a label called MyApp and designate a TCP network port 9376 to those pods port 80
Is kubernetes api to connect the external world to each specific service.
Use Kubernetes to enhance your application and platform in web development in Ethiopia