文档说明:只记录关键地方;
试验环境: linux debian 11
目标:自建K8S 对外提供 http https 服务
ingress-nginx 暴露服务端口
| apiVersion: v1 |
| kind: Service |
| 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.2.0 |
| name: ingress-nginx-controller |
| namespace: ingress-nginx |
| spec: |
| ports: |
| - appProtocol: http |
| name: http |
| port: 80 |
| protocol: TCP |
| targetPort: http |
| - appProtocol: https |
| name: https |
| port: 443 |
| protocol: TCP |
| targetPort: https |
| selector: |
| app.kubernetes.io/component: controller |
| app.kubernetes.io/instance: ingress-nginx |
| app.kubernetes.io/name: ingress-nginx |
| type: NodePort |
| externalIPs: |
| - 192.168.3.123 |
| - 192.168.3.124 |
| |
生成secret TLS
| |
| kubectl create -n default secret tls com-xiaoshuogeng-tls-cert-secret \ |
| --key=/data/tls/wildcard.xiaoshuogeng.com.key.pem \ |
| --cert=/data/tls/wildcard.xiaoshuogeng.com.fullchain.pem |
| |
ingress-nginx 配置路由
com-xiaoshuogeng-confluence-service是内部服务名称
| apiVersion: networking.k8s.io/v1 |
| kind: Ingress |
| metadata: |
| name: ingress-com-xiaoshuogeng-confluence |
| namespace: default |
| annotations: |
| nginx.ingress.kubernetes.io/force-ssl-redirect: "True" |
| spec: |
| ingressClassName: nginx |
| rules: |
| - host: confluence.xiaoshuogeng.com |
| http: |
| paths: |
| - path: / |
| pathType: Prefix |
| backend: |
| service: |
| name: com-xiaoshuogeng-confluence-service |
| port: |
| number: 80 |
| tls: |
| - hosts: |
| - confluence.xiaoshuogeng.com |
| secretName: com-xiaoshuogeng-tls-cert-secret |
| |
参考文档
- 自建kubernetes ingress-nginx 和ingress-istio 服务暴露端口
- Ingress Controllers
- Workload Resources
- Ingress
- k8s从私有仓库拉取镜像
- Pull an Image from a Private Registry
- k8s给应用注入数据
- k8s secret
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· Docker 太简单,K8s 太复杂?w7panel 让容器管理更轻松!