Kubernetes is a container orchestration system for automating application deployment, scaling and management. Here we will show a simple example of nginx deployment by kubernetes.
Requirements
- install kubernetes, for me, I use minikube
- install docker
Step 1: Pull the image from Docker Registry
1 | $ kubectl run nginx --image=nginx:latest --port=80 |
Step 2: Check if deployment ok
1 | $ kubectl get pods |
Step 3: Expose service through NodePort
As I use minikube in local, I don’t have LoadBalancer installed, so I use NodePort as type here
1 | kubectl expose deployment nginx --type=NodePort --port=80 --target-port=80 |
Step 4: Get service port
1 | kubectl get svc nginx |
Here we can find that the service if exposed by port 32598
Step 5: Get kubernetes ip
1 | kubectl get endpoints kubernetes |
Step 6: Access to nginx
Open your navigator and type the url of kubernetes with the port of nginx, you will access to welcome page of nginx
1 | http://192.168.99.100:32598 |