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

Prerequisites

Before using commands, configure Connect to a Kubernetes cluster by using kubectl first.

Create an application by using commands

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

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

This command creates a service portal for this container. Specify--type=LoadBalancer and 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