zoukankan      html  css  js  c++  java
  • k8s笔记——NodePort暴露nginx-controller实现https自动跳转自定义nodePort端口

    安装nginx-controller并暴露nodePort

    helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx/
    helm repo update
    helm install gateway ingress-nginx/ingress-nginx --set controller.service.type=NodePort --set controller.admissionWebhooks.enabled=false
    kubectl patch svc gateway-ingress-nginx-controller  -p '{"spec":{"ports":[{"name":"http","nodePort":30882,"port":80,"protocol":"TCP","targetPort":30882},{"name":"https","nodePort":30883,"port":443,"protocol":"TCP","targetPort":30883}]}}'

    修改deployment

    kubectl edit deploy gateway-ingress-nginx-controller
          containers:
          - args:
            - /nginx-ingress-controller
            - --publish-service=$(POD_NAMESPACE)/gateway-ingress-nginx-controller
            - --election-id=ingress-controller-leader
            - --ingress-class=nginx
            - --http-port=30882
            - --https-port=30883
            - --configmap=$(POD_NAMESPACE)/gateway-ingress-nginx-controller

    修改configmap,新增use-port-in-redirects并禁用hsts(不禁用hsts浏览器在第二次访问时不会走服务器的308让ingress跳转到https_port而是会自动http->https端口不会修改导致https:http_port访问出现访问失败)

    kubectl edit configmap gateway-ingress-nginx-controller
    apiVersion: v1
    data:  
    hsts: "false" use
    -port-in-redirects: "true" kind: ConfigMap
  • 相关阅读:
    Goolge-Guava Concurrent中的Service
    Golang操作数据库
    HttpContext
    office 问题集
    C# 日志使用
    字符编解码的故事 字符集 GBK GB2312 GB18030 Unicode 的由来和区别
    TCP UDP 协议的选择
    WebService 学习总结
    WebService 学习过程
    Archery:开源漏洞评估和管理工具
  • 原文地址:https://www.cnblogs.com/gmmy/p/14923870.html
Copyright © 2011-2022 走看看