1
0

service-apollo-portal-server.yaml 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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. - ip: your-mysql-addresses
  27. ports:
  28. - protocol: TCP
  29. port: 3306
  30. ---
  31. # configmap for apollo-portal-server
  32. kind: ConfigMap
  33. apiVersion: v1
  34. metadata:
  35. namespace: sre
  36. name: configmap-apollo-portal-server
  37. data:
  38. application-github.properties: |
  39. spring.datasource.url = jdbc:mysql://service-mysql-for-portal-server.sre:3306/ApolloPortalDB?characterEncoding=utf8
  40. # mysql username
  41. spring.datasource.username = FillInCorrectUser
  42. # mysql password
  43. spring.datasource.password = FillInCorrectPassword
  44. apollo-env.properties: |
  45. dev.meta=http://service-apollo-config-server-dev.sre:8080
  46. fat.meta=http://service-apollo-config-server-test-alpha.sre:8080
  47. uat.meta=http://service-apollo-config-server-test-beta.sre:8080
  48. pro.meta=http://service-apollo-config-server-prod.sre:8080
  49. ---
  50. kind: Service
  51. apiVersion: v1
  52. metadata:
  53. namespace: sre
  54. name: service-apollo-portal-server
  55. labels:
  56. app: service-apollo-portal-server
  57. spec:
  58. ports:
  59. - protocol: TCP
  60. port: 8070
  61. targetPort: 8070
  62. nodePort: 30001
  63. selector:
  64. app: pod-apollo-portal-server
  65. type: NodePort
  66. # portal session 保持
  67. sessionAffinity: ClientIP
  68. ---
  69. kind: Deployment
  70. apiVersion: apps/v1
  71. metadata:
  72. namespace: sre
  73. name: deployment-apollo-portal-server
  74. labels:
  75. app: deployment-apollo-portal-server
  76. spec:
  77. # 3 个实例
  78. replicas: 3
  79. selector:
  80. matchLabels:
  81. app: pod-apollo-portal-server
  82. strategy:
  83. rollingUpdate:
  84. maxSurge: 1
  85. maxUnavailable: 1
  86. type: RollingUpdate
  87. template:
  88. metadata:
  89. labels:
  90. app: pod-apollo-portal-server
  91. spec:
  92. affinity:
  93. podAntiAffinity:
  94. preferredDuringSchedulingIgnoredDuringExecution:
  95. - weight: 100
  96. podAffinityTerm:
  97. labelSelector:
  98. matchExpressions:
  99. - key: app
  100. operator: In
  101. values:
  102. - pod-apollo-portal-server
  103. topologyKey: kubernetes.io/hostname
  104. volumes:
  105. - name: volume-configmap-apollo-portal-server
  106. configMap:
  107. name: configmap-apollo-portal-server
  108. items:
  109. - key: application-github.properties
  110. path: application-github.properties
  111. - key: apollo-env.properties
  112. path: apollo-env.properties
  113. initContainers:
  114. # 确保 admin-service 正常提供服务
  115. - image: alpine-bash:3.8
  116. name: check-service-apollo-admin-server-dev
  117. 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"]
  118. - image: alpine-bash:3.8
  119. name: check-service-apollo-admin-server-alpha
  120. 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"]
  121. - image: alpine-bash:3.8
  122. name: check-service-apollo-admin-server-beta
  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-beta.sre:8090"]
  124. - image: alpine-bash:3.8
  125. name: check-service-apollo-admin-server-prod
  126. 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"]
  127. containers:
  128. - image: apollo-portal-server:v1.0.0 # 更改为你的 docker registry 下的 image
  129. securityContext:
  130. privileged: true
  131. imagePullPolicy: IfNotPresent
  132. name: container-apollo-portal-server
  133. ports:
  134. - protocol: TCP
  135. containerPort: 8070
  136. volumeMounts:
  137. - name: volume-configmap-apollo-portal-server
  138. mountPath: /apollo-portal-server/config/application-github.properties
  139. subPath: application-github.properties
  140. - name: volume-configmap-apollo-portal-server
  141. mountPath: /apollo-portal-server/config/apollo-env.properties
  142. subPath: apollo-env.properties
  143. env:
  144. - name: APOLLO_PORTAL_SERVICE_NAME
  145. value: "service-apollo-portal-server.sre"
  146. readinessProbe:
  147. tcpSocket:
  148. port: 8070
  149. initialDelaySeconds: 10
  150. periodSeconds: 5
  151. livenessProbe:
  152. tcpSocket:
  153. port: 8070
  154. # 120s 内, server 未启动则重启 container
  155. initialDelaySeconds: 120
  156. periodSeconds: 15
  157. dnsPolicy: ClusterFirst
  158. restartPolicy: Always