Web development in Ethiopia using Kubernetes
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.
Kubernetes cluster
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
Master 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>
Deployment
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]
Pods
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
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
Ingress
Is kubernetes api to connect the external world to each specific service.
Finally
Use Kubernetes to enhance your application and platform in web development in Ethiopia