From d6d3cc170e7b71d8f43a846184e44e1ce4031b59 Mon Sep 17 00:00:00 2001 From: ycz008 Date: Fri, 18 Aug 2023 11:42:14 +0800 Subject: [PATCH] add: prod k8s --- ...s-no-pvc-ingress.yaml => nacos-no-pvcyaml} | 24 +-- prod-upgrade/nacos/mysql-local.yaml | 49 ++++++ prod-upgrade/nacos/nacos-no-pvc.yaml | 143 ++++++++++++++++++ 3 files changed, 195 insertions(+), 21 deletions(-) rename dev-upgrade/nacos/{nacos-no-pvc-ingress.yaml => nacos-no-pvcyaml} (92%) create mode 100644 prod-upgrade/nacos/mysql-local.yaml create mode 100644 prod-upgrade/nacos/nacos-no-pvc.yaml diff --git a/dev-upgrade/nacos/nacos-no-pvc-ingress.yaml b/dev-upgrade/nacos/nacos-no-pvcyaml similarity index 92% rename from dev-upgrade/nacos/nacos-no-pvc-ingress.yaml rename to dev-upgrade/nacos/nacos-no-pvcyaml index 9554929..3bf1f11 100644 --- a/dev-upgrade/nacos/nacos-no-pvc-ingress.yaml +++ b/dev-upgrade/nacos/nacos-no-pvcyaml @@ -56,6 +56,9 @@ metadata: spec: serviceName: nacos replicas: 3 + selector: + matchLabels: + app: nacos template: metadata: labels: @@ -138,24 +141,3 @@ spec: value: "SSBhbSB0aGUgc3RhZmYgb2Ygd3d3LmJlYWNvbmZpcmVpbmMuY29tCg==" - name: NACOS_AUTH_IDENTITY_VALUE value: "SSBhbSB0aGUgc3RhZmYgb2Ygd3d3LmJlYWNvbmZpcmVpbmMuY29tCg==" - selector: - matchLabels: - app: nacos - ---- -apiVersion: networking.k8s.io/v1 -kind: Ingress -metadata: - name: nacos -spec: - rules: - - host: nacos.beaconfireinc.com - http: - paths: - - path: /nacos - pathType: Prefix - backend: - service: - name: nacos - port: - name: server diff --git a/prod-upgrade/nacos/mysql-local.yaml b/prod-upgrade/nacos/mysql-local.yaml new file mode 100644 index 0000000..36cf46f --- /dev/null +++ b/prod-upgrade/nacos/mysql-local.yaml @@ -0,0 +1,49 @@ +apiVersion: v1 +kind: ReplicationController +metadata: + name: mysql + labels: + name: mysql +spec: + replicas: 1 + selector: + name: mysql + template: + metadata: + labels: + name: mysql + spec: + containers: + - name: mysql + image: mysql:8.0.33 + ports: + - containerPort: 3306 + volumeMounts: + - name: nacos-mysql-data + mountPath: /var/lib/mysql + env: + - name: MYSQL_ROOT_PASSWORD + value: "---------" + - name: MYSQL_DATABASE + value: "nacos" + - name: MYSQL_USER + value: "nacos" + - name: MYSQL_PASSWORD + value: "Nacos@2099" + volumes: + - name: nacos-mysql-data + hostPath: + path: /data/nacos/mysql +--- +apiVersion: v1 +kind: Service +metadata: + name: mysql + labels: + name: mysql +spec: + ports: + - port: 3306 + targetPort: 3306 + selector: + name: mysql diff --git a/prod-upgrade/nacos/nacos-no-pvc.yaml b/prod-upgrade/nacos/nacos-no-pvc.yaml new file mode 100644 index 0000000..9a88ceb --- /dev/null +++ b/prod-upgrade/nacos/nacos-no-pvc.yaml @@ -0,0 +1,143 @@ +apiVersion: v1 +kind: Service +metadata: + name: nacos-public + labels: + app: nacos +spec: + type: NodePort + selector: + app: nacos + ports: + - port: 8848 + name: server + targetPort: 8848 + nodePort: 30848 + - port: 9848 + name: client-rpc + targetPort: 9848 + nodePort: 30948 +--- +apiVersion: v1 +kind: Service +metadata: + name: nacos + labels: + app: nacos +spec: + type: ClusterIP + selector: + app: nacos + ports: + - port: 8848 + name: server + targetPort: 8848 + - port: 9848 + name: client-rpc + targetPort: 9848 + +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: nacos-cm +data: + mysql.host: "mysql" + mysql.db.name: "nacos" + mysql.port: "3306" + mysql.user: "root" + mysql.password: "Admin@2099" + +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: nacos +spec: + serviceName: nacos + replicas: 3 + selector: + matchLabels: + app: nacos + template: + metadata: + labels: + app: nacos + annotations: + pod.alpha.kubernetes.io/initialized: "true" + spec: + affinity: + podAntiAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + - labelSelector: + matchExpressions: + - key: "app" + operator: In + values: + - nacos + topologyKey: "kubernetes.io/hostname" + containers: + - name: nacos + imagePullPolicy: Always + image: nacos/nacos-server:v2.2.2 + resources: + requests: + memory: "2Gi" + cpu: "500m" + ports: + - containerPort: 8848 + name: client + - containerPort: 9848 + name: client-rpc + - containerPort: 9849 + name: raft-rpc + - containerPort: 7848 + name: old-raft-rpc + env: + - name: NACOS_REPLICAS + value: "3" + - name: MYSQL_SERVICE_HOST + valueFrom: + configMapKeyRef: + name: nacos-cm + key: mysql.host + - name: MYSQL_SERVICE_DB_NAME + valueFrom: + configMapKeyRef: + name: nacos-cm + key: mysql.db.name + - name: MYSQL_SERVICE_PORT + valueFrom: + configMapKeyRef: + name: nacos-cm + key: mysql.port + - name: MYSQL_SERVICE_USER + valueFrom: + configMapKeyRef: + name: nacos-cm + key: mysql.user + - name: MYSQL_SERVICE_PASSWORD + valueFrom: + configMapKeyRef: + name: nacos-cm + key: mysql.password + - name: MYSQL_SERVICE_DB_PARAM + value: "characterEncoding=utf8&connectTimeout=10000&socketTimeout=30000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true" + - name: SPRING_DATASOURCE_PLATFORM + value: "mysql" + - name: MODE + value: "cluster" + - name: NACOS_SERVER_PORT + value: "8848" + - name: PREFER_HOST_MODE + value: "hostname" + - name: NACOS_SERVERS + value: "nacos-0.nacos.base.svc:8848 nacos-1.nacos.base.svc:8848 nacos-2.nacos.base.svc:8848" + - name: NACOS_AUTH_ENABLE + value: "true" + - name: NACOS_AUTH_TOKEN + value: "SSBhbSB0aGUgc3RhZmYgb2Ygd3d3LmJlYWNvbmZpcmVpbmMuY29tCg==" + - name: NACOS_AUTH_IDENTITY_KEY + value: "SSBhbSB0aGUgc3RhZmYgb2Ygd3d3LmJlYWNvbmZpcmVpbmMuY29tCg==" + - name: NACOS_AUTH_IDENTITY_VALUE + value: "SSBhbSB0aGUgc3RhZmYgb2Ygd3d3LmJlYWNvbmZpcmVpbmMuY29tCg=="