1
0

service-apollo-portal-server.yaml 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. #
  2. # Copyright 2021 Apollo Authors
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. #
  16. ---
  17. # 为外部 mysql 服务设置 service
  18. kind: Service
  19. apiVersion: v1
  20. metadata:
  21. namespace: sre
  22. name: service-mysql-for-portal-server
  23. labels:
  24. app: service-mysql-for-portal-server
  25. spec:
  26. ports:
  27. - protocol: TCP
  28. port: 3306
  29. targetPort: 3306
  30. type: ClusterIP
  31. sessionAffinity: None
  32. ---
  33. kind: Endpoints
  34. apiVersion: v1
  35. metadata:
  36. namespace: sre
  37. name: service-mysql-for-portal-server
  38. subsets:
  39. - addresses:
  40. # 更改为你的 mysql addresses, 例如 1.1.1.1
  41. - ip: your-mysql-addresses
  42. ports:
  43. - protocol: TCP
  44. port: 3306
  45. ---
  46. # configmap for apollo-portal-server
  47. kind: ConfigMap
  48. apiVersion: v1
  49. metadata:
  50. namespace: sre
  51. name: configmap-apollo-portal-server
  52. data:
  53. application-github.properties: |
  54. spring.datasource.url = jdbc:mysql://service-mysql-for-portal-server.sre:3306/ApolloPortalDB?characterEncoding=utf8
  55. # mysql username
  56. spring.datasource.username = FillInCorrectUser
  57. # mysql password
  58. spring.datasource.password = FillInCorrectPassword
  59. # enabled environments
  60. apollo.portal.envs = dev,fat,uat,pro
  61. apollo-env.properties: |
  62. dev.meta=http://service-apollo-config-server-dev.sre:8080
  63. fat.meta=http://service-apollo-config-server-fat.sre:8080
  64. uat.meta=http://service-apollo-config-server-uat.sre:8080
  65. pro.meta=http://service-apollo-config-server-prod.sre:8080
  66. ---
  67. kind: Service
  68. apiVersion: v1
  69. metadata:
  70. namespace: sre
  71. name: service-apollo-portal-server
  72. labels:
  73. app: service-apollo-portal-server
  74. spec:
  75. ports:
  76. - protocol: TCP
  77. port: 8070
  78. targetPort: 8070
  79. nodePort: 30001
  80. selector:
  81. app: pod-apollo-portal-server
  82. type: NodePort
  83. # portal session 保持
  84. sessionAffinity: ClientIP
  85. ---
  86. kind: Deployment
  87. apiVersion: apps/v1
  88. metadata:
  89. namespace: sre
  90. name: deployment-apollo-portal-server
  91. labels:
  92. app: deployment-apollo-portal-server
  93. spec:
  94. # 2 个实例
  95. replicas: 2
  96. selector:
  97. matchLabels:
  98. app: pod-apollo-portal-server
  99. strategy:
  100. rollingUpdate:
  101. maxSurge: 1
  102. maxUnavailable: 1
  103. type: RollingUpdate
  104. template:
  105. metadata:
  106. labels:
  107. app: pod-apollo-portal-server
  108. spec:
  109. affinity:
  110. podAntiAffinity:
  111. preferredDuringSchedulingIgnoredDuringExecution:
  112. - weight: 100
  113. podAffinityTerm:
  114. labelSelector:
  115. matchExpressions:
  116. - key: app
  117. operator: In
  118. values:
  119. - pod-apollo-portal-server
  120. topologyKey: kubernetes.io/hostname
  121. volumes:
  122. - name: volume-configmap-apollo-portal-server
  123. configMap:
  124. name: configmap-apollo-portal-server
  125. items:
  126. - key: application-github.properties
  127. path: application-github.properties
  128. - key: apollo-env.properties
  129. path: apollo-env.properties
  130. containers:
  131. - image: apolloconfig/apollo-portal:1.9.2
  132. securityContext:
  133. privileged: true
  134. imagePullPolicy: IfNotPresent
  135. name: container-apollo-portal-server
  136. ports:
  137. - protocol: TCP
  138. containerPort: 8070
  139. volumeMounts:
  140. - name: volume-configmap-apollo-portal-server
  141. mountPath: /apollo-portal/config/application-github.properties
  142. subPath: application-github.properties
  143. - name: volume-configmap-apollo-portal-server
  144. mountPath: /apollo-portal/config/apollo-env.properties
  145. subPath: apollo-env.properties
  146. env:
  147. - name: APOLLO_PORTAL_SERVICE_NAME
  148. value: "service-apollo-portal-server.sre"
  149. readinessProbe:
  150. tcpSocket:
  151. port: 8070
  152. initialDelaySeconds: 10
  153. periodSeconds: 5
  154. livenessProbe:
  155. tcpSocket:
  156. port: 8070
  157. # 120s 内, server 未启动则重启 container
  158. initialDelaySeconds: 120
  159. periodSeconds: 15
  160. dnsPolicy: ClusterFirst
  161. restartPolicy: Always