You can create applications or view containers in applications by using commands.

Prerequisites

Before using commands to manage applications, Connect to a Kubernetes cluster by using kubectl.

Create an application by using commands

Run the following statements to run a simple container (a Nginx Web server in this example).

 root@master # kubectl run -it nginx --image=registry.aliyuncs.com/spacexnice/netdia:latest

This command creates a service portal for this container. Specify --type=LoadBalancer and an Alibaba Cloud Server Load Balancer route will be created to the Nginx container.

root@master # kubectl expose deployment nginx --port=80 --target-port=80 --type=LoadBalancer

View containers by using commands

Run the following command to list all the running containers in the default namespaces.

root@master # kubectl get pods
NAME READY STATUS RESTARTS AGE
nginx-2721357637-dvwq3 1/1 Running 1 9h