Kubernetes has become the leading platform for container orchestration and management in the world of application infrastructure. Through this blog, I will explain a tour of the most used Kubernetes concepts, from the most basic to the most complex use cases with examples and key commands to use.
Introducing Kubernetes
Kubernetes, also known as K8s, is an open source platform that automates the deployment, scaling, and operation of containerized applications. Containers are units that encapsulate an application and all its dependencies. Kubernetes provides tools for managing containers efficiently, ensuring high availability and scalability of applications.
Installation and Configuration
The installation of Kubernetes may vary depending on the platform, but there are some tools such as 'Kubeadm', 'minikube' or cloud solutions such as:
- Google Kubernetes Engine (GKE) ⇨ Google Cloud Platform (GCP) cloud.
- Elastic Kubernetes Services (EKS) ⇨ Amazon Web Service (AWS) Cloud.
- Azure Kubernetes Services (AKS) ⇨ Azure Cloud (Azure).
Once installed, you can configure your command line tools to access the cluster.
Example of installation using the 'minikube'
💡 Note: Before starting and seeing what are the different components used in Kubernetes, you have to be clear about several things, first the indentation in the Yaml files, without them it will generate an error, and second ALWAYS, but ALWAYS a Yaml file is built of four (4) levels essential for the creation of a Yaml file, and in this order respectively, which are:
- ApiVersion
- Kind
- Metadata
- Spec
Where:
%201.11.08%20p.m..png)
Having explained the above, we can see each of the components contained in this orchestration tool called kubernetes.
Pods and Containers
A Pod is the most basic unit of deployment in Kubernetes. It can contain one or more containers that share resources and network.
Let's see an example of how to create a Pod using a Yml file.
💡 Note: In the example above we see a Yaml file that is called 'pod-example.yaml', the first thing would be to create the pod, secondly it would be to list the pods to see if our pod was created in a satisfactory way and if we want to learn more about our Pod we can use the reserved word 'describe', the commands would be in this order and like this:
Replication and Scaling
Kubernetes allows you to easily replicate and scale applications using a Yaml file or in a declarative (terminal) form, to improve availability and performance.
Let's see an example of how to create a ReplicaSet by means of a Yml file.
💡 Note: In the example above we see a Yaml file that is called 'replicaset-example.yaml', the first thing would be to create the replicaset, secondly it would be to list the replicasets to see if our replica was successfully created and if we want to scale our replica if we had to enter our Yml file they would be in this order and in this way:
Services and Networking
The Services allow communication between different sets of Containers in Kubernetes. A Service can be exposed internally or externally.
Let's see an example of how to create a Service by means of a Yml file.
💡 Note: In the example above we see a Yaml file that is called 'service-example.yaml', the first thing would be to create the service, secondly it would be to list the services to see if it was created in a satisfactory way', the commands would be in this order and like this:
Configuration and Secrets
Secrets in Kubernetes allow you to store sensitive information, such as passwords, in a secure manner.
Let's see an example of how to create a Secret by means of a Yml file.
💡 Note: In the example above we see a Yaml file that is called 'secret-example.yaml', the first thing would be to create the secret, secondly it would be to list the secrets to see if it was created in a satisfactory way', the commands would be in this order and like this:
Monitoring
Observability is critical in Kubernetes, as it helps teams identify problems and proactively manage Kubernetes clusters that. Tools such as Prometheus can be used.
Example of installation using the 'Prometheus'
Deployments
A Deployment is an object that can represent an application in the cluster. When the Deployment is created, it can be specified in the Spec of the Deployment how many replicas of the application you want to run.
Let's see an example of how to create a Deployment by means of a Yml file.
💡 Note: In the example above we see a Yaml file that is called 'deployment-example.yaml', the first thing would be to create the deployment, secondly it would be to list the secrets to see if it was created in a satisfactory way', the commands would be in this order and like this:
Updates and Rollbacks
Los Rolling Updates allow you to update applications gradually to avoid interruptions.
Example of upgrading a 'Deployment'
Advanced Use Case
Kubernetes can be used in a variety of use cases, such as multicluster deployments, persistent storage, batch execution, and more.
Let's see an example of how to create a TareaBatch by means of a Yml file.
💡 Note: In the example above we see a Yaml file that is called 'job-example.yaml', the first thing would be to create the job, secondly it would be to list the jobs to see if it was created in a satisfactory way', the commands would be in this order and like this:
Conclusion
With this, we have explored a wide range of concepts that are used in Kubernetes, from the most basic concepts such as creating a Pod to the most advanced. This is a very powerful tool that allows you to orchestrate applications in an efficient and scalable way in container environments.
Ready to optimize the management of your applications with Kubernetes?
At Kranio, we have experts in container orchestration who will help you implement efficient solutions using Kubernetes, ensuring the scalability and performance of your applications. Contact us and discover how we can promote the digital transformation of your company.