Skip to content

Commit

Permalink
Creation of HPA template (#398)
Browse files Browse the repository at this point in the history
Co-authored-by: Brandon Foley <[email protected]>
Co-authored-by: Brandon Foley <[email protected]>
  • Loading branch information
3 people authored Oct 15, 2024
1 parent d45a77a commit b2e15d9
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 19 deletions.
41 changes: 22 additions & 19 deletions pkg/config/draftconfig_template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,28 @@ var validVariableTypes = map[string]bool{
"object": true,
}
var validVariableKinds = map[string]bool{
"azureContainerRegistry": true,
"azureKeyvaultUri": true,
"azureManagedCluster": true,
"azureResourceGroup": true,
"azureServiceConnection": true,
"containerImageName": true,
"containerImageVersion": true,
"dirPath": true,
"dockerFileName": true,
"filePath": true,
"flag": true,
"helmChartOverrides": true,
"ingressHostName": true,
"kubernetesNamespace": true,
"kubernetesResourceName": true,
"label": true,
"port": true,
"repositoryBranch": true,
"workflowName": true,
"azureContainerRegistry": true,
"azureKeyvaultUri": true,
"azureManagedCluster": true,
"azureResourceGroup": true,
"azureServiceConnection": true,
"containerImageName": true,
"containerImageVersion": true,
"dirPath": true,
"dockerFileName": true,
"filePath": true,
"flag": true,
"helmChartOverrides": true,
"ingressHostName": true,
"kubernetesNamespace": true,
"kubernetesResourceName": true,
"label": true,
"port": true,
"repositoryBranch": true,
"workflowName": true,
"replicaCount": true,
"scalingResourceType": true,
"scalingResourceUtilization": true,
}

/*
Expand Down
42 changes: 42 additions & 0 deletions template/manifests/PodDisruptionBudget/manifest/draft.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
templateName: "podDisruptionBudget-manifest"
description: "This template is used to create a PodDisruptionBudget for an application"
type: "manifest"
variables:
- name: "APPNAME"
type: "string"
kind: "kubernetesResourceName"
description: "the name of the application"
- name: "PARTOF"
type: "string"
kind: "label"
description: "the label to identify which project the resource belong to"
- name: "GENERATORLABEL"
type: "string"
kind: "label"
description: "the label to identify who generated the resource"
default:
value: "draft"
- name: "MINIMUMREPLICAS"
type: "int"
kind: "replicaCount"
description: "specifies the minimum number of pod replicas that the deployment should have"
default:
value: 2
- name: "MAXIMUMREPLICAS"
type: "int"
kind: "replicaCount"
description: "defines the maximum number of pod replicas the deployment can scale to"
default:
value: 5
- name: "RESOURCETYPE"
type: "string"
kind: "scalingResourceType"
description: "specifies the resource type (e.g., cpu or memory) to be monitored for scaling"
default:
value: "cpu"
- name: "AVGUTILIZATION"
type: "int"
kind: "scalingResourceUtilization"
description: "specifies the average utilization for the monitored resource, triggering scaling when exceeded"
default:
value: 80
22 changes: 22 additions & 0 deletions template/manifests/PodDisruptionBudget/manifest/hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{.APPNAME}}
labels:
app.kubernetes.io/name: {{.APPNAME}}
app.kubernetes.io/part-of: {{.PARTOF}}
kubernetes.azure.com/generator: {{.GENERATORLABEL}}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{.APPNAME}}
minReplicas: {{.MINIMUMREPLICAS}}
maxReplicas: {{.MAXIMUMREPLICAS}}
metrics:
- type: Resource
resource:
name: {{.RESOURCETYPE}}
target:
type: Utilization
averageUtilization: {{.AVGUTILIZATION}}

0 comments on commit b2e15d9

Please sign in to comment.