diff --git a/Makefile b/Makefile index afdca66..b0167a1 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,6 @@ create-kind-cluster: deploy: kubectl apply -f k8s - sleep 3 $(MAKE) port-forward delete: @@ -18,14 +17,14 @@ delete: redeploy: $(MAKE) delete $(MAKE) deploy - sleep 3 $(MAKE) port-forward port-forward: + sleep 4 kubectl port-forward svc/go-http-app-service 8000:80 install-metrics-components: kubectl apply -f k8s/metrics-server.yaml kubectl wait --namespace kube-system \ --for=condition=available deployment/metrics-server \ - --timeout=200s + --timeout=60s diff --git a/k8s/deployment.yaml b/k8s/deployment.yaml index bd925fb..7ef1753 100644 --- a/k8s/deployment.yaml +++ b/k8s/deployment.yaml @@ -17,7 +17,7 @@ spec: spec: containers: - name: go-http-app - image: wesleywillians/hello-go:v5.5 # Probe on port /healthz (+ readiness check: if app is up < 10s it will fail. This way, readiness will only be "ready" when the pod is healthy) + image: wesleywillians/hello-go:v9.6 resources: requests: cpu: "0.03" diff --git a/k8s/hpa.yaml b/k8s/hpa.yaml new file mode 100644 index 0000000..10dadb6 --- /dev/null +++ b/k8s/hpa.yaml @@ -0,0 +1,18 @@ +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: go-http-app-hpa +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: go-http-app + minReplicas: 2 + maxReplicas: 10 + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: 35