All Documents
Current Document

Content is empty

If you don't find the content you expect, please try another search term


Create a simple NGINX service

Last updated:2021-04-14 15:43:53

This topic describes how to create a simple NGINX Service in a Kingsoft Cloud container cluster.

Create an NGINX application

Create a Deployment

Use kubectl to run the following command:

kubectl run my-nginx --image=nginx --replicas=3 --port=80
deployment "my-nginx" created

The command creates a my-nginx Deployment that contains three NGINX containers.

Query the status of the NGINX containers.

kubectl get pod
NAME                                 READY     STATUS              RESTARTS   AGE
my-nginx-85584476c8-7nsnr            1/1       Running             0          1m
my-nginx-85584476c8-k86pj            1/1       Running             0          1m
my-nginx-85584476c8-p8kvb            1/1       Running             0          1m

Create a Service

kubectl expose deployment my-nginx --port=80 --type=LoadBalancer
service "my-nginx" exposed

The command creates a LoadBalancer Service for the NGINX application to expose the NGINX Service to the Internet.

View the Service

Run the following command to view the Service:

kubectl get svc
NAME       TYPE           CLUSTER-IP       EXTERNAL-IP     PORT(S)        AGE
my-nginx   LoadBalancer   10.254.xx.xx   120.92.xx.xx   80:31084/TCP   8s

The NGINX Service is available at 120.92.xx.xx, as shown in the following figure.


On this page
Pure ModeNormal Mode

Pure Mode

Click to preview the document content in full screen