Skip to content

Commit

Permalink
feat: kustomize
Browse files Browse the repository at this point in the history
  • Loading branch information
StuxxNet authored and ramon.silveira-borges@telekom.com committed Dec 6, 2023
1 parent 309f575 commit 9ecd445
Show file tree
Hide file tree
Showing 13 changed files with 86 additions and 22 deletions.
17 changes: 8 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ KUBE_PROMETHEUS_STACK_CHART_LOCAL_VALUES := configs/helm/kube-prometheus-stack/v
KUBE_PROMETHEUS_STACK_CHART_EKS_VALUES := configs/helm/kube-prometheus-stack/values-eks.yml

GIROPOPS_SENHAS_ROOT := giropops-senhas
GIROPOPS_SENHAS_BASE := ${GIROPOPS_SENHAS_ROOT}/manifests/base
GIROPOPS_SENHAS_LOCAL := ${GIROPOPS_SENHAS_ROOT}/manifests/overlays/kind
GIROPOPS_SENHAS_EKS := ${GIROPOPS_SENHAS_ROOT}/manifests/overlays/eks
GIROPOPS_SENHAS_DOCKERFILE := ${GIROPOPS_SENHAS_ROOT}/Dockerfile
Expand All @@ -52,8 +53,8 @@ delete-kind-cluster: # Remove o cluster local
kind get clusters | grep -i ${CLUSTER_NAME} && kind delete clusters ${CLUSTER_NAME} || echo "Cluster não existe"

set-context-kind: # Seta contexto do Kind
kind get clusters | grep -i ${CLUSTER_NAME} || echo "Cluster não existe" && exit 1
kubectl config set-context ${CLUSTER_NAME}
kind get clusters | grep -i ${CLUSTER_NAME} || (echo "Cluster não existe" && exit 1)
kubectl config set-context kind-${CLUSTER_NAME}

##------------------------------------------------------------------------
## AWS K8S Cluster
Expand Down Expand Up @@ -193,25 +194,22 @@ push-image-dockerhub-ci: # Realiza o push da imagem para o Dockerhub - Som

deploy-giropops-senhas-kind: # Realiza a instalação do Giropops no Kind
kubectl create ns ${GIROPOPS_SENHAS_NAMESPACE} || echo "Namespace já existe"
cd ${GIROPOPS_SENHAS_BASE} && kustomize edit set image giropops-senhas=giropops-senhas-python-chainguard:${GIROPOPS_SENHAS_TAG}
kubectl apply -k ${GIROPOPS_SENHAS_LOCAL}
kubectl rollout restart deployment -n ${GIROPOPS_SENHAS_NAMESPACE} giropops-senhas

deploy-giropops-senhas-eks: # Realiza a instalação do Giropops no EKS
kubectl create ns ${GIROPOPS_SENHAS_NAMESPACE} || echo "Namespace já existe"
cd ${GIROPOPS_SENHAS_BASE} && kustomize edit set image giropops-senhas=${DOCKERHUB_USERNAME}/giropops-senhas-python-chainguard:${GIROPOPS_SENHAS_TAG}
kubectl apply -k ${GIROPOPS_SENHAS_EKS}

update-giropops-senhas-image: # Realiza o update da image no deployment
kubectl set image -n giropops-senhas deployment/giropops-senhas giropops-senhas=${DOCKERHUB_USERNAME}/giropops-senhas-python-chainguard:${GIROPOPS_SENHAS_TAG}
kubectl rollout restart -n giropops-senhas deployment giropops-senhas

deploy-giropops-senhas-local: # Realiza deploy no Kind
$(MAKE) set-context-kind
$(MAKE) deploy-giropops-senhas-kind
$(MAKE) update-giropops-senhas-image

deploy-giropops-senhas-aws: # Realiza deploy no EKS
$(MAKE) set-context-eks
$(MAKE) deploy-giropops-senhas-eks
$(MAKE) update-giropops-senhas-image

delete-giropops-senhas: # Remove a instalação do Giropops
kubectl delete -f ${GIROPOPS_SENHAS_MANIFESTS}
Expand All @@ -232,7 +230,8 @@ deploy-all-local: # Sobe a infra completa localmente num cluster Kind
$(MAKE) deploy-kind-cluster
$(MAKE) deploy-kube-prometheus-stack-local
$(MAKE) deploy-redis-local
$(MAKE) deploy-giropops-senhas
$(MAKE) build-scan-push-local
$(MAKE) deploy-giropops-senhas-local

deploy-infra-aws: # Sobe a infra completa na AWS
$(MAKE) deploy-eks-cluster
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ Ele iniciará o stress-test da aplicação usando como base o scrit [generate-ke

## ToDos e Refinos

- [ ] Ajustar overlays do giropops-senhas;
- [ ] Ajustar os values dos helm charts (ingress, images e resources);
- [ ] Ajustar lint no CI que tá quebrando
- [ ] Teste geral de todos os targets;
Expand Down
2 changes: 1 addition & 1 deletion configs/eksctl/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ iam:
withOIDC: true

nodeGroups:
- name: ng-1
- name: default-nodegroup
instanceType: t3.medium
desiredCapacity: 5
privateNetworking: true
Expand Down
9 changes: 3 additions & 6 deletions giropops-senhas/manifests/base/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ kind: Deployment
metadata:
name: giropops-senhas
namespace: giropops-senhas
labels:
owner: "bravo"
annotations:
email: ramonboorges@gmail.com
spec:
strategy:
type: RollingUpdate
Expand Down Expand Up @@ -34,10 +30,11 @@ spec:
key: REDIS_HOST
resources:
requests:
cpu: 0.5
cpu: "0.25"
memory: 64Mi
limits:
memory: 256Mi
memory: 128Mi
cpu: "0.5"
livenessProbe:
httpGet:
path: /
Expand Down
4 changes: 2 additions & 2 deletions giropops-senhas/manifests/base/hpa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ spec:
apiVersion: apps/v1
kind: Deployment
name: giropops-senhas
minReplicas: 4
maxReplicas: 10
minReplicas: 1
maxReplicas: 3
metrics:
- type: Resource
resource:
Expand Down
3 changes: 1 addition & 2 deletions giropops-senhas/manifests/base/ingress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ metadata:
namespace: giropops-senhas
spec:
rules:
- host: giropops-senhas.svc.cluster.local
http:
- http:
paths:
- path: /
pathType: Prefix
Expand Down
8 changes: 7 additions & 1 deletion giropops-senhas/manifests/base/kustomization.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
commonLabels:
owner: bravo
resources:
- configmap.yml
- serviceaccount.yml
- deployment.yml
- service.yml
- ingress.yml
- service-monitor.yml
- hpa.yml
- hpa.yml
images:
- name: giropops-senhas
newName: giropops-senhas-python-chainguard
newTag: local
22 changes: 22 additions & 0 deletions giropops-senhas/manifests/overlays/eks/deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: giropops-senhas
namespace: giropops-senhas
spec:
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 3
maxUnavailable: 2
template:
spec:
containers:
- name: giropops-senhas
resources:
requests:
cpu: "0.25"
memory: 128Mi
limits:
memory: 256Mi
cpu: "0.5"
8 changes: 8 additions & 0 deletions giropops-senhas/manifests/overlays/eks/hpa.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: giropops-senhas
namespace: giropops-senhas
spec:
minReplicas: 4
maxReplicas: 10
2 changes: 2 additions & 0 deletions giropops-senhas/manifests/overlays/eks/kustomization.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ resources:
- ../../base

patches:
- path: deployment.yml
- path: hpa.yml
- path: ingress.yml
22 changes: 22 additions & 0 deletions giropops-senhas/manifests/overlays/kind/deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: giropops-senhas
namespace: giropops-senhas
spec:
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 2
maxUnavailable: 1
template:
spec:
containers:
- name: giropops-senhas
resources:
requests:
cpu: "0.15"
memory: 32Mi
limits:
memory: 64Mi
cpu: "0.25"
8 changes: 8 additions & 0 deletions giropops-senhas/manifests/overlays/kind/hpa.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: giropops-senhas
namespace: giropops-senhas
spec:
minReplicas: 2
maxReplicas: 4
2 changes: 2 additions & 0 deletions giropops-senhas/manifests/overlays/kind/kustomization.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ resources:
- ../../base

patches:
- path: deployment.yml
- path: hpa.yml
- path: ingress.yml

0 comments on commit 9ecd445

Please sign in to comment.