Skip to content

How to expose the app?

Course: Kubernetes Part 1 - chapter 17

Let’s delete all resources and restart a deployment for nginx with 3 replicas

apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:latest
ports:
- containerPort: 80
  • Apply the configuration
kubectl apply -f deployment.yml
  • Get all pods
kubectl get pods -owide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
nginx-deployment-576c6b7b6-7jrn5 1/1 Running 0 2m19s 10.244.2.19 local-worker2 <none> <none>
nginx-deployment-576c6b7b6-88fkh 1/1 Running 0 2m22s 10.244.1.13 local-worker <none> <none>
nginx-deployment-576c6b7b6-zf8ff 1/1 Running 0 2m25s 10.244.2.18 local-worker2 <none> <none>
  • The IPs that you see are private IPs . You wont be able to access the app on it