forked from badtuxx/giropops-senhas
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create templates for database and observability configmaps
- Loading branch information
1 parent
4e9d23a
commit 8abe588
Showing
7 changed files
with
194 additions
and
0 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 }} |
4 changes: 4 additions & 0 deletions
4
charts/giropops-senhas-chart/templates/database-configmap.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{{- range $component, $config := .Values.databases }} | ||
{{- $data := dict "component" $component "config" $config }} | ||
{{- include "database.configmap" $data | nindent 0 }} | ||
{{- end }} |
26 changes: 26 additions & 0 deletions
26
charts/giropops-senhas-chart/templates/giropops-senhas-deployments.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 }} |
23 changes: 23 additions & 0 deletions
23
charts/giropops-senhas-chart/templates/giropops-senhas-service.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 }} |
4 changes: 4 additions & 0 deletions
4
charts/giropops-senhas-chart/templates/observability-configmap.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{{- range $component, $config := .Values.observability }} | ||
{{- $data := dict "component" $component "config" $config }} | ||
{{- include "observability.configmap" $data | nindent 0 }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" |