Last updated:2021-04-14 15:43:53
This topic describes how to create a simple NGINX Service in a Kingsoft Cloud container cluster.
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
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.
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.
Did you find the above information helpful?
Please give us your feedback.
Thank you for your feedback.