Introduction to Kubernetes: Deploying a Simple Application
Learn the basics of Kubernetes and how to deploy a simple application using pods, services, and deployments.
Introduction to Kubernetes
Kubernetes is a popular container orchestration platform that helps you deploy and manage containerized applications. In this tutorial, we will learn how to deploy a simple application using Kubernetes.
Step 1: Install Kubernetes
To get started with Kubernetes, you need to install it on your machine. You can download the Kubernetes installer from the official Kubernetes website.
# Install Kubernetes on Ubuntu-based systems
sudo apt update
sudo apt install kubeadm -y
Step 2: Create a Deployment
Once Kubernetes is installed, we can create a deployment. A deployment is a YAML file that defines the application to be deployed.
# deployment.yml
apiVersion: apps/v1
kind: Deployment
metadata:
name: hello-world
spec:
replicas: 3
selector:
matchLabels:
app: hello-world
template:
metadata:
labels:
app: hello-world
spec:
containers:
- name: hello-world
image: gcr.io/codelab-184332/monolith:1.0.0
ports:
- containerPort: 80
Step 3: Apply the Deployment
Now that we have the deployment YAML file, we can apply it using the kubectl command.
# Apply the deployment
kubectl apply -f deployment.yml
In this tutorial, we learned how to install Kubernetes, create a deployment, and apply it using the kubectl command. With this knowledge, you can deploy your applications using Kubernetes and manage them using pods, services, and deployments.