" />

欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

nginx-ingress-controller部署配置詳解

 更新時間:2023年11月22日 08:49:53   作者:moon  
這篇文章主要為大家介紹了nginx ingress controller的部署配置,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪

引言

  • 開源 Nginx Ingress Controller(k8s 官網(wǎng)推薦)、Nginx Incorporaton (nginx inc,nginx官網(wǎng)) 和 Nginx Incorporaton Plus
  • 當(dāng)多個ingress對象資源配置同一個主機時,就會發(fā)生主機沖突。 Ingress Controller 支持兩種處理主機沖突的選項:
  • Choosing the Winner

If multiple resources contend for the same host, the Ingress Controller will pick the winner based on the creationTimestamp of the resources: the oldest resource will win. In case there are more than one oldest resources (their creationTimestamp is the same), the Ingress Controller will choose the resource with the lexicographically smallest uid.

  • Merging Configuration for the Same Host

It is possible to merge configuration for multiple Ingress resources for the same host. One common use case for this approach is distributing resources across multiple namespaces.

  • 所以最好一個域名,對應(yīng)一個ingress對象
# describe ingress 報錯
  Warning  Rejected  17m (x2 over 6d23h)  nginx-ingress-controller  All hosts are taken by other resources
  Warning  Rejected  17m (x2 over 3d17h)  nginx-ingress-controller  All hosts are taken by other resources

一. 部署

wget https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.2.1/deploy/static/provider/cloud/deploy.yaml
# 選擇版本
https://github.com/kubernetes/ingress-nginx/blob/controller-v1.4.0/deploy/static/provider/cloud/deploy.yaml
# 修改yaml中的image,改為自己的
    # 可用國內(nèi)源: registry.cn-hangzhou.aliyuncs.com/google_containers/nginx-ingress-controller:v1.2.1
registry.cn-hangzhou.aliyuncs.com/google_containers/nginx-ingress-controller:v1.8.1
registry.cn-hangzhou.aliyuncs.com/google_containers/kube-webhook-certgen:v20230407

二. 配置

1. 跨域

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: front-web
  namespace: web
  annotations:
    kubernetes.io/ingress.class: "nginx"
    nginx.ingress.kubernetes.io/enable-cors: "true"
    nginx.ingress.kubernetes.io/cors-allow-methods: "PUT, GET, POST, OPTIONS"
    nginx.ingress.kubernetes.io/cors-allow-headers: "Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control"
    nginx.ingress.kubernetes.io/cors-expose-headers: "*, X-CustomResponseHeader"
    nginx.ingress.kubernetes.io/cors-max-age: 600

2. 白名單

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress-myapp
  namespace: default
  annotations:
    kubernetes.io/ingress.class: "nginx"
    # 白名單
    nginx.ingress.kubernetes.io/whitelist-source-range: 120.176.65.13,120.79.18.35
# 設(shè)置從代理服務(wù)器讀取響應(yīng)的超時時間(以秒為單位,默認(rèn)值60)
nginx.ingress.kubernetes.io/proxy-read-timeout: "300"

# 強制重定向到 HTTPS(即使 Ingress 未啟用 TLS)
nginx.ingress.kubernetes.io/force-ssl-redirect: "true"

3. 強制https

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: test-ingress
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
    nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
    nginx.ingress.kubernetes.io/ssl-redirect: "true"
    nginx.ingress.kubernetes.io/preserve-trailing-slash: "true"
spec:
  rules:
  - http:
      paths:
      - path: /testpath
        backend:
          serviceName: test
          servicePort: 80

4. 跳轉(zhuǎn)

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: test-ingress
  namespace: uf
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
  ingressClassName: nginx-ingress
  rules:
  - host: dev-gf.uf.net.cn
    http:
      paths:
      - backend:
          service:
            name: uf-epi-html
            port:
              number: 80
        path: /epi/(.*)
        pathType: ImplementationSpecific

以上就是nginx-ingress-controller部署配置詳解的詳細(xì)內(nèi)容,更多關(guān)于nginx ingress controller部署配置的資料請關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

  • Nginx 動態(tài)域名解析過程詳解

    Nginx 動態(tài)域名解析過程詳解

    這篇文章主要為大家介紹了Nginx 動態(tài)域名解析過程,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-03-03
  • 分享最新版 nginx內(nèi)置變量 大全

    分享最新版 nginx內(nèi)置變量 大全

    在配置基于nginx服務(wù)器的網(wǎng)站時,必然會用到 nginx內(nèi)置變量 ,下面筆者將它整理成列表,把最新版本的變量列出來,以方便做配置時查詢
    2016-04-04
  • Nginx中IF語句實現(xiàn)數(shù)學(xué)比較功能

    Nginx中IF語句實現(xiàn)數(shù)學(xué)比較功能

    這篇文章主要介紹了Nginx中IF語句實現(xiàn)數(shù)學(xué)比較功能,即在Nginx中用if判斷數(shù)字大小,類似編程語言中的邏輯比較,需要的朋友可以參考下
    2015-02-02
  • 從Nginx切換到Tengine的步驟分享

    從Nginx切換到Tengine的步驟分享

    由淘寶網(wǎng)發(fā)起的Web服務(wù)器 Tengine 可以被看作一個更好的Nginx,或者是Nginx的超集。它在Nginx的基礎(chǔ)上,針對大訪問量網(wǎng)站的需求,添加了很多高級功能和特性
    2012-11-11
  • Nginx工作模式及代理配置的使用細(xì)節(jié)

    Nginx工作模式及代理配置的使用細(xì)節(jié)

    這篇文章主要為大家介紹了Nginx工作模式及代理配置的使用細(xì)節(jié),有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-03-03
  • 在Nginx服務(wù)器上安裝配置博客程序Typecho的教程

    在Nginx服務(wù)器上安裝配置博客程序Typecho的教程

    這篇文章主要介紹了在Nginx服務(wù)器上安裝配置博客程序Typecho的教程,Typecho是一個開源的PHP博客程序,比WordPress更加輕量,需要的朋友可以參考下
    2015-12-12
  • nginx tcp負(fù)載均衡的具體實現(xiàn)

    nginx tcp負(fù)載均衡的具體實現(xiàn)

    Nginx是比較不錯的開源Web服務(wù)器之一,它也可以用作TCP和UDP負(fù)載均衡器,本文主要介紹了nginx tcp負(fù)載均衡的具體實現(xiàn),具有一定的參考價值,感興趣的可以了解一下
    2024-05-05
  • Nginx實現(xiàn)基于請求頭的訪問控制配置的示例

    Nginx實現(xiàn)基于請求頭的訪問控制配置的示例

    在Nginx中,可以使用"allow"和"deny"指令來實現(xiàn)IP訪問限制,本文給大家介紹Nginx實現(xiàn)基于請求頭的訪問控制配置,感興趣的朋友一起看看吧
    2023-11-11
  • Nginx之QPS限制模塊的具體使用

    Nginx之QPS限制模塊的具體使用

    本文主要介紹了Nginx之QPS限制模塊的具體使用,主要介紹Nginx QPS限制模塊的原理、安裝和使用方法,具有一定的參考價值,感興趣的可以了解一下
    2023-09-09
  • 詳解nginx 的 default_server 定義及匹配規(guī)則

    詳解nginx 的 default_server 定義及匹配規(guī)則

    這篇文章主要介紹了詳解nginx 的 default_server 定義及匹配規(guī)則,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-08-08

最新評論