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

Prerequisites

The kubectl client is connected to the Kubernetes cluster. For more information, see Connect to Kubernetes clusters through kubectl.

Create an application by using commands

  1. Run the following command to start a container, which is an NGINX web server in this example:
     # kubectl run -it nginx --image=registry.aliyuncs.com/spacexnice/netdia:latest
  2. 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 kubectl get pods command to list all the running containers in the default namespace.

NAME                                   READY     STATUS    RESTARTS   AGE
nginx-2721357637-dvwq3                 1/1       Running   1          9h