-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(metrics-operator): add HPA integration test (#2195)
Signed-off-by: realanna <anna.reale@dynatrace.com> Signed-off-by: RealAnna <89971034+RealAnna@users.noreply.github.com> Co-authored-by: Florian Bacher <florian.bacher@dynatrace.com> Co-authored-by: odubajDT <93584209+odubajDT@users.noreply.github.com>
- Loading branch information
1 parent
ac85d0d
commit 4342d33
Showing
6 changed files
with
258 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: podtato-head-entry | ||
labels: | ||
app: podtato-head | ||
spec: | ||
selector: | ||
matchLabels: | ||
component: podtato-head-entry | ||
replicas: 1 | ||
template: | ||
metadata: | ||
labels: | ||
component: podtato-head-entry | ||
spec: | ||
terminationGracePeriodSeconds: 5 | ||
containers: | ||
- name: server | ||
image: ghcr.io/podtato-head/entry:0.2.8 | ||
imagePullPolicy: Always | ||
resources: | ||
limits: | ||
cpu: 10m | ||
memory: 128Mi | ||
requests: | ||
cpu: 5m | ||
memory: 64Mi | ||
ports: | ||
- containerPort: 9000 | ||
env: | ||
- name: PODTATO_PORT | ||
value: "9000" | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: podtato-head-entry | ||
labels: | ||
app: podtato-head | ||
spec: | ||
selector: | ||
component: podtato-head-entry | ||
ports: | ||
- name: http | ||
port: 9000 | ||
protocol: TCP | ||
targetPort: 9000 | ||
type: ClusterIP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestStep | ||
commands: | ||
- script: | | ||
kubectl apply -f mock-server.yaml -n $NAMESPACE | ||
# substitutes namespace, making sure they are changed to env var first | ||
# to prevent bad files in case of a test interrupt | ||
- script: | | ||
echo "registering the metric" | ||
envsubst < metric.yaml | kubectl apply -f - -n $NAMESPACE | ||
echo "configuring HPA" | ||
kubectl apply -f hpa.yaml -n $NAMESPACE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: podtato-head-entry | ||
labels: | ||
app: podtato-head | ||
spec: | ||
selector: | ||
matchLabels: | ||
component: podtato-head-entry | ||
replicas: 3 | ||
template: | ||
metadata: | ||
labels: | ||
component: podtato-head-entry |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
apiVersion: autoscaling/v2 | ||
kind: HorizontalPodAutoscaler | ||
metadata: | ||
name: podtato-metrics-hpa | ||
spec: | ||
scaleTargetRef: | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
name: podtato-head-entry | ||
minReplicas: 1 | ||
maxReplicas: 3 | ||
metrics: | ||
- type: Object | ||
object: | ||
metric: | ||
name: cpu-throttling | ||
describedObject: | ||
apiVersion: metrics.keptn.sh/v1alpha3 | ||
kind: KeptnMetric | ||
name: cpu-throttling | ||
target: | ||
type: Value | ||
value: "0.05" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
apiVersion: metrics.keptn.sh/v1alpha3 | ||
kind: KeptnMetricsProvider | ||
metadata: | ||
name: my-provider | ||
spec: | ||
type: prometheus | ||
targetServer: "http://mockserver.$NAMESPACE.svc.cluster.local:1080" | ||
--- | ||
apiVersion: metrics.keptn.sh/v1alpha3 | ||
kind: KeptnMetric | ||
metadata: | ||
name: cpu-throttling | ||
spec: | ||
provider: | ||
name: my-provider | ||
query: 'avg(rate(container_cpu_cfs_throttled_seconds_total{container="server", namespace="podtato-metrics"}))' | ||
fetchIntervalSeconds: 10 | ||
range: | ||
interval: "1m" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: mockserver | ||
spec: | ||
ports: | ||
- name: serviceport | ||
port: 1080 | ||
protocol: TCP | ||
targetPort: serviceport | ||
selector: | ||
app: mockserver | ||
sessionAffinity: None | ||
type: ClusterIP | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
labels: | ||
app: mockserver | ||
name: mockserver | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: mockserver | ||
template: | ||
metadata: | ||
labels: | ||
app: mockserver | ||
name: mockserver | ||
spec: | ||
containers: | ||
- env: | ||
- name: MOCKSERVER_LOG_LEVEL | ||
value: INFO | ||
- name: SERVER_PORT | ||
value: "1080" | ||
image: mockserver/mockserver:mockserver-5.13.0 | ||
imagePullPolicy: IfNotPresent | ||
livenessProbe: | ||
failureThreshold: 10 | ||
initialDelaySeconds: 10 | ||
periodSeconds: 5 | ||
successThreshold: 1 | ||
tcpSocket: | ||
port: serviceport | ||
timeoutSeconds: 1 | ||
name: mockserver | ||
ports: | ||
- containerPort: 1080 | ||
name: serviceport | ||
protocol: TCP | ||
readinessProbe: | ||
failureThreshold: 10 | ||
initialDelaySeconds: 2 | ||
periodSeconds: 2 | ||
successThreshold: 1 | ||
tcpSocket: | ||
port: serviceport | ||
timeoutSeconds: 1 | ||
volumeMounts: | ||
- mountPath: /config | ||
name: config-volume | ||
- mountPath: /libs | ||
name: libs-volume | ||
terminationGracePeriodSeconds: 30 | ||
volumes: | ||
- configMap: | ||
defaultMode: 420 | ||
name: mockserver-config | ||
optional: true | ||
name: config-volume | ||
- configMap: | ||
defaultMode: 420 | ||
name: mockserver-config | ||
optional: true | ||
name: libs-volume | ||
--- | ||
kind: ConfigMap | ||
apiVersion: v1 | ||
metadata: | ||
name: mockserver-config | ||
data: | ||
initializerJson.json: |- | ||
[ | ||
{ | ||
"httpRequest": { | ||
"path": "/api/v1/query_range", | ||
"method": "POST" | ||
}, | ||
"httpResponse": { | ||
"body": { | ||
"status": "success", | ||
"data": { | ||
"resultType": "matrix", | ||
"result": [ | ||
{ | ||
"metric": { | ||
"__name__": "cpu-throttling", | ||
"job": "", | ||
"instance": "" | ||
}, | ||
"values": [[1669714193.275, "4.0"]] | ||
} | ||
] | ||
} | ||
}, | ||
"statusCode": 200 | ||
} | ||
} | ||
] | ||
mockserver.properties: |- | ||
############################### | ||
# MockServer & Proxy Settings # | ||
############################### | ||
# Socket & Port Settings | ||
# socket timeout in milliseconds (default 120000) | ||
mockserver.maxSocketTimeout=120000 | ||
# Certificate Generation | ||
# dynamically generated CA key pair (if they don't already exist in | ||
specified directory) | ||
mockserver.dynamicallyCreateCertificateAuthorityCertificate=true | ||
# save dynamically generated CA key pair in working directory | ||
mockserver.directoryToSaveDynamicSSLCertificate=. | ||
# certificate domain name (default "localhost") | ||
mockserver.sslCertificateDomainName=localhost | ||
# comma separated list of ip addresses for Subject Alternative Name domain | ||
names (default empty list) | ||
mockserver.sslSubjectAlternativeNameDomains=www.example.com,www.another.com | ||
# comma separated list of ip addresses for Subject Alternative Name ips | ||
(default empty list) | ||
mockserver.sslSubjectAlternativeNameIps=127.0.0.1 | ||
# CORS | ||
# enable CORS for MockServer REST API | ||
mockserver.enableCORSForAPI=true | ||
# enable CORS for all responses | ||
mockserver.enableCORSForAllResponses=true | ||
# Json Initialization | ||
mockserver.initializationJsonPath=/config/initializerJson.json |