Skip to content

Commit

Permalink
adicionando mais coisas sobre o helm
Browse files Browse the repository at this point in the history
  • Loading branch information
badtuxx committed Feb 13, 2024
1 parent 020e8a0 commit b2857c3
Show file tree
Hide file tree
Showing 11 changed files with 975 additions and 1 deletion.
790 changes: 789 additions & 1 deletion pt/day-16/README.md

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions pt/day-16/files/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# charts-example
Empty file.
7 changes: 7 additions & 0 deletions pt/day-16/files/charts/giropops-senhas/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v2
name: giropops-senhas
description: Esse é o chart do Giropops-Senhas, utilizados nos laboratórios de Kubernetes.
version: 0.1.0
appVersion: 0.1.0
sources:
- https://github.com/badtuxx/giropops-senhas
45 changes: 45 additions & 0 deletions pt/day-16/files/charts/giropops-senhas/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{{/* Define a base para reutilização de labels */}}
{{- define "app.labels" -}}
app: {{ .labels.app | quote }}
env: {{ .labels.env | quote }}
live: {{ .labels.live | quote }}
{{- end }}

{{/* Template para especificações de recursos de containers */}}
{{- define "app.resources" -}}
requests:
memory: {{ .resources.requests.memory }}
cpu: {{ .resources.requests.cpu }}
limits:
memory: {{ .resources.limits.memory }}
cpu: {{ .resources.limits.cpu }}
{{- end }}

{{/* Template para definição de portas em containers */}}
{{- define "app.ports" -}}
{{- range .ports }}
- containerPort: {{ .port }}
{{- end }}
{{- end }}

{{/* Template para gerar um ConfigMap para configurações de banco de dados */}}
{{- define "database.configmap" -}}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .component }}-db-config
data:
app-config.yaml: |
{{- toYaml .config | nindent 4 }}
{{- end }}

{{/* Template para gerar um ConfigMap para configurações de observabilidade */}}
{{- define "observability.configmap" -}}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .component }}-observability-config
data:
app-config.json: |
{{ toJson .config }}
{{- end }}
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 }}
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 }}
33 changes: 33 additions & 0 deletions pt/day-16/files/charts/giropops-senhas/templates/deployments.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{{- 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 3 }}
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 }}
{{- if $config.env }}
env:
{{- range $config.env }}
- name: {{ .name }}
value: {{ .value }}
{{- end }}
{{- end }}
---
{{- end }}
23 changes: 23 additions & 0 deletions pt/day-16/files/charts/giropops-senhas/templates/services.yaml
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 }}
69 changes: 69 additions & 0 deletions pt/day-16/files/charts/giropops-senhas/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
deployments:
giropops-senhas:
name: "giropops-senhas"
image: "linuxtips/giropops-senhas:1.0"
replicas: 2
labels:
app: "giropops-senhas"
env: "labs"
live: "true"
resources:
requests:
memory: "128Mi"
cpu: "250m"
limits:
memory: "256Mi"
cpu: "500m"
redis:
image: "redis"
replicas: 1
port: 6379
labels:
app: "redis"
env: "labs"
live: "true"
resources:
requests:
memory: "128Mi"
cpu: "250m"
limits:
memory: "256Mi"
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:
type: "MySQL"
host: "mysql.svc.cluster.local"
port: 3306
name: "MyDB"
Binary file added pt/day-16/images/github-pages.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit b2857c3

Please sign in to comment.