Junior — Middle
What actions did you perform to launch applications or services in the Kubernetes cluster?
sobes.tech AI
Answer from AI
To deploy applications or services in a Kubernetes cluster, I usually perform the following steps:
- Create YAML manifest files describing the necessary Kubernetes objects such as Deployment, Service, ConfigMap, etc.
- Define containers with the application image, specify the number of replicas, resources, and environment variables.
- Apply the manifests using the command
kubectl apply -f <file.yaml>to create or update resources in the cluster. - Check the status of running pods and services using
kubectl get pods,kubectl get services. - If necessary, configure Ingress for external access to the services.
An example of a simple Deployment for a Python application:
apiVersion: apps/v1
kind: Deployment
metadata:
name: python-app
spec:
replicas: 3
selector:
matchLabels:
app: python-app
template:
metadata:
labels:
app: python-app
spec:
containers:
- name: python-container
image: python:3.9-slim
command: ["python", "-m", "http.server", "8000"]
ports:
- containerPort: 8000
Then run:
kubectl apply -f deployment.yaml
kubectl expose deployment python-app --type=NodePort --port=8000