Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kustomize: add HorizontalPodAutoscaler to Clair+Mirror (PROJQUAY-1449) #452

Merged
merged 1 commit into from
Apr 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions kustomize/components/clair/clair.horizontalpodautoscaler.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
name: clair-app
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: clair-app
minReplicas: 2
maxReplicas: 10
# TODO: Use custom Prometheus metrics (https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#support-for-metrics-apis)
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 90
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: 90
1 change: 1 addition & 0 deletions kustomize/components/clair/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ resources:
- ./clair.serviceaccount.yaml
- ./postgres.serviceaccount.yaml
- ./clair.deployment.yaml
- ./clair.horizontalpodautoscaler.yaml
- ./clair.service.yaml
- ./postgres.persistentvolumeclaim.yaml
- ./postgres.deployment.yaml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ spec:
apiVersion: apps/v1
kind: Deployment
name: quay-app
minReplicas: 1
minReplicas: 2
maxReplicas: 20
# TODO: Use custom Prometheus metrics (https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#support-for-metrics-apis)
metrics:
Expand Down
1 change: 1 addition & 0 deletions kustomize/components/mirror/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apiVersion: kustomize.config.k8s.io/v1alpha1
kind: Component
resources:
- ./mirror.deployment.yaml
- ./mirror.horizontalpodautoscaler.yaml
vars:
- name: QUAY_APP_SERVICE_HOST
objref:
Expand Down
25 changes: 25 additions & 0 deletions kustomize/components/mirror/mirror.horizontalpodautoscaler.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
name: quay-mirror
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: quay-mirror
minReplicas: 2
maxReplicas: 20
# TODO: Use custom Prometheus metrics (https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#support-for-metrics-apis)
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 90
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: 90
10 changes: 9 additions & 1 deletion pkg/kustomize/kustomize_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
objectbucket "github.com/kube-object-storage/lib-bucket-provisioner/pkg/apis/objectbucket.io/v1alpha1"
"github.com/stretchr/testify/assert"
appsv1 "k8s.io/api/apps/v1"
autoscaling "k8s.io/api/autoscaling/v2beta2"
batchv1 "k8s.io/api/batch/v1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/meta"
Expand Down Expand Up @@ -219,6 +220,7 @@ var quayComponents = map[string][]client.Object{
&corev1.Secret{ObjectMeta: metav1.ObjectMeta{Name: "clair-config-secret"}},
&appsv1.Deployment{ObjectMeta: metav1.ObjectMeta{Name: "clair-app"}},
&corev1.Service{ObjectMeta: metav1.ObjectMeta{Name: "clair-app"}},
&autoscaling.HorizontalPodAutoscaler{ObjectMeta: metav1.ObjectMeta{Name: "clair-app"}},
&appsv1.Deployment{ObjectMeta: metav1.ObjectMeta{Name: "clair-postgres"}},
&corev1.PersistentVolumeClaim{ObjectMeta: metav1.ObjectMeta{Name: "clair-postgres"}},
&corev1.Service{ObjectMeta: metav1.ObjectMeta{Name: "clair-postgres"}},
Expand Down Expand Up @@ -247,6 +249,10 @@ var quayComponents = map[string][]client.Object{
},
"mirror": {
&appsv1.Deployment{ObjectMeta: metav1.ObjectMeta{Name: "quay-mirror"}},
&autoscaling.HorizontalPodAutoscaler{ObjectMeta: metav1.ObjectMeta{Name: "quay-mirror"}},
},
"horizontalpodautoscaler": {
&autoscaling.HorizontalPodAutoscaler{ObjectMeta: metav1.ObjectMeta{Name: "quay-app"}},
},
}

Expand Down Expand Up @@ -277,6 +283,7 @@ var inflateTests = []struct {
{Kind: "redis", Managed: true},
{Kind: "objectstorage", Managed: true},
{Kind: "mirror", Managed: true},
{Kind: "horizontalpodautoscaler", Managed: true},
},
},
},
Expand All @@ -288,7 +295,7 @@ var inflateTests = []struct {
"config.yaml": encode(map[string]interface{}{"SERVER_HOSTNAME": "quay.io"}),
},
},
withComponents([]string{"base", "clair", "postgres", "redis", "objectstorage", "mirror"}),
withComponents([]string{"base", "clair", "postgres", "redis", "objectstorage", "mirror", "horizontalpodautoscaler"}),
nil,
},
{
Expand All @@ -301,6 +308,7 @@ var inflateTests = []struct {
{Kind: "redis", Managed: false},
{Kind: "objectstorage", Managed: false},
{Kind: "mirror", Managed: false},
{Kind: "horizontalpodautoscaler", Managed: false},
},
},
},
Expand Down