From 845b84c4048c70a7c7ac98295be7272184ea47ce Mon Sep 17 00:00:00 2001 From: ivan_chuvakhin Date: Fri, 2 Jul 2021 17:54:40 +0300 Subject: [PATCH] helm config for deployment --- spring-petclinic/Chart.yaml | 2 +- spring-petclinic/templates/configmap.yaml | 6 +- spring-petclinic/templates/deployment.yaml | 67 +++++----------- spring-petclinic/templates/service.yaml | 18 ++--- spring-petclinic/values.yaml | 92 +++------------------- 5 files changed, 40 insertions(+), 145 deletions(-) diff --git a/spring-petclinic/Chart.yaml b/spring-petclinic/Chart.yaml index 39fab970f..001ae9040 100644 --- a/spring-petclinic/Chart.yaml +++ b/spring-petclinic/Chart.yaml @@ -21,4 +21,4 @@ version: 0.1.0 # incremented each time you make changes to the application. Versions are not expected to # follow Semantic Versioning. They should reflect the version the application is using. # It is recommended to use it with quotes. -appVersion: "1.16.0" +appVersion: 1.16.0 diff --git a/spring-petclinic/templates/configmap.yaml b/spring-petclinic/templates/configmap.yaml index 1c3ca4aeb..6f6e10dcb 100644 --- a/spring-petclinic/templates/configmap.yaml +++ b/spring-petclinic/templates/configmap.yaml @@ -1,8 +1,8 @@ apiVersion: v1 kind: ConfigMap metadata: - name: petclinic-configmap + name: {{ .Values.petclinic.configmap.name }} data: - application.yml: | + {{ .Values.petclinic.configmap.application.properties.name }}: | server: - port: 8081 + port: {{ .Values.petclinic.server.port }} diff --git a/spring-petclinic/templates/deployment.yaml b/spring-petclinic/templates/deployment.yaml index bec7cf314..26a492f39 100644 --- a/spring-petclinic/templates/deployment.yaml +++ b/spring-petclinic/templates/deployment.yaml @@ -1,61 +1,30 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: {{ include "spring-petclinic.fullname" . }} - labels: - {{- include "spring-petclinic.labels" . | nindent 4 }} + name: petclinic-deployment-{{ .Chart.AppVersion }} spec: - {{- if not .Values.autoscaling.enabled }} - replicas: {{ .Values.replicaCount }} - {{- end }} + replicas: 1 selector: matchLabels: - {{- include "spring-petclinic.selectorLabels" . | nindent 6 }} + app: {{ .Values.petclinic.label }} template: metadata: - {{- with .Values.podAnnotations }} - annotations: - {{- toYaml . | nindent 8 }} - {{- end }} labels: - {{- include "spring-petclinic.selectorLabels" . | nindent 8 }} + app: {{ .Values.petclinic.label }} spec: - {{- with .Values.imagePullSecrets }} - imagePullSecrets: - {{- toYaml . | nindent 8 }} - {{- end }} - serviceAccountName: {{ include "spring-petclinic.serviceAccountName" . }} - securityContext: - {{- toYaml .Values.podSecurityContext | nindent 8 }} containers: - - name: {{ .Chart.Name }} - securityContext: - {{- toYaml .Values.securityContext | nindent 12 }} - image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" - imagePullPolicy: {{ .Values.image.pullPolicy }} + - name: petclinic + image: {{ .Values.petclinic.image }} + imagePullPolicy: Never ports: - - name: http - containerPort: 80 - protocol: TCP - livenessProbe: - httpGet: - path: / - port: http - readinessProbe: - httpGet: - path: / - port: http - resources: - {{- toYaml .Values.resources | nindent 12 }} - {{- with .Values.nodeSelector }} - nodeSelector: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.affinity }} - affinity: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.tolerations }} - tolerations: - {{- toYaml . | nindent 8 }} - {{- end }} + - containerPort: {{ .Values.petclinic.server.port }} + name: "http" + volumeMounts: + - name: app-config + mountPath: /application.yml + subPath: {{ .Values.petclinic.configmap.application.properties.name }} + readOnly: true + volumes: + - name: app-config + configMap: + name: {{ .Values.petclinic.configmap.name }} diff --git a/spring-petclinic/templates/service.yaml b/spring-petclinic/templates/service.yaml index 91b122cfa..bb8a65b53 100644 --- a/spring-petclinic/templates/service.yaml +++ b/spring-petclinic/templates/service.yaml @@ -1,15 +1,13 @@ apiVersion: v1 kind: Service metadata: - name: {{ include "spring-petclinic.fullname" . }} - labels: - {{- include "spring-petclinic.labels" . | nindent 4 }} + name: petclinic-service spec: - type: {{ .Values.service.type }} - ports: - - port: {{ .Values.service.port }} - targetPort: http - protocol: TCP - name: http selector: - {{- include "spring-petclinic.selectorLabels" . | nindent 4 }} + app: {{ .Values.petclinic.label }} + ports: + - name: http + protocol: TCP + port: {{ .Values.petclinic.server.port }} + targetPort: {{ .Values.petclinic.server.port }} + type: NodePort diff --git a/spring-petclinic/values.yaml b/spring-petclinic/values.yaml index 49182eb97..e2101aa92 100644 --- a/spring-petclinic/values.yaml +++ b/spring-petclinic/values.yaml @@ -1,82 +1,10 @@ -# Default values for spring-petclinic. -# This is a YAML-formatted file. -# Declare variables to be passed into your templates. - -replicaCount: 1 - -image: - repository: nginx - pullPolicy: IfNotPresent - # Overrides the image tag whose default is the chart appVersion. - tag: "" - -imagePullSecrets: [] -nameOverride: "" -fullnameOverride: "" - -serviceAccount: - # Specifies whether a service account should be created - create: true - # Annotations to add to the service account - annotations: {} - # The name of the service account to use. - # If not set and create is true, a name is generated using the fullname template - name: "" - -podAnnotations: {} - -podSecurityContext: {} - # fsGroup: 2000 - -securityContext: {} - # capabilities: - # drop: - # - ALL - # readOnlyRootFilesystem: true - # runAsNonRoot: true - # runAsUser: 1000 - -service: - type: ClusterIP - port: 80 - -ingress: - enabled: false - className: "" - annotations: {} - # kubernetes.io/ingress.class: nginx - # kubernetes.io/tls-acme: "true" - hosts: - - host: chart-example.local - paths: - - path: / - pathType: ImplementationSpecific - tls: [] - # - secretName: chart-example-tls - # hosts: - # - chart-example.local - -resources: {} - # We usually recommend not to specify default resources and to leave this as a conscious - # choice for the user. This also increases chances charts run on environments with little - # resources, such as Minikube. If you do want to specify resources, uncomment the following - # lines, adjust them as necessary, and remove the curly braces after 'resources:'. - # limits: - # cpu: 100m - # memory: 128Mi - # requests: - # cpu: 100m - # memory: 128Mi - -autoscaling: - enabled: false - minReplicas: 1 - maxReplicas: 100 - targetCPUUtilizationPercentage: 80 - # targetMemoryUtilizationPercentage: 80 - -nodeSelector: {} - -tolerations: [] - -affinity: {} +petclinic: + server: + port: 8081 + image: spring-petclinic + configmap: + name: petclinic-configmap + application: + properties: + name: application.yml + label: petclinic