Skip to content

Commit

Permalink
fix: kubernetes resource fixture to test ingress
Browse files Browse the repository at this point in the history
  • Loading branch information
adityathebe committed Apr 3, 2024
1 parent 9bb6b4a commit 9d6144d
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 6 deletions.
4 changes: 2 additions & 2 deletions checks/kubernetes_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ func (c *KubernetesResourceChecker) Check(ctx *context.Context, check v1.Kuberne

templater := gomplate.StructTemplater{
Values: map[string]any{
"staticResource": check.StaticResources,
"resources": check.Resources,
"staticResources": check.StaticResources,
"resources": check.Resources,
},
ValueFunctions: true,
DelimSets: []gomplate.Delims{
Expand Down
48 changes: 44 additions & 4 deletions fixtures/k8s/kubernetes_resource.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,31 @@ metadata:
labels:
"Expected-Fail": "false"
spec:
schedule: '@every 5m'
schedule: "@every 5m"
kubernetesResource:
- name: ingress-accessibility-check
- name: ingress-accessibility-check
namespace: default
description: "deploy an nginx pod"
waitForReady: true
description: "deploy an nginx pod & check that it's accessible via ingress"
waitForReady: true
timeout: 10m
staticResources:
- apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: nginx-pod-ingress
namespace: default
spec:
rules:
- host: nginx.test.flanksource.com
http:
paths:
- pathType: Prefix
path: /
backend:
service:
name: nginx
port:
number: 80
resources:
- apiVersion: v1
kind: Pod
Expand All @@ -26,3 +44,25 @@ spec:
image: nginx:1.24.0-alpine-slim
ports:
- containerPort: 80
- apiVersion: v1
kind: Service
metadata:
name: nginx
namespace: default
spec:
selector:
name: nginx-pod
ports:
- port: 80
targetPort: 80
checks:
- http:
- url: "http://ingress-nginx.ingress-nginx.svc"
headers:
- name: Host
value: "nginx.test.flanksource.com"
# - url: "http://localhost:1337"
# headers:
# - name: host
# value: "nginx.test.flanksource.com"
# value: "{{(index (index .staticResources 0).spec.rules 0).host}}"
1 change: 1 addition & 0 deletions fixtures/k8s/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ resources:
- pod_fail.yaml
- pod_pass.yaml
- kubernetes_bundle.yaml
- kuberenetes_resource.yaml
2 changes: 2 additions & 0 deletions pkg/db/canary.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ func DeleteCanary(ctx context.Context, id string) error {
}
metrics.UnregisterGauge(ctx, checkIDs)

// TODO: delete all the static resources

if err := DeleteCheckComponentRelationshipsForCanary(ctx.DB(), id); err != nil {
return err
}
Expand Down

0 comments on commit 9d6144d

Please sign in to comment.