DEV Community

Cover image for kubernetes
betpido
betpido

Posted on

kubernetes

Kubernetes is an open-source system for automating deployment, scaling, and management of containerized applications.

It groups containers that make up an application into logical units for easy management and discovery.
It is designed to be portable, extensible, and self-healing.

Kubernetes is widely used in the industry to manage containerized applications.

How it works:

Kubernetes is a container orchestration platform that automates the deployment and scaling of containerized workloads. It is designed to be portable, extensible, and self-healing.

Kubernetes works by grouping containers that make up an application into logical units for easy management and discovery. It provides a platform for developers to deploy and manage their applications in a scalable and efficient manner.

Kubernetes uses declarative configuration to define the desired state of the application. The user specifies the desired state of the application in a YAML file, which is then used by Kubernetes to create and manage the application.

Kubernetes also provides self-healing capabilities. If a container fails, Kubernetes will automatically restart it. If a node fails, Kubernetes will reschedule the containers running on that node to other healthy nodes in the cluster

kubernetes cluster:

A Kubernetes cluster is a set of node machines for running containerized applications. At a minimum, a cluster contains a control plane and one or more compute machines, or nodes.

The control plane is responsible for maintaining the desired state of the cluster, such as which applications are running and which container images they use.

an example of how to deploy an application using Kubernetes:

Create a deployment YAML file that describes the desired state of your application. Here is an example YAML file for a simple web application:
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-web-app
spec:
replicas: 3
selector:
matchLabels:
app: my-web-app
template:
metadata:
labels:
app: my-web-app
spec:
containers:

  • name: my-web-app image: my-web-app:v1 ports:
    • containerPort: 80

This YAML file specifies that we want to deploy three replicas of a web application called my-web-app. The application runs in a container with the image my-web-app:v1 and listens on port 80.

Use the kubectl apply command to create the deployment:
kubectl apply -f deployment.yaml

This command creates the deployment and starts the specified number of replicas.

Verify that the deployment was created successfully:
kubectl get deployments

This command should output information about the my-web-app deployment.

Expose the deployment as a service:
kubectl expose deployment my-web-app --type=LoadBalancer --port=80 --target-port=80

This command creates a service that exposes the my-web-app deployment on port 80.

Verify that the service was created successfully:
kubectl get services

This command should output information about the my-web-app service.

Top comments (0)