From 0abc964586f92992e99b1029833bcb4639a6d74e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E6=B5=B7?= <10402852@qq.com> Date: Sat, 14 Sep 2024 20:23:39 +0800 Subject: [PATCH] 'commit' --- .../1、K8S搭建/openresty-deployment.yaml | 73 +++++++++++++++++++ .../1、K8S搭建/openresty-service.yaml | 36 +++++++++ .../openresty-deployment.yaml | 31 ++++++++ .../openresty-service.yaml | 15 ++++ .../创建OpenResty的例子/创建脚本.txt | 5 ++ 5 files changed, 160 insertions(+) create mode 100644 操作文档/1、K8S搭建/openresty-deployment.yaml create mode 100644 操作文档/1、K8S搭建/openresty-service.yaml create mode 100644 操作文档/1、K8S搭建/创建OpenResty的例子/openresty-deployment.yaml create mode 100644 操作文档/1、K8S搭建/创建OpenResty的例子/openresty-service.yaml create mode 100644 操作文档/1、K8S搭建/创建OpenResty的例子/创建脚本.txt diff --git a/操作文档/1、K8S搭建/openresty-deployment.yaml b/操作文档/1、K8S搭建/openresty-deployment.yaml new file mode 100644 index 00000000..6ec7a589 --- /dev/null +++ b/操作文档/1、K8S搭建/openresty-deployment.yaml @@ -0,0 +1,73 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + annotations: {} + labels: + app: nginx-deployment-label + name: nginx-deployment + namespace: default + resourceVersion: '568978' +spec: + progressDeadlineSeconds: 600 + replicas: 1 + revisionHistoryLimit: 10 + selector: + matchLabels: + app: nginx-selector + strategy: + rollingUpdate: + maxSurge: 25% + maxUnavailable: 25% + type: RollingUpdate + template: + metadata: + creationTimestamp: null + labels: + app: nginx-selector + spec: + containers: + - env: + - name: password + value: '123' + - name: age + value: '18' + image: >- + swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/openresty/openresty:1.25.3.1-5-alpine-fat + imagePullPolicy: Always + name: nginx-container + ports: + - containerPort: 80 + name: http + protocol: TCP + - containerPort: 443 + name: https + protocol: TCP + resources: {} + terminationMessagePath: /dev/termination-log + terminationMessagePolicy: File + dnsPolicy: ClusterFirst + restartPolicy: Always + schedulerName: default-scheduler + securityContext: {} + terminationGracePeriodSeconds: 30 +status: + availableReplicas: 1 + conditions: + - lastTransitionTime: '2024-09-14T12:15:22Z' + lastUpdateTime: '2024-09-14T12:15:22Z' + message: Deployment has minimum availability. + reason: MinimumReplicasAvailable + status: 'True' + type: Available + - lastTransitionTime: '2024-09-14T12:15:20Z' + lastUpdateTime: '2024-09-14T12:15:22Z' + message: ReplicaSet "nginx-deployment-86b7dc4856" has successfully progressed. + reason: NewReplicaSetAvailable + status: 'True' + type: Progressing + observedGeneration: 1 + readyReplicas: 1 + replicas: 1 + updatedReplicas: 1 + diff --git a/操作文档/1、K8S搭建/openresty-service.yaml b/操作文档/1、K8S搭建/openresty-service.yaml new file mode 100644 index 00000000..700ef1e3 --- /dev/null +++ b/操作文档/1、K8S搭建/openresty-service.yaml @@ -0,0 +1,36 @@ +--- +apiVersion: v1 +kind: Service +metadata: + labels: + app: nginx-service-label + name: nginx-service + namespace: default + resourceVersion: '569157' +spec: + clusterIP: 10.97.26.42 + clusterIPs: + - 10.97.26.42 + externalTrafficPolicy: Cluster + internalTrafficPolicy: Cluster + ipFamilies: + - IPv4 + ipFamilyPolicy: SingleStack + ports: + - name: http + nodePort: 30004 + port: 80 + protocol: TCP + targetPort: 80 + - name: https + nodePort: 30443 + port: 443 + protocol: TCP + targetPort: 443 + selector: + app: nginx-selector + sessionAffinity: None + type: NodePort +status: + loadBalancer: {} + diff --git a/操作文档/1、K8S搭建/创建OpenResty的例子/openresty-deployment.yaml b/操作文档/1、K8S搭建/创建OpenResty的例子/openresty-deployment.yaml new file mode 100644 index 00000000..21b1ba50 --- /dev/null +++ b/操作文档/1、K8S搭建/创建OpenResty的例子/openresty-deployment.yaml @@ -0,0 +1,31 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: openresty-deployment +spec: + replicas: 2 # 根据需求设置副本数量 + selector: + matchLabels: + app: openresty + template: + metadata: + labels: + app: openresty + spec: + containers: + - name: openresty + image: swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/openresty/openresty:1.25.3.1-5-alpine-fat + ports: + - containerPort: 80 + name: http + - containerPort: 443 + name: https + volumeMounts: + - mountPath: /usr/local/openresty/nginx/conf/lua-scripts + name: lua-scripts-volume + command: ["/bin/bash", "-c"] + args: ["exec /usr/bin/openresty -g 'daemon off;'"] + volumes: + - name: lua-scripts-volume + configMap: + name: openresty-lua-configmap \ No newline at end of file diff --git a/操作文档/1、K8S搭建/创建OpenResty的例子/openresty-service.yaml b/操作文档/1、K8S搭建/创建OpenResty的例子/openresty-service.yaml new file mode 100644 index 00000000..c2457c55 --- /dev/null +++ b/操作文档/1、K8S搭建/创建OpenResty的例子/openresty-service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: openresty-service +spec: + selector: + app: openresty + ports: + - name: http + port: 80 + targetPort: 80 + - name: https + port: 443 + targetPort: 443 + type: LoadBalancer # 或者 NodePort \ No newline at end of file diff --git a/操作文档/1、K8S搭建/创建OpenResty的例子/创建脚本.txt b/操作文档/1、K8S搭建/创建OpenResty的例子/创建脚本.txt new file mode 100644 index 00000000..73201e4f --- /dev/null +++ b/操作文档/1、K8S搭建/创建OpenResty的例子/创建脚本.txt @@ -0,0 +1,5 @@ +# Deployment +kubectl apply -f deployment.yaml + +#Export Service +kubectl apply -f service.yaml \ No newline at end of file