_helpers.tpl 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. {{/*
  2. Base library chart helpers for reusable resources.
  3. These templates are included by service subcharts.
  4. */}}
  5. {{- define "base.configmap" -}}
  6. {{- if .Values.config.enabled }}
  7. apiVersion: v1
  8. kind: ConfigMap
  9. metadata:
  10. name: {{ .Values.app.name }}-config
  11. labels:
  12. app: {{ .Values.app.name }}
  13. data:
  14. application.properties: |
  15. spring.application.name={{ .Values.app.name }}
  16. spring.protocol.name=spring
  17. server.port={{ .Values.service.targetPort }}
  18. application.yml: |
  19. {{- .Values.config.yml | toYaml | nindent 4 }}
  20. {{- end }}
  21. {{- end }}
  22. {{- define "base.deployment" -}}
  23. apiVersion: apps/v1
  24. kind: Deployment
  25. metadata:
  26. name: {{ .Values.app.name }}
  27. labels:
  28. app: {{ .Values.app.name }}
  29. spec:
  30. replicas: {{ .Values.app.replicaCount }}
  31. selector:
  32. matchLabels:
  33. app: {{ .Values.app.name }}
  34. template:
  35. metadata:
  36. labels:
  37. app: {{ .Values.app.name }}
  38. {{- with .Values.podAnnotations }}
  39. annotations:
  40. {{- toYaml . | nindent 8 }}
  41. {{- end }}
  42. spec:
  43. {{- with .Values.securityContext }}
  44. securityContext:
  45. {{- toYaml . | nindent 8 }}
  46. {{- end }}
  47. containers:
  48. - name: {{ .Values.app.name }}
  49. image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
  50. imagePullPolicy: {{ .Values.image.pullPolicy }}
  51. ports:
  52. - name: http
  53. containerPort: {{ .Values.service.targetPort }}
  54. protocol: TCP
  55. volumeMounts:
  56. - name: config-volume
  57. mountPath: /etc/config
  58. readOnly: true
  59. env:
  60. - name: JAVA_OPTS
  61. value: "-Xmx512m -Xms256m"
  62. {{- with .Values.resources }}
  63. resources:
  64. {{- toYaml . | nindent 12 }}
  65. {{- end }}
  66. livenessProbe:
  67. httpGet:
  68. path: /actuator/health
  69. port: http
  70. initialDelaySeconds: 30
  71. periodSeconds: 10
  72. readinessProbe:
  73. httpGet:
  74. path: /actuator/health
  75. port: http
  76. initialDelaySeconds: 5
  77. periodSeconds: 5
  78. volumes:
  79. - name: config-volume
  80. configMap:
  81. name: {{ .Values.app.name }}-config
  82. {{- with .Values.nodeSelector }}
  83. nodeSelector:
  84. {{- toYaml . | nindent 8 }}
  85. {{- end }}
  86. {{- with .Values.affinity }}
  87. affinity:
  88. {{- toYaml . | nindent 8 }}
  89. {{- end }}
  90. {{- with .Values.tolerations }}
  91. tolerations:
  92. {{- toYaml . | nindent 8 }}
  93. {{- end }}
  94. {{- end }}
  95. {{- define "base.service" -}}
  96. apiVersion: v1
  97. kind: Service
  98. metadata:
  99. name: {{ .Values.app.name }}
  100. labels:
  101. app: {{ .Values.app.name }}
  102. spec:
  103. type: {{ .Values.service.type }}
  104. ports:
  105. - port: {{ .Values.service.port }}
  106. targetPort: http
  107. protocol: TCP
  108. name: http
  109. selector:
  110. app: {{ .Values.app.name }}
  111. {{- end }}