Install Nginx on microK8s with Metallb using Kubernetes Deployment
Deploy Nginx container on microK8s
Create file nginx-deployment.yaml with the following content:
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 deployment
microk8s kubectl apply -f nginx-deployment.yaml
Check deployment
microk8s kubectl get pods
Expose the Deployment Using MetalLB
Create file nginx-service.yaml with the following content:
apiVersion: v1
kind: Service
metadata:
name: nginx-service
spec:
selector:
app: nginx
ports:
- protocol: TCP
port: 80
targetPort: 80
type: LoadBalancer
Apply the Service:
microk8s kubectl apply -f nginx-service.yaml
Check service and external IP
microk8s kubectl get service nginx-service
Check cluster health
microk8s inspect