|
|
|
@ -654,27 +654,43 @@ kubectl get pods
|
|
|
|
|
|
|
|
|
|
### 四、命令行创建发布与服务
|
|
|
|
|
|
|
|
|
|
**1、部署应用**
|
|
|
|
|
**1、创建命名空间**
|
|
|
|
|
|
|
|
|
|
```shell
|
|
|
|
|
kubectl create deployment nginx-deployment --image=swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/openresty/openresty:1.25.3.1-5-alpine-fat --replicas=1 --port=80
|
|
|
|
|
# 创建命名空间
|
|
|
|
|
kubectl create namespace dsideal
|
|
|
|
|
|
|
|
|
|
# 查看命名空间
|
|
|
|
|
kubectl get namespaces
|
|
|
|
|
|
|
|
|
|
# 删除命名空间
|
|
|
|
|
kubectl delete namespace dsideal
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
**2、部署应用**
|
|
|
|
|
|
|
|
|
|
```shell
|
|
|
|
|
kubectl create deployment nginx-deployment --image=swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/openresty/openresty:1.25.3.1-5-alpine-fat --replicas=1 --port=80 --namespace=dsideal
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
**2、暴露应用服务**
|
|
|
|
|
**3、暴露应用服务**
|
|
|
|
|
|
|
|
|
|
```shell
|
|
|
|
|
kubectl expose deployment nginx-deployment --type=NodePort --port=80 --target-port=80
|
|
|
|
|
kubectl expose deployment nginx-deployment --type=NodePort --port=80 --target-port=80 --namespace=dsideal
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
kubectl expose deployment nginx-deployment --type=LoadBalancer --port=80 --target-port=80
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
**3、查看集群部署状态**
|
|
|
|
|
**4、查看集群部署状态**
|
|
|
|
|
|
|
|
|
|
```shell
|
|
|
|
|
kubectl get deployment,svc
|
|
|
|
|
kubectl get deployment,svc --namespace=dsideal
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
**4、通过公网$ip+NodePort$端口号的方式访问$nginx$服务**
|
|
|
|
|
**5、通过公网$ip+NodePort$端口号的方式访问$nginx$服务**
|
|
|
|
|
|
|
|
|
|
```shell
|
|
|
|
|
http://10.10.14.200:30642
|
|
|
|
|