service-apollo-portal-server.yaml 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. ---
  2. # 为外部 mysql 服务设置 service
  3. kind: Service
  4. apiVersion: v1
  5. metadata:
  6. namespace: sre
  7. name: service-mysql-for-portal-server
  8. labels:
  9. app: service-mysql-for-portal-server
  10. spec:
  11. ports:
  12. - protocol: TCP
  13. port: 3306
  14. targetPort: 3306
  15. type: ClusterIP
  16. sessionAffinity: None
  17. ---
  18. kind: Endpoints
  19. apiVersion: v1
  20. metadata:
  21. namespace: sre
  22. name: service-mysql-for-portal-server
  23. subsets:
  24. - addresses:
  25. # 更改为你的 mysql addresses, 例如 1.1.1.1
  26. # 其中 1.1.1.1、2.2.2.2、3.3.3.3 为你的 mysql 集群, 例如 MySQL-Galera-WSrep 或 TiDB
  27. - ip: your-mysql-addresses
  28. ports:
  29. - protocol: TCP
  30. port: 3306
  31. - addresses:
  32. # 更改为你的 mysql addresses, 例如 2.2.2.2
  33. - ip: your-mysql-addresses
  34. ports:
  35. - protocol: TCP
  36. port: 3306
  37. - addresses:
  38. # 更改为你的 mysql addresses, 例如 3.3.3.3
  39. - ip: your-mysql-addresses
  40. ports:
  41. - protocol: TCP
  42. port: 3306
  43. ---
  44. # configmap for apollo-portal-server
  45. kind: ConfigMap
  46. apiVersion: v1
  47. metadata:
  48. namespace: sre
  49. name: configmap-apollo-portal-server
  50. data:
  51. application-github.properties: |
  52. spring.datasource.url = jdbc:mysql://service-mysql-for-portal-server.sre:3306/ApolloPortalDB?characterEncoding=utf8
  53. # mysql username
  54. spring.datasource.username = FillInCorrectUser
  55. # mysql password
  56. spring.datasource.password = FillInCorrectPassword
  57. apollo-env.properties: |
  58. dev.meta=http://service-apollo-config-server-dev.sre:8080
  59. fat.meta=http://service-apollo-config-server-test-alpha.sre:8080
  60. uat.meta=http://service-apollo-config-server-test-beta.sre:8080
  61. pro.meta=http://service-apollo-config-server-prod.sre:8080
  62. ---
  63. kind: Service
  64. apiVersion: v1
  65. metadata:
  66. namespace: sre
  67. name: service-apollo-portal-server
  68. labels:
  69. app: service-apollo-portal-server
  70. spec:
  71. ports:
  72. - protocol: TCP
  73. port: 8070
  74. targetPort: 8070
  75. nodePort: 30001
  76. selector:
  77. app: pod-apollo-portal-server
  78. type: NodePort
  79. # portal session 保持
  80. sessionAffinity: ClientIP
  81. ---
  82. kind: Deployment
  83. apiVersion: apps/v1beta2
  84. metadata:
  85. namespace: sre
  86. name: deployment-apollo-portal-server
  87. labels:
  88. app: deployment-apollo-portal-server
  89. spec:
  90. # 3 个实例
  91. replicas: 3
  92. selector:
  93. matchLabels:
  94. app: pod-apollo-portal-server
  95. strategy:
  96. rollingUpdate:
  97. maxSurge: 1
  98. maxUnavailable: 1
  99. type: RollingUpdate
  100. template:
  101. metadata:
  102. labels:
  103. app: pod-apollo-portal-server
  104. spec:
  105. nodeSelector:
  106. node: "apollo"
  107. volumes:
  108. - name: volume-configmap-apollo-portal-server
  109. configMap:
  110. name: configmap-apollo-portal-server
  111. items:
  112. - key: application-github.properties
  113. path: application-github.properties
  114. - key: apollo-env.properties
  115. path: apollo-env.properties
  116. initContainers:
  117. # 确保 admin-service 正常提供服务
  118. - image: alpine-bash:3.8
  119. name: check-service-apollo-admin-server-dev
  120. command: ['bash', '-c', "curl --connect-timeout 2 --max-time 5 --retry 60 --retry-delay 1 --retry-max-time 120 service-apollo-admin-server-dev.sre:8090"]
  121. - image: alpine-bash:3.8
  122. name: check-service-apollo-admin-server-dev
  123. command: ['bash', '-c', "curl --connect-timeout 2 --max-time 5 --retry 60 --retry-delay 1 --retry-max-time 120 service-apollo-admin-server-test-alpha.sre:8090"]
  124. - image: alpine-bash:3.8
  125. name: check-service-apollo-admin-server-dev
  126. command: ['bash', '-c', "curl --connect-timeout 2 --max-time 5 --retry 60 --retry-delay 1 --retry-max-time 120 service-apollo-admin-server-test-beta.sre:8090"]
  127. - image: alpine-bash:3.8
  128. name: check-service-apollo-admin-server-dev
  129. command: ['bash', '-c', "curl --connect-timeout 2 --max-time 5 --retry 60 --retry-delay 1 --retry-max-time 120 service-apollo-admin-server-prod.sre:8090"]
  130. containers:
  131. - image: apollo-portal-server:v1.0.0 # 更改为你的 docker registry 下的 image
  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-server/config/application-github.properties
  142. subPath: application-github.properties
  143. - name: volume-configmap-apollo-portal-server
  144. mountPath: /apollo-portal-server/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