Deploy Nginx Service in Kubernetes
To deploy Nginx in Kubernetes and make it accessible from external sources, you need to follow a few steps:
Last updated
vi deployment.yamlapiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
spec:
replicas: 1
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx
ports:
- containerPort: 80vi service.yamlapiVersion: v1
kind: Service
metadata:
name: nginx-service
spec:
type: LoadBalancer
selector:
app: nginx
ports:
- protocol: TCP
port: 80
targetPort: 80kubectl apply -f deployment.yamlkubectl apply -f service.yamlkubectl get services kubectl describe services