# # Copyright 2021 Apollo Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # --- # 为外部 mysql 服务设置 service kind: Service apiVersion: v1 metadata: namespace: sre name: service-mysql-for-portal-server labels: app: service-mysql-for-portal-server spec: ports: - protocol: TCP port: 3306 targetPort: 3306 type: ClusterIP sessionAffinity: None --- kind: Endpoints apiVersion: v1 metadata: namespace: sre name: service-mysql-for-portal-server subsets: - addresses: # 更改为你的 mysql addresses, 例如 1.1.1.1 - ip: your-mysql-addresses ports: - protocol: TCP port: 3306 --- # configmap for apollo-portal-server kind: ConfigMap apiVersion: v1 metadata: namespace: sre name: configmap-apollo-portal-server data: application-github.properties: | spring.datasource.url = jdbc:mysql://service-mysql-for-portal-server.sre:3306/ApolloPortalDB?characterEncoding=utf8 # mysql username spring.datasource.username = FillInCorrectUser # mysql password spring.datasource.password = FillInCorrectPassword # enabled environments apollo.portal.envs = dev,fat,uat,pro apollo-env.properties: | dev.meta=http://service-apollo-config-server-dev.sre:8080 fat.meta=http://service-apollo-config-server-fat.sre:8080 uat.meta=http://service-apollo-config-server-uat.sre:8080 pro.meta=http://service-apollo-config-server-prod.sre:8080 --- kind: Service apiVersion: v1 metadata: namespace: sre name: service-apollo-portal-server labels: app: service-apollo-portal-server spec: ports: - protocol: TCP port: 8070 targetPort: 8070 nodePort: 30001 selector: app: pod-apollo-portal-server type: NodePort # portal session 保持 sessionAffinity: ClientIP --- kind: Deployment apiVersion: apps/v1 metadata: namespace: sre name: deployment-apollo-portal-server labels: app: deployment-apollo-portal-server spec: # 2 个实例 replicas: 2 selector: matchLabels: app: pod-apollo-portal-server strategy: rollingUpdate: maxSurge: 1 maxUnavailable: 1 type: RollingUpdate template: metadata: labels: app: pod-apollo-portal-server spec: affinity: podAntiAffinity: preferredDuringSchedulingIgnoredDuringExecution: - weight: 100 podAffinityTerm: labelSelector: matchExpressions: - key: app operator: In values: - pod-apollo-portal-server topologyKey: kubernetes.io/hostname volumes: - name: volume-configmap-apollo-portal-server configMap: name: configmap-apollo-portal-server items: - key: application-github.properties path: application-github.properties - key: apollo-env.properties path: apollo-env.properties containers: - image: apolloconfig/apollo-portal:1.9.2 securityContext: privileged: true imagePullPolicy: IfNotPresent name: container-apollo-portal-server ports: - protocol: TCP containerPort: 8070 volumeMounts: - name: volume-configmap-apollo-portal-server mountPath: /apollo-portal/config/application-github.properties subPath: application-github.properties - name: volume-configmap-apollo-portal-server mountPath: /apollo-portal/config/apollo-env.properties subPath: apollo-env.properties env: - name: APOLLO_PORTAL_SERVICE_NAME value: "service-apollo-portal-server.sre" readinessProbe: tcpSocket: port: 8070 initialDelaySeconds: 10 periodSeconds: 5 livenessProbe: tcpSocket: port: 8070 # 120s 内, server 未启动则重启 container initialDelaySeconds: 120 periodSeconds: 15 dnsPolicy: ClusterFirst restartPolicy: Always