Ingress-Nginx 安装
Configuring a webserver or loadbalancer is harder than it should be. Most webserver configuration files are very similar. There are some applications that have weird little quirks that tend to throw a wrench in things, but for the most part you can apply the same logic to them and achieve a desired result.
The Ingress resource embodies this idea, and an Ingress controller is meant to handle all the quirks associated with a specific "class" of Ingress.
An Ingress Controller is a daemon, deployed as a Kubernetes Pod, that watches the apiserver's
/ingressesendpoint for updates to the Ingress resource.配置一个 Web 服务器或者负载均衡器比想象的难。大多数 Web 服务的配置文件非常相似。有些应用需要一些奇怪的需求,但是在大多数的情况下,可以使用相同的逻辑以达到预期的效果。
Ingress 资源体现了这一思想,ingress 控制器处理了上述奇怪的需求。
Ingress 控制器是一个守护进程,作为一个 Pod 部署,它监视 Apiserver 的 ingresses 端点以获取 ingress 资源的更新。
[TOC]
下载部署文件
# Ingress-nginx Deployment YAML 文件
for file in configmap.yaml mandatory.yaml namespace.yaml rbac.yaml with-rbac.yaml; do wget https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/static/$file; done
# Service Nodeport YAML 文件
wget https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/static/provider/baremetal/service-nodeport.yaml修改 Service Nodeport 文件
...
ports:
- name: http
port: 80
targetPort: 80
# 自定义 NodPort
# 确保重启 SVC 后,Port 不变
nodePort: 30080
protocol: TCP
- name: https
port: 443
targetPort: 443
nodePort: 30443
protocol: TCP
...部署 Ingress
测试 Ingress
创建 Nginx
创建 Ingress
部署测试应用
查看 Ingress
验证 Ingress
通过外网访问域名加端口,此处为 test.test.com:30080。
Last updated
Was this helpful?