This topic describes how to use commands to create applications or view containers in which applications run.

Prerequisites

The kubectl client is connected to the Serverless Kubernetes cluster. For more information, see Connect to a Kubernetes cluster by using kubectl.

Create an application by using commands

Run the following command to start a container, which is an NGINX web server in this example:

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

Run the following command to create a service entry for this container. The --type=LoadBalancer parameter in the command instructs the system to create a Server Load Balancer (SLB) instance for the NGINX container.

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 namespace:

kubectl get pods
NAME                                   READY     STATUS    RESTARTS   AGE
nginx-2721357637-d****                 1/1       Running   1          9h