What is Container Orchestration?
Over the past few years, the use of containers has been increasing. You need orchestrators because most containers run in container orchestrators. For example - Mesos, Kubernetes, etc,. These Orchestrators provide resource allocation, and management of the container life cycle. and assurance that the containerized workloads are running and available for your application.

Benefits of Container Orchestration for containerized workloads include:
- The complexity of the container is high, so to simplify the operation, container orchestrators are used.
- These are also used to automatically restart or scare a cluster(group of containers) or a container.
-
It also provides security to applications by eliminating or reducing the chances of human errors.
Let's now discuss the various type of container concepts in Chef Habitat available.
Azure Container Service
Nowadays, we prefer not to get stuck in installing, configuring, and maintaining tools and services. We prefer to use technologies like serverless architecture to stay focused on providing value to our applications instead of wasting time on maintaining the infrastructure. As Kubernetes is the most popular form of orchestrator. Azure is offering AKS (Azure Kubernetes Service), which was previously known by the name ACS(Azure Container Service).

Azure container service allows you to select among the most popular container orchestrators. For example - Kubernetes, Mesos, Swarm, etc,. In the earlier version, users had to pay for the master services provided by the container orchestrator. But the new version, i.e., AKS, only charges for nodes where containers are deployed.
To create a Kubernetes managed cluster, you need to have:
-
An account on Azure with a subscription; when you start your subscription, you will get free credits for initial use. It should contain three resources -
- Storage
- Networking
-
Container Service
- Installed and configured Azure command-line interface
-
Installed Kubectl, a tool for Kubernetes command line

The steps for creating a Kubernetes managed cluster on Azure are:
Step 1 is to create a new group of resources. To keep all the related resources together. For sharing permission and policies, and if at some point you want to clear them, then you need to delete this resource group. The following command can do this:
az group create --name <group_name> --location <XYZ>
To delete the whole group of resources, you can use the following command:
az group delete -n <group_name>
Step 2 is to create an Azure Kubernetes Service cluster. The following command can do this:
az aks create --resource-group <group_name> --name <cluster_name> --node-count <number_of_nodes> --node-vm-size <type_of_instance> --generate-ssh-keys
Now, Azure will create a cluster with default values for resources like networking and monitoring. It will take approx 20-25 minutes to create a cluster. Now let's see if the cluster is working or not.
Step 3 is to download the credentials of the cluster. Run the following command in your command line interface to start downloading:
az aks get-credentials --resource-group=<group_name> --name=<cluster_name>
Step 4 is to browser the created cluster. To browse the cluster, run the following command:
az aks browse --resource-group <group_name> --name <cluster_name>
A few seconds later, a browser window shows the Kubernetes dashboard window. If the window shows you the cluster name with a green tick, CONGRATULATIONS 🎉 your cluster has been created and is working correctly.

Step 5 is the final step, i.e., Deleting the Azure Kubernetes Service cluster after its use; otherwise, you have to pay for it until it is not deleted. This can be done by running the following command:
az aks delete --resource-group <group_name> --name <cluster_name>
This was one of the container concepts in chef habitat. Let's now discuss the next container service, Amazon Container Service.
Amazon Container Service
It is an extensible container management system that can be easily used and integrated highly with other AWS(Amazon Web Services), but it doesn't support Kubernetes. ECS(Elastic Container Service) helps to start, stop and manage containerized applications by just calling an API(Application Programmable Interface). Also, if you are familiar with the EC2 service, you can identify the status of the cluster from a central service.

This Amazon ECS service allows you to run your Docker-based application on containers. Some of the features provided by Amazon Container Service are
-
Security - This service enables you to set permissions for each container. ECS thus provides a high level of security to our applications.
-
Integrity - Amazon EC service can be accessed anywhere. It enables users to run and maintain applications without worrying about on-premises investments.
- Cost Efficient - This service allows the user to deploy various containers at the same node. As a result, it helps in reducing the cost of the application.
Google Container Registry
Google Container Registry is a private Docker repository. It runs on GCP(Google Cloud Platform) for providing compatible up-times on the infrastructure that Google protects. This Google Container Registry works with continuous delivery systems. For hosting your private images under the GCP project in Cloud Storage.

Before pushing or pulling images in the Cloud Storage, configure the Docker to use Google CLI (Command Line Interface). You need to run the following command to do this:
gcloud auth configure-docker
After building the chef habitat package. Now, you can push images using the registry's URL(Uniform Resource Locator). And the format for pushing the image will be as follows: [HOSTNAME] / [PROJECT_ID] / [IMAGE_URL]:[IMAGE_TAG]
Running Linux Container
On Linux, Chef Habitat usually runs as the root user and will start Chef Habitat services specified by that user. However, in some scenarios of deployment, it is undesirable or sometimes even impossible to run the chef habitat as a root user.
In that case, there is an OpenShift container platform that doesn't run chef habitat as a root user, but it will run as random user IDs called non-root users. Version 0.53.0 onward enables this feature. It now gives users more flexibility in using Chef Habitat.

Run the following command to run the chef habitat as a root user:
docker run --rm -it core/redis:latest
To run chef habitat as a non-root user, add the user’s id in the above command as follows:
docker run --rm -it --user=<user_id> core/redis:latest
This was all about the container concept in chef habitat. Let's now discuss a few frequently asked questions.
Frequently Asked Questions
What is Chef Habitat?
Chef Habitat enables the users to build, deploy and manage their services and applications in different environments of their choice like Kubernetes, Docker, etc.
What is Kubernetes?
It is a popular container orchestrator for deploying, scaling and managing containerized applications on container clusters.
What is the container concept in chef habitat?
The container concept in chef habitat refers to the form of OS (Operating System) virtualization, which enables you to build a non-changeable image of the runtime environment.
How can you delete the resource group?
To delete a complete resource group, you need to type the following command in the command line interfaced and hit enter: az group delete -n <group_name>
On what language is chef based?
Chef is based on Ruby Language.
Conclusion
In this blog, we learned about the container concept in chef habitat in detail. We looked at the concepts involved in understanding the chef. This blog also discussed container orchestration and various container services like AKS(Azure Container Service), Amazon ECS(Elastic Container Service), GCR(Google Container Registry), and running the chef habitat in Linux containers.
You can refer to other similar articles as well:
Please refer to our guided paths on Coding Ninjas Studio to learn more about DSA, Competitive Programming, JavaScript, System Design, etc. And also, enroll in our courses and refer to the mock test and problems available. Have a look at the interview experiences and interview bundle for placement preparations.
Do upvote our blog to help other ninjas grow.
Happy Learning!