deployment-portal.yaml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. ---
  2. # configmap for apollo-portal
  3. kind: ConfigMap
  4. apiVersion: v1
  5. metadata:
  6. {{- $portalFullName := include "apollo.portal.fullName" . }}
  7. name: {{ $portalFullName }}
  8. data:
  9. application-github.properties: |
  10. spring.datasource.url = jdbc:mysql://{{include "apollo.portaldb.serviceName" .}}:{{ .Values.portaldb.service.port }}/{{ .Values.portaldb.dbName }}{{ if .Values.portaldb.connectionStringProperties }}?{{ .Values.portaldb.connectionStringProperties }}{{ end }}
  11. spring.datasource.username = {{ required "portaldb.userName is required!" .Values.portaldb.userName }}
  12. spring.datasource.password = {{ required "portaldb.password is required!" .Values.portaldb.password }}
  13. {{- if .Values.config.envs }}
  14. apollo.portal.envs = {{ .Values.config.envs }}
  15. {{- end }}
  16. {{- if .Values.config.contextPath }}
  17. server.servlet.context-path = {{ .Values.config.contextPath }}
  18. {{- end }}
  19. apollo-env.properties: |
  20. {{- range $env, $address := .Values.config.metaServers }}
  21. {{ $env }}.meta = {{ $address }}
  22. {{- end }}
  23. {{- range $fileName, $content := .Values.config.files }}
  24. {{ $fileName | indent 2 }}: |
  25. {{ $content | indent 4 }}
  26. {{- end }}
  27. ---
  28. kind: Deployment
  29. apiVersion: apps/v1
  30. metadata:
  31. name: {{ $portalFullName }}
  32. labels:
  33. {{- include "apollo.portal.labels" . | nindent 4 }}
  34. spec:
  35. replicas: {{ .Values.replicaCount }}
  36. selector:
  37. matchLabels:
  38. app: {{ $portalFullName }}
  39. {{- with .Values.strategy }}
  40. strategy:
  41. {{- toYaml . | nindent 4 }}
  42. {{- end }}
  43. template:
  44. metadata:
  45. labels:
  46. app: {{ $portalFullName }}
  47. spec:
  48. {{- with .Values.imagePullSecrets }}
  49. imagePullSecrets:
  50. {{- toYaml . | nindent 8 }}
  51. {{- end }}
  52. volumes:
  53. - name: configmap-{{ $portalFullName }}
  54. configMap:
  55. name: {{ $portalFullName }}
  56. items:
  57. - key: application-github.properties
  58. path: application-github.properties
  59. - key: apollo-env.properties
  60. path: apollo-env.properties
  61. {{- range $fileName, $content := .Values.config.files }}
  62. - key: {{ $fileName }}
  63. path: {{ $fileName }}
  64. {{- end }}
  65. defaultMode: 420
  66. containers:
  67. - name: {{ .Values.name }}
  68. image: "{{ .Values.image.repository }}:{{ .Chart.AppVersion }}"
  69. imagePullPolicy: {{ .Values.image.pullPolicy }}
  70. ports:
  71. - name: http
  72. containerPort: {{ .Values.containerPort }}
  73. protocol: TCP
  74. env:
  75. - name: SPRING_PROFILES_ACTIVE
  76. value: {{ .Values.config.profiles | quote }}
  77. {{- range $key, $value := .Values.env }}
  78. - name: {{ $key }}
  79. value: {{ $value }}
  80. {{- end }}
  81. volumeMounts:
  82. - name: configmap-{{ $portalFullName }}
  83. mountPath: /apollo-portal/config/application-github.properties
  84. subPath: application-github.properties
  85. - name: configmap-{{ $portalFullName }}
  86. mountPath: /apollo-portal/config/apollo-env.properties
  87. subPath: apollo-env.properties
  88. {{- range $fileName, $content := .Values.config.files }}
  89. - name: configmap-{{ $portalFullName }}
  90. mountPath: /apollo-portal/config/{{ $fileName }}
  91. subPath: {{ $fileName }}
  92. {{- end }}
  93. livenessProbe:
  94. tcpSocket:
  95. port: {{ .Values.containerPort }}
  96. initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
  97. periodSeconds: {{ .Values.liveness.periodSeconds }}
  98. readinessProbe:
  99. httpGet:
  100. path: {{ .Values.config.contextPath }}/health
  101. port: {{ .Values.containerPort }}
  102. initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
  103. periodSeconds: {{ .Values.readiness.periodSeconds }}
  104. resources:
  105. {{- toYaml .Values.resources | nindent 12 }}
  106. {{- with .Values.nodeSelector }}
  107. nodeSelector:
  108. {{- toYaml . | nindent 8 }}
  109. {{- end }}
  110. {{- with .Values.affinity }}
  111. affinity:
  112. {{- toYaml . | nindent 8 }}
  113. {{- end }}
  114. {{- with .Values.tolerations }}
  115. tolerations:
  116. {{- toYaml . | nindent 8 }}
  117. {{- end }}