From the Kubernetes Quick Start
kubectl run
Let us start by running a simple HTTP server: nginx. Nginix is a popular HTTP server, with a pre-built container on Docker hub. The kubectl run commands below will create two nginx replicas, listening on port 80, and a public IP address for your application.
kubectl run my-nginx --image=nginx --replicas=2 --port=80
The output should look like this
deployment "my-nginx" created
kubectl expose deployment my-nginx --target-port=80 --type=LoadBalancer
The output should look like this
service "my-nginx" exposed
Kubernetes will ensure that your application keeps running, by automatically restarting containers that fail, spreading containers across nodes, and recreating containers on new nodes when nodes fail.
kubectl get service my-nginx
The output should look like this
NAME CLUSTER_IP EXTERNAL_IP PORT(S) AGE
my-nginx 10.179.240.1 25.1.2.3 80/TCP 8s
kubectl delete deployment,service my-nginx
The output should look like this
deployment "my-nginx" deleted
service "my-nginx" deleted