当前位置:网站首页>Kubernetes基础自学系列 | Ingress API讲解
Kubernetes基础自学系列 | Ingress API讲解
2022-06-27 15:45:00 【51CTO】
视频来源:B站《2021 年末倾力打造 Kubernetes 入门至精通 - 2022 年幸福的开胃菜》
一边学习一边整理老师的课程内容及试验笔记,并与大家分享,侵权即删,谢谢支持!
资料信息
Ingress-Nginx github 地址:
https://github.com/kubernetes/ingress-nginx
Ingress-Nginx 官方网站:
https://kubernetes.github.io/ingress-nginx/


部署 Ingress-Nginx
Ingress HTTP 代理访问
deployment、Service、Ingress Yaml 文件
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: nginx-dm
spec:
replicas: 2
template:
metadata:
labels:
name: nginx
spec:
containers:
- name: nginx
image: wangyanglinux/myapp:v1
imagePullPolicy: IfNotPresent
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
name: nginx-svc
spec:
ports:
- port: 80
targetPort: 80
protocol: TCP
selector:
name: nginx
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: nginx-test
spec:
rules:
- host: www1.hongfu.com
http:
paths:
- path: /
backend:
serviceName: nginx-svc
servicePort: 80
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.
- 25.
- 26.
- 27.
- 28.
- 29.
- 30.
- 31.
- 32.
- 33.
- 34.
- 35.
- 36.
- 37.
- 38.
- 39.
- 40.
- 41.
- 42.
- 43.
Ingress HTTPS 代理访问
创建证书,以及 cert 存储方式
deployment、Service、Ingress Yaml 文件
Nginx 进行 BasicAuth
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: auth.hongfu.com
annotations:
nginx.ingress.kubernetes.io/auth-type: basic
nginx.ingress.kubernetes.io/auth-secret: basic-auth
nginx.ingress.kubernetes.io/auth-realm: 'Authentication Required - foo'
spec:
rules:
- host: auth.hongfu.com
http:
paths:
- path: /
backend:
serviceName: nginx-svc
servicePort: 80
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
Nginx 进行重写
名称 | 描述 | 值 |
nginx.ingress.kubernetes.io/rewrite-target | 必须重定向流量的目标URI | 串 |
nginx.ingress.kubernetes.io/ssl-redirect | 指示位置部分是否仅可访问SSL(当Ingress包含证书时默认为True) | 布尔 |
nginx.ingress.kubernetes.io/force-ssl-redirect | 即使Ingress未启用TLS,也强制重定向到HTTPS | 布尔 |
nginx.ingress.kubernetes.io/app-root | 定义Controller必须重定向的应用程序根,如果它在'/'上下文中 | 串 |
nginx.ingress.kubernetes.io/use-regex | 指示Ingress上定义的路径是否使用正则表达式 | 布尔 |
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: rew.hongfu.com
annotations:
nginx.ingress.kubernetes.io/rewrite-target: https://www.baidu.com
spec:
rules:
- host: rew.hongfu.com
http:
paths:
- path: /
backend:
serviceName: nginx-svc
servicePort: 80
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
边栏推荐
- Bit. Store: long bear market, stable stacking products may become the main theme
- 事务的隔离级别详解
- 等保三级密码复杂度是多少?多久更换一次?
- LeetCode每日一练(主要元素)
- Introduce you to ldbc SNB, a powerful tool for database performance and scenario testing
- 深耕数字化,引领云原生,服务更多开发者
- 一场分销裂变活动,不止是发发朋友圈这么简单!
- Sigkdd22 | graph generalization framework of graph neural network under the paradigm of "pre training, prompting and fine tuning"
- EMQ helps Qingdao Yanbo build a smart water platform
- QT5 之信号与槽机制(信号与槽的基本介绍)
猜你喜欢

Construction and management practice of ByteDance buried point data flow
Yyds dry inventory brief chrome V8 engine garbage collection

What is the level 3 password complexity of ISO? How often is it replaced?

Hongmeng makes efforts! HDD Hangzhou station · offline salon invites you to build ecology

A robot is located in the upper left corner of an M x n grid. The robot can only move down or right one step at a time. The robot attempts to reach the lower right corner of the grid. How many differe

Cesium realizes satellite orbit detour

What is RPC

LeetCode每日一练(主要元素)
![[pygame Games] ce jeu](/img/3c/e573106ec91441a554cba18d5b2253.png)
[pygame Games] ce jeu "eat Everything" est fantastique? Tu manges tout? (avec code source gratuit)

郎酒两大王牌产品成都联动共振,持续带动光瓶酒消费浪潮
随机推荐
带你认识图数据库性能和场景测试利器LDBC SNB
Etcd visualization tool: kstone deployment (I), rapid deployment based on Helm
国家食品安全风险评估中心:不要盲目片面追捧标签为“零添加”“纯天然”食品
A distribution fission activity is more than just a circle of friends!
郎酒两大王牌产品成都联动共振,持续带动光瓶酒消费浪潮
[pygame Games] ce jeu "eat Everything" est fantastique? Tu manges tout? (avec code source gratuit)
深耕数字化,引领云原生,服务更多开发者
事务的隔离级别详解
Slow bear market, bit Store provides stable stacking products to help you cross the bull and bear
List to table
Leetcode daily practice (main elements)
数组表示若干个区间的集合,请你合并所有重叠的区间,并返回 一个不重叠的区间数组,该数组需恰好覆盖输入中的所有区间 。【LeetCodeHot100】
A large number of missing anchor text
ICML 2022 ぷ the latest fedformer of the Dharma Institute of Afghanistan ⻓ surpasses SOTA in the whole process of time series prediction
List转Table
华为云首次解读云原生2.0十大典型架构,加速构建现代化应用
华为云DevCloud重磅发布四大新能力,创下国内两项第一
C système de gestion de la charge de travail des enseignants en langues
National food safety risk assessment center: do not blindly and unilaterally pursue "zero addition" and "pure natural" food
Regular matching starts with what, ends with what, starts with what, and ends with what