修改和新增
All checks were successful
continuous-integration/drone Build is passing

This commit is contained in:
2025-12-23 01:53:01 +08:00
parent 89a07bc062
commit b44594def6
17 changed files with 922 additions and 110 deletions

View File

@@ -4,13 +4,18 @@
## 准备工作
- Nginx Deployment
1. 部署 Nginx 资源
- Nginx Service:
```yaml
kubectl apply -f https://gitee.com/offends/Kubernetes/raw/main/File/Yaml/nginx-deployment.yaml
kubectl apply -f https://gitee.com/offends/Kubernetes/raw/main/File/Yaml/nginx-deployment-svc.yaml
```
Name: nginx-service
2. 查看部署情况
Port: 80
```bash
kubectl get deploy,svc
```
## 示例
@@ -22,40 +27,70 @@
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:
- HTTP
```yaml
cat <<EOF | kubectl apply -f -
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: nginx-ingress
spec:
rules:
# 对外域名
- host: nginx.example.com
namespace: default
annotations:
# 不限制文件上传大小 或 选择其他参数
nginx.ingress.kubernetes.io/proxy-body-size: "0"
labels:
name: nginx-ingress
spec:
ingressClassName: nginx # 通过 kubectl get ingressclass 查看
rules:
- http:
paths:
- backend:
service:
name: nginx-service # Nginx Serice 名称
port:
number: 80 # Nginx 端口
path: /
pathType: Prefix
EOF
```
- HTTPS
```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:
ingressClassName: nginx # 通过 kubectl get ingressclass 查看
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
```
- backend:
service:
name: nginx-service # Nginx Serice 名称
port:
number: 80 # Nginx 端口
path: /
pathType: Prefix
# 对外域名证书配置
tls:
- hosts:
- nginx.example.com
secretName: nginx-tls
EOF
```
3. 访问域名