fix: 修复nginx-deployment.yaml
This commit is contained in:
parent
1ed98506f9
commit
88bad1ae39
@ -10,21 +10,6 @@
|
|||||||
#
|
#
|
||||||
# 2. 运行部署脚本:
|
# 2. 运行部署脚本:
|
||||||
# ./deploy.sh
|
# ./deploy.sh
|
||||||
#
|
|
||||||
# 或者手动执行:
|
|
||||||
# 1. kubectl create secret docker-registry harbor-registry-secret \
|
|
||||||
# --docker-server=$HARBOR_REGISTRY \
|
|
||||||
# --docker-username=$HARBOR_USERNAME \
|
|
||||||
# --docker-password=$HARBOR_PASSWORD
|
|
||||||
# 2. kubectl apply -f nginx-deployment.yaml
|
|
||||||
|
|
||||||
---
|
|
||||||
# 1. 私有仓库访问凭据 Secret (通过脚本自动创建)
|
|
||||||
# 如果需要手动创建,请使用以下命令:
|
|
||||||
# kubectl create secret docker-registry harbor-registry-secret \
|
|
||||||
# --docker-server=<HARBOR_REGISTRY> \
|
|
||||||
# --docker-username=<HARBOR_USERNAME> \
|
|
||||||
# --docker-password=<HARBOR_PASSWORD>
|
|
||||||
|
|
||||||
---
|
---
|
||||||
# 1. ConfigMap - NGINX 配置
|
# 1. ConfigMap - NGINX 配置
|
||||||
@ -46,7 +31,7 @@ data:
|
|||||||
}
|
}
|
||||||
|
|
||||||
http {
|
http {
|
||||||
include /usr/local/nginx/conf/mime.types;
|
include /etc/nginx/mime.types;
|
||||||
default_type application/octet-stream;
|
default_type application/octet-stream;
|
||||||
|
|
||||||
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
||||||
@ -76,7 +61,7 @@ data:
|
|||||||
}
|
}
|
||||||
|
|
||||||
---
|
---
|
||||||
# 3. Deployment - NGINX 应用部署
|
# 2. Deployment - NGINX 应用部署
|
||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
metadata:
|
metadata:
|
||||||
@ -114,7 +99,7 @@ spec:
|
|||||||
containers:
|
containers:
|
||||||
- name: nginx
|
- name: nginx
|
||||||
# 使用私有仓库中的镜像(需要根据实际情况修改)
|
# 使用私有仓库中的镜像(需要根据实际情况修改)
|
||||||
image: ${HARBOR_REGISTRY}/test/nginx:latest
|
image: $HARBOR_REGISTRY/test/nginx:$NGINX_IMAGE_TAG
|
||||||
imagePullPolicy: Always
|
imagePullPolicy: Always
|
||||||
|
|
||||||
ports:
|
ports:
|
||||||
@ -202,7 +187,7 @@ spec:
|
|||||||
tolerationSeconds: 300
|
tolerationSeconds: 300
|
||||||
|
|
||||||
---
|
---
|
||||||
# 4. Service - 服务暴露
|
# 3. Service - 服务暴露
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Service
|
kind: Service
|
||||||
metadata:
|
metadata:
|
||||||
@ -221,7 +206,7 @@ spec:
|
|||||||
app: nginx
|
app: nginx
|
||||||
|
|
||||||
---
|
---
|
||||||
# 5. HorizontalPodAutoscaler - 自动扩缩容
|
# 4. HorizontalPodAutoscaler - 自动扩缩容
|
||||||
apiVersion: autoscaling/v2
|
apiVersion: autoscaling/v2
|
||||||
kind: HorizontalPodAutoscaler
|
kind: HorizontalPodAutoscaler
|
||||||
metadata:
|
metadata:
|
||||||
@ -262,40 +247,7 @@ spec:
|
|||||||
periodSeconds: 15
|
periodSeconds: 15
|
||||||
|
|
||||||
---
|
---
|
||||||
# 6. PodDisruptionBudget - Pod 中断预算
|
# 5. PodDisruptionBudget - Pod 中断预算
|
||||||
apiVersion: policy/v1
|
|
||||||
kind: PodDisruptionBudget
|
|
||||||
metadata:
|
|
||||||
name: nginx-pdb
|
|
||||||
namespace: default
|
|
||||||
spec:
|
|
||||||
minAvailable: 1
|
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
app: nginx
|
|
||||||
averageUtilization: 70
|
|
||||||
- type: Resource
|
|
||||||
resource:
|
|
||||||
name: memory
|
|
||||||
target:
|
|
||||||
type: Utilization
|
|
||||||
averageUtilization: 80
|
|
||||||
behavior:
|
|
||||||
scaleDown:
|
|
||||||
stabilizationWindowSeconds: 300
|
|
||||||
policies:
|
|
||||||
- type: Percent
|
|
||||||
value: 50
|
|
||||||
periodSeconds: 60
|
|
||||||
scaleUp:
|
|
||||||
stabilizationWindowSeconds: 60
|
|
||||||
policies:
|
|
||||||
- type: Percent
|
|
||||||
value: 100
|
|
||||||
periodSeconds: 15
|
|
||||||
|
|
||||||
---
|
|
||||||
# 6. PodDisruptionBudget - Pod 中断预算
|
|
||||||
apiVersion: policy/v1
|
apiVersion: policy/v1
|
||||||
kind: PodDisruptionBudget
|
kind: PodDisruptionBudget
|
||||||
metadata:
|
metadata:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user