kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.8.2/deploy/static/provider/cloud/deploy.yaml
把https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.8.2/deploy/static/provider/cloud/deploy.yaml下载下来。由于使用的内网搭建服务,所以选择一个节点作为nginx的启动节点。修改内容如下:
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app.kubernetes.io/component: controller
app.kubernetes.io/instance: ingress-nginx
app.kubernetes.io/name: ingress-nginx
app.kubernetes.io/part-of: ingress-nginx
app.kubernetes.io/version: 1.8.2
name: ingress-nginx-controller
namespace: ingress-nginx
spec:
...
template:
...
spec:
nodeName: ls.uniosjob.cn # 固定到指定node,如果不固定可以不配置
hostNetwork: true # 将本pod映射到对应服务器的主进程,所以该节点配置的port也会直接占用服务器的port
...
指定占用的节点名称。(或者使用其他的方案。。)
然后再创建ingress的时候,务必添加ingressClassName参数指向ingressClass对象。(如果先部署的ingress服务则不用配置)