This commit is contained in:
61
网关/Ingress/创建Ingress资源提供访问.md
Normal file
61
网关/Ingress/创建Ingress资源提供访问.md
Normal file
@@ -0,0 +1,61 @@
|
||||
> 本文作者:丁辉
|
||||
|
||||
# 创建Ingress资源提供访问
|
||||
|
||||
## 准备工作
|
||||
|
||||
- Nginx Deployment
|
||||
|
||||
- Nginx Service:
|
||||
|
||||
Name: nginx-service
|
||||
|
||||
Port: 80
|
||||
|
||||
## 示例
|
||||
|
||||
1. 创建对外域名证书
|
||||
|
||||
```bash
|
||||
kubectl create secret tls nginx-tls --key nginx.key --cert nginx.pem -n default
|
||||
```
|
||||
|
||||
2. 创建 Ingress 资源
|
||||
|
||||
```yaml
|
||||
cat <<EOF | kubectl apply -f -
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: nginx-ingress
|
||||
namespace: default
|
||||
annotations:
|
||||
# 不限制文件上传大小 或 选择其他参数
|
||||
nginx.ingress.kubernetes.io/proxy-body-size: "0"
|
||||
labels:
|
||||
name: nginx-ingress
|
||||
spec:
|
||||
rules:
|
||||
# 对外域名
|
||||
- host: nginx.example.com
|
||||
http:
|
||||
paths:
|
||||
- pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
# Nginx Serice 名称
|
||||
name: nginx-service
|
||||
port:
|
||||
# Nginx 端口
|
||||
number: 80
|
||||
path: /
|
||||
# 对外域名证书配置
|
||||
tls:
|
||||
- hosts:
|
||||
- nginx.example.com
|
||||
secretName: nginx-tls
|
||||
EOF
|
||||
```
|
||||
|
||||
3. 访问域名
|
||||
|
||||
Reference in New Issue
Block a user