From fcee7c3cf0b9c7a2558854cd7e6cb0287ebe4fa4 Mon Sep 17 00:00:00 2001 From: suyiiyii Date: Tue, 21 Jan 2025 19:42:23 +0800 Subject: [PATCH] feat(deployment): parameterize deployment configuration for multiple services --- templates/auth-deployment.yaml | 16 +++++++++------- values.yaml | 15 ++++++++------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/templates/auth-deployment.yaml b/templates/auth-deployment.yaml index b1e0b51..496d8ea 100644 --- a/templates/auth-deployment.yaml +++ b/templates/auth-deployment.yaml @@ -1,22 +1,23 @@ +{{- range $index, $deployment := .Values.deployments }} apiVersion: apps/v1 kind: Deployment metadata: - name: auth + name: {{ $deployment.name }} labels: - app: auth + app: {{ $deployment.name }} spec: - replicas: 1 + replicas: {{ $deployment.replicas }} selector: matchLabels: - app: auth + app: {{ $deployment.name }} template: metadata: labels: - app: auth + app: {{ $deployment.name }} spec: containers: - - image: {{ .Values.registry }}/suyiiyii/hertz101-auth:{{ .Values.tag }} - name: badger + - image: {{ $.Values.registry }}/suyiiyii/hertz101-{{ $deployment.name }}:{{ $.Values.tag }} + name: {{ $deployment.name }} resources: limits: memory: "512Mi" @@ -25,3 +26,4 @@ spec: memory: "64Mi" cpu: "200m" restartPolicy: Always +{{- end }} \ No newline at end of file diff --git a/values.yaml b/values.yaml index 1cd9ac0..c0702e6 100644 --- a/values.yaml +++ b/values.yaml @@ -1,10 +1,11 @@ -# Default values for hertz101. -# This is a YAML-formatted file. -# Declare variables to be passed into your templates. -# This will set the replicaset count more information can be found here: https://kubernetes.io/docs/concepts/workloads/controllers/replicaset/ -replicaCount: 1 - -# This sets the container image more information can be found here: https://kubernetes.io/docs/concepts/containers/images/ registry: ghcr.io tag: main + +deployments: + - name: user + replicas: 1 + - name: auth + replicas: 2 + - name: facade + replicas: 3 \ No newline at end of file