-
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.
chore: migrate testcertificate to chainsaw
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
- Loading branch information
1 parent
ff45589
commit 02a5965
Showing
18 changed files
with
499 additions
and
5 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
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
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
24 changes: 24 additions & 0 deletions
24
test/chainsaw/testcertificate/cert-recreates/00-assert.yaml
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,24 @@ | ||
# certificate is recreated and there are operators instances available | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: keptn-certs | ||
namespace: keptn-system | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
namespace: keptn-system | ||
labels: | ||
control-plane: metrics-operator | ||
status: | ||
readyReplicas: 1 | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
namespace: keptn-system | ||
labels: | ||
control-plane: lifecycle-operator | ||
status: | ||
readyReplicas: 1 |
24 changes: 24 additions & 0 deletions
24
test/chainsaw/testcertificate/cert-recreates/01-assert.yaml
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,24 @@ | ||
# certificate is recreated and there are operators instances available | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: keptn-certs | ||
namespace: keptn-system | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
namespace: keptn-system | ||
labels: | ||
control-plane: metrics-operator | ||
status: | ||
readyReplicas: 1 | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
namespace: keptn-system | ||
labels: | ||
control-plane: lifecycle-operator | ||
status: | ||
readyReplicas: 1 |
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,6 @@ | ||
# second scenario: certificate is removed with no restart | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: keptn-certs | ||
namespace: keptn-system |
26 changes: 26 additions & 0 deletions
26
test/chainsaw/testcertificate/cert-recreates/02-assert.yaml
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,26 @@ | ||
# certificate is recreated and there are operators instances available | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: keptn-certs | ||
namespace: keptn-system | ||
annotations: | ||
mycert: "true" # make sure this is the latest secret | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
labels: | ||
control-plane: metrics-operator | ||
namespace: keptn-system | ||
status: | ||
readyReplicas: 1 | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
labels: | ||
control-plane: lifecycle-operator | ||
namespace: keptn-system | ||
status: | ||
readyReplicas: 1 |
13 changes: 13 additions & 0 deletions
13
test/chainsaw/testcertificate/cert-recreates/02-install.yaml
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,13 @@ | ||
# third scenario: certificate is invalid/expired | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: keptn-certs | ||
namespace: keptn-system | ||
annotations: | ||
mycert: "true" | ||
data: | ||
# yamllint disable rule:line-length | ||
tls.crt: "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUNkekNDQWg2Z0F3SUJBZ0lRZUpBWkJMcmxCY2VqNzh3cm4wV1ZIekFLQmdncWhrak9QUVFEQWpDQmlURUwKa0ZGY1FpY29hdE8yRFJnPQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0t" | ||
# yamllint disable rule:line-length | ||
tls.key: "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUNkekNDQWg2Z0F3SUJBZ0lRZUpBWkJMcmxCY2VqNzh3cm4wV1ZIekFLQmdncWhrak9QUVFEQWpDQmlURUwKa0ZGY1FpY29hdE8yRFJnPQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0t" |
44 changes: 44 additions & 0 deletions
44
test/chainsaw/testcertificate/cert-recreates/chainsaw-test.yaml
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,44 @@ | ||
# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json | ||
apiVersion: chainsaw.kyverno.io/v1alpha1 | ||
kind: Test | ||
metadata: | ||
name: cert-recreates | ||
spec: | ||
steps: | ||
- name: step-00 | ||
try: | ||
- delete: | ||
ref: | ||
apiVersion: v1 | ||
kind: Secret | ||
namespace: keptn-system | ||
name: keptn-certs | ||
- script: | ||
content: | | ||
set -euo pipefail | ||
kubectl rollout restart deployment -n keptn-system -l control-plane=lifecycle-operator | ||
kubectl rollout restart deployment -n keptn-system -l control-plane=metrics-operator | ||
- assert: | ||
file: 00-assert.yaml | ||
- name: step-01 | ||
try: | ||
- apply: | ||
file: 01-delete.yaml | ||
- assert: | ||
file: 01-assert.yaml | ||
- name: step-02 | ||
try: | ||
- apply: | ||
file: 02-install.yaml | ||
- script: | ||
content: | | ||
str1=$(kubectl get secret keptn-certs -n keptn-system -o=go-template='{{index .data "tls.crt"}}') | ||
str2="LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUNkekNDQWg2Z0F3SUJBZ0lRZUpBWkJMcmxCY2VqNzh3cm4wV1ZIekFLQmdncWhrak9QUVFEQWpDQmlURUwKa0ZGY1FpY29hdE8yRFJnPQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0t" | ||
if [ "$str1" == "$str2" ]; then | ||
echo "Strings are equal" $str1 | ||
exit 1 | ||
else | ||
echo "Strings are not equal" $str1 "!=" $str2 | ||
fi | ||
- assert: | ||
file: 02-assert.yaml |
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,30 @@ | ||
# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json | ||
apiVersion: chainsaw.kyverno.io/v1alpha1 | ||
kind: Test | ||
metadata: | ||
creationTimestamp: null | ||
name: metrics-hpa | ||
spec: | ||
steps: | ||
- name: step-00 | ||
try: | ||
- apply: | ||
file: 00-install.yaml | ||
- script: | ||
content: | | ||
kubectl apply -f mock-server.yaml -n $NAMESPACE | ||
- script: | ||
content: | | ||
echo "registering the metric" | ||
envsubst < metric.yaml | kubectl apply -f - -n $NAMESPACE | ||
echo "configuring HPA" | ||
kubectl apply -f hpa.yaml -n $NAMESPACE | ||
catch: | ||
- podLogs: | ||
selector: app=podtato-head | ||
- script: | ||
content: | | ||
kubectl logs -l app=metrics-operator -n keptn-system | ||
kubectl describe keptnmetric podtatometric -n $NAMESPACE | ||
kubectl describe keptnmetricsprovider dynatrace -n $NAMESPACE | ||
kubectl describe pods -l app=podtato-head -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/v1beta1 | ||
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/v1beta1 | ||
kind: KeptnMetricsProvider | ||
metadata: | ||
name: my-provider | ||
spec: | ||
type: prometheus | ||
targetServer: "http://mockserver.$NAMESPACE.svc.cluster.local:1080" | ||
--- | ||
apiVersion: metrics.keptn.sh/v1beta1 | ||
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" |
Oops, something went wrong.