- Create
kubectl run nginx --image=nginx --replicas=1 --port=80
kubectl expose deployment nginx --type=LoadBalancer --name=mynginx
- View
watch kubectl describe service mynginx
or
watch kubectl get service mynginx -o wide
- Delete
kubectl delete service mynginx
kubectl delete deployment nginx
-
Requirements:
- Install kompose: http://kompose.io/
-
From
docker-compose.yml
version: '3'
services:
nginx:
image: nginx:1.15
ports:
- "80:80"
restart: unless-stopped
- Run:
kompose convert -f docker-compose.yml
- Output:
WARN Restart policy 'unless-stopped' in service nginx is not supported, convert it to 'always'
INFO Kubernetes file "nginx-service.yaml" created
INFO Kubernetes file "nginx-deployment.yaml" created
$ tree
.
├── nginx-deployment.yaml
└── nginx-service.yaml
- Change @
nginx-service.yaml
:
name: nginx
>> name: mynginx
- Add @
nginx-service.yaml
:
spec:
type: LoadBalancer
- Apply YAML configurations:
kubectl apply --filename nginx-deployment.yaml
kubectl apply --filename nginx-service.yaml
kubectl describe service mynginx