k8s1.17-Ingress部署 作者:马育民 • 2023-10-03 11:14 • 阅读:10036 # 说明 默认k8s是不带ingress的,需要我们单独安装 # 配置文件 创建文件夹 ``` mkdir ingress-controller ``` ``` cd ingress-controller ``` 获取ingress-nginx,本次案例使用的是0.30版本 ``` wget https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-0.30.0/deploy/static/mandatory.yaml ``` 下载失败用该文件: [k8s1.17-Ingress0.30-mandatory.yaml文件内容](//www.malaoshi.top/show_1IX6LVv98pHv.html "k8s1.17-Ingress0.30-mandatory.yaml文件内容") ``` wget https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-0.30.0/deploy/static/provider/baremetal/service-nodeport.yaml ``` 下载失败用该文件: [k8s1.17-Ingress0.30-service-nodeport.yaml文件内容](//www.malaoshi.top/show_1IX6LVwDIDix.html "k8s1.17-Ingress0.30-service-nodeport.yaml文件内容") # 创建 ingress-nginx ``` kubectl apply -f ./ ``` # 查看 ingress 控制器 ingress 控制器是 pod,执行下面命令: ``` kubectl get pod -n ingress-nginx ``` 执行结果如下: ``` NAME READY STATUS RESTARTS AGE nginx-ingress-controller-7f74f657bd-2lr96 1/1 Running 0 56s ``` # 查看service 因为ingress要接所有的请求流量,安装完还会产生一个 `NodePort` 类型的service ``` kubectl get svc -n ingress-nginx ``` 执行结果如下: ``` NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE ingress-nginx NodePort 10.108.196.2 80:32099/TCP,443:32489/TCP 2m31s ``` 外部计算机访问 `32099` 端口,就会转发到 `80` 端口 **注意:**`32099` 端口 非常关键,通过该端口访问服务 原文出处:http://malaoshi.top/show_1IX6LVmCI1Ub.html