diff --git a/giropops-senhas-chart/Chart.yaml b/charts/giropops-senhas-chart/Chart.yaml similarity index 100% rename from giropops-senhas-chart/Chart.yaml rename to charts/giropops-senhas-chart/Chart.yaml diff --git a/charts/giropops-senhas-chart/templates/_helpers.tpl b/charts/giropops-senhas-chart/templates/_helpers.tpl new file mode 100644 index 0000000..0b7bab9 --- /dev/null +++ b/charts/giropops-senhas-chart/templates/_helpers.tpl @@ -0,0 +1,58 @@ +{{/* +Criar as nossas tags +*/}} +{{- define "app.labels" -}} +app: {{ .labels.app | quote }} +env: {{ .labels.env | quote }} +live: {{ .labels.live | quote }} +{{- end }} + +{{/* +Definir os limites de recursos +*/}} +{{- define "app.resources" -}} +requests: + memory: {{ .resources.requests.memory }} + cpu: {{ .resources.requests.cpu }} +limits: + memory: {{ .resources.limits.memory }} + cpu: {{ .resources.limits.cpu }} +{{- end }} + + +{{/* +Definir as portas dos containers +*/}} +{{- define "app.ports" -}} +{{ range .ports }} +- containerPort: {{ .port }} +{{- end }} +{{- end }} + + +{{/* +Definindo os nossos configmaps +*/}} +{{- define "database.configmap" -}} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .component }}-db-config +data: + app-config.yaml: | + {{- toYaml .config | nindent 4 }} +{{- end }} + + +{{/* +Definindo os nossos configmaps +*/}} +{{- define "observability.configmap" -}} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .component }}-observability-config +data: + app-config.json: | + {{ toJson .config }} +{{- end }} diff --git a/charts/giropops-senhas-chart/templates/database-configmap.yaml b/charts/giropops-senhas-chart/templates/database-configmap.yaml new file mode 100644 index 0000000..a61c3c1 --- /dev/null +++ b/charts/giropops-senhas-chart/templates/database-configmap.yaml @@ -0,0 +1,4 @@ +{{- range $component, $config := .Values.databases }} + {{- $data := dict "component" $component "config" $config }} + {{- include "database.configmap" $data | nindent 0 }} +{{- end }} diff --git a/charts/giropops-senhas-chart/templates/giropops-senhas-deployments.yaml b/charts/giropops-senhas-chart/templates/giropops-senhas-deployments.yaml new file mode 100644 index 0000000..e1baacb --- /dev/null +++ b/charts/giropops-senhas-chart/templates/giropops-senhas-deployments.yaml @@ -0,0 +1,26 @@ +{{- range $component, $config := .Values.deployments }} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ $component }} + labels: + {{- include "app.labels" $config | nindent 4 }} +spec: + replicas: {{ $config.replicas | default 2 }} + selector: + matchLabels: + app: {{ $config.labels.app }} + template: + metadata: + labels: + {{- include "app.labels" $config | nindent 8 }} + spec: + containers: + - name: {{ $component }} + image: {{ $config.image }} + ports: + {{- include "app.ports" $config | nindent 10 }} + resources: + {{- include "app.resources" $config | nindent 12 }} +--- +{{- end }} diff --git a/charts/giropops-senhas-chart/templates/giropops-senhas-service.yaml b/charts/giropops-senhas-chart/templates/giropops-senhas-service.yaml new file mode 100644 index 0000000..3b7dcc7 --- /dev/null +++ b/charts/giropops-senhas-chart/templates/giropops-senhas-service.yaml @@ -0,0 +1,23 @@ +{{- range $component, $config := .Values.services }} + {{- range $port := $config.ports }} +apiVersion: v1 +kind: Service +metadata: + name: {{ $component }}-{{ $port.name }} + labels: + {{- include "app.labels" $config | nindent 4 }} +spec: + type: {{ $port.serviceType }} + ports: + - port: {{ $port.port }} + targetPort: {{ $port.targetPort }} + protocol: TCP + name: {{ $port.name }} + {{- if eq $port.serviceType "NodePort" }} + nodePort: {{ $port.nodePort }} + {{- end }} + selector: + app: {{ $config.labels.app }} +--- + {{- end }} +{{- end }} diff --git a/charts/giropops-senhas-chart/templates/observability-configmap.yaml b/charts/giropops-senhas-chart/templates/observability-configmap.yaml new file mode 100644 index 0000000..b98be33 --- /dev/null +++ b/charts/giropops-senhas-chart/templates/observability-configmap.yaml @@ -0,0 +1,4 @@ +{{- range $component, $config := .Values.observability }} + {{- $data := dict "component" $component "config" $config }} + {{- include "observability.configmap" $data | nindent 0 }} +{{- end }} diff --git a/charts/giropops-senhas-chart/values.yaml b/charts/giropops-senhas-chart/values.yaml new file mode 100644 index 0000000..0a46dcf --- /dev/null +++ b/charts/giropops-senhas-chart/values.yaml @@ -0,0 +1,79 @@ +deployments: + giropops-senhas: + name: "giropops-senhas" + image: "linuxtips/giropops-senhas:1.0" + replicas: "3" + ports: + - port: 5000 + targetPort: 5000 + name: "giropops-senhas-port" + serviceType: "NodePort" + NodePort: 32500 + - port: 8088 + targetPort: 8088 + name: "giropops-senhas-metrics" + serviceType: "ClusterIP" + labels: + app: "giropops-senhas" + env: "labs" + live: "true" + resources: + requests: + memory: "64Mi" + cpu: "250m" + limits: + memory: "128Mi" + cpu: "500m" + redis: + name: "redis-helm" + image: "redis" + replicas: "1" + labels: + app: "redis" + env: "labs" + live: "true" + resources: + requests: + memory: "64Mi" + cpu: "250m" + limits: + memory: "128Mi" + cpu: "500m" +services: + giropops-senhas: + ports: + - port: 5000 + targetPort: 5000 + name: "app" + serviceType: "NodePort" + NodePort: 32500 + - port: 8088 + targetPort: 8088 + name: "metrics" + serviceType: "ClusterIP" + labels: + app: "giropops-senhas" + env: "labs" + live: "true" + redis: + ports: + - port: 6379 + targetPort: 6379 + name: "service" + serviceType: "ClusterIP" + labels: + app: "redis" + env: "labs" + live: "true" +observability: + giropops-senhas: + logging: true + metrics: + enabled: true + path: "/metrics" +databases: + giropops-senhas: + mysql: + host: "mysql.svc.cluster.local" + port: 3306 + name: "MyDB"