From 88bad1ae3937f2d3a65a88665b5d0b1cd632d3a2 Mon Sep 17 00:00:00 2001 From: huangzhiqiang Date: Mon, 9 Jun 2025 13:50:53 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Dnginx-deployment.yaml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- k8s/nginx-deployment.yaml | 60 ++++----------------------------------- 1 file changed, 6 insertions(+), 54 deletions(-) diff --git a/k8s/nginx-deployment.yaml b/k8s/nginx-deployment.yaml index 2ead073..3ae8b28 100644 --- a/k8s/nginx-deployment.yaml +++ b/k8s/nginx-deployment.yaml @@ -10,21 +10,6 @@ # # 2. 运行部署脚本: # ./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= \ -# --docker-username= \ -# --docker-password= --- # 1. ConfigMap - NGINX 配置 @@ -46,7 +31,7 @@ data: } http { - include /usr/local/nginx/conf/mime.types; + include /etc/nginx/mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' @@ -76,7 +61,7 @@ data: } --- -# 3. Deployment - NGINX 应用部署 +# 2. Deployment - NGINX 应用部署 apiVersion: apps/v1 kind: Deployment metadata: @@ -114,7 +99,7 @@ spec: containers: - name: nginx # 使用私有仓库中的镜像(需要根据实际情况修改) - image: ${HARBOR_REGISTRY}/test/nginx:latest + image: $HARBOR_REGISTRY/test/nginx:$NGINX_IMAGE_TAG imagePullPolicy: Always ports: @@ -202,7 +187,7 @@ spec: tolerationSeconds: 300 --- -# 4. Service - 服务暴露 +# 3. Service - 服务暴露 apiVersion: v1 kind: Service metadata: @@ -221,7 +206,7 @@ spec: app: nginx --- -# 5. HorizontalPodAutoscaler - 自动扩缩容 +# 4. HorizontalPodAutoscaler - 自动扩缩容 apiVersion: autoscaling/v2 kind: HorizontalPodAutoscaler metadata: @@ -262,40 +247,7 @@ spec: periodSeconds: 15 --- -# 6. 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 中断预算 +# 5. PodDisruptionBudget - Pod 中断预算 apiVersion: policy/v1 kind: PodDisruptionBudget metadata: