What steps are necessary to deploy and run an application in Kubernetes?
sobes.tech AI
Answer from AI
The typical steps for deploying and running an application in Kubernetes are:
-
Preparing manifests — creating YAML files describing Kubernetes resources such as Deployment, Service, ConfigMap.
-
Creating a Docker image — packaging the application into a container and uploading the image to a registry (Docker Hub, private registry).
-
Applying manifests — using the command
kubectl apply -f <file>to create objects in the cluster. -
Checking status — using
kubectl get pods,kubectl describe, andkubectl logsto verify that pods are running and functioning correctly. -
Configuring access — creating services (Service) for accessing the application inside or outside the cluster.
Example of a simple Deployment:
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp-deployment
spec:
replicas: 3
selector:
matchLabels:
app: myapp
template:
metadata:
labels:
app: myapp
spec:
containers:
- name: myapp-container
image: myrepo/myapp:latest
ports:
- containerPort: 8080
After that:
kubectl apply -f deployment.yaml
kubectl get pods
kubectl expose deployment myapp-deployment --type=LoadBalancer --port=80 --target-port=8080
This is a basic process that can be expanded depending on application requirements and infrastructure.