Skip to content

Commit

Permalink
Merge pull request #11 from SAP/helm-tests
Browse files Browse the repository at this point in the history
Helm tests
  • Loading branch information
cbarbian-sap authored Dec 28, 2024
2 parents 09e4ddf + 41c27ac commit ea24e6a
Show file tree
Hide file tree
Showing 3 changed files with 141 additions and 0 deletions.
53 changes: 53 additions & 0 deletions chart/.setup.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
apiVersion: v1
kind: ConfigMap
metadata:
namespace: kube-system
name: coredns
data:
Corefile: |
.:53 {
errors
health {
lameduck 5s
}
ready
kubernetes cluster.local in-addr.arpa ip6.arpa {
pods insecure
fallthrough in-addr.arpa ip6.arpa
ttl 30
}
prometheus :9153
forward . /etc/resolv.conf {
max_concurrent 1000
}
cache 30
loop
reload
loadbalance
import custom/*.override
}
---
apiVersion: apps/v1
kind: Deployment
metadata:
namespace: kube-system
name: coredns
spec:
selector:
matchLabels:
k8s-app: kube-dns
template:
spec:
containers:
- name: coredns
volumeMounts:
- mountPath: /etc/coredns/custom
name: custom-config-volume
readOnly: true
volumes:
- name: custom-config-volume
configMap:
defaultMode: 420
name: coredns-custom
optional: true
50 changes: 50 additions & 0 deletions chart/templates/tests/rbac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "dns-masquerading-operator.fullname" . }}-test
labels:
{{- include "dns-masquerading-operator.labels" . | nindent 4 }}
annotations:
helm.sh/hook: test
helm.sh/hook-weight: "-1"
helm.sh/hook-delete-policy: before-hook-creation,hook-succeeded
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ include "dns-masquerading-operator.fullname" . }}-test
labels:
{{- include "dns-masquerading-operator.labels" . | nindent 4 }}
annotations:
helm.sh/hook: test
helm.sh/hook-weight: "-1"
helm.sh/hook-delete-policy: before-hook-creation,hook-succeeded
rules:
- apiGroups:
- dns.cs.sap.com
resources:
- masqueradingrules
verbs:
- get
- list
- watch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ include "dns-masquerading-operator.fullname" . }}-test
labels:
{{- include "dns-masquerading-operator.labels" . | nindent 4 }}
annotations:
helm.sh/hook: test
helm.sh/hook-weight: "-1"
helm.sh/hook-delete-policy: before-hook-creation,hook-succeeded
subjects:
- kind: ServiceAccount
namespace: {{ .Release.Namespace }}
name: {{ include "dns-masquerading-operator.fullname" . }}-test
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{ include "dns-masquerading-operator.fullname" . }}-test
38 changes: 38 additions & 0 deletions chart/templates/tests/test-1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{{- $ruleName := printf "%s-test-1-%s" (include "dns-masquerading-operator.fullname" .) (randAlphaNum 10 | lower) }}
---
apiVersion: dns.cs.sap.com/v1alpha1
kind: MasqueradingRule
metadata:
name: {{ $ruleName }}
labels:
{{- include "dns-masquerading-operator.labels" . | nindent 4 }}
annotations:
helm.sh/hook: test
helm.sh/hook-weight: "0"
helm.sh/hook-delete-policy: before-hook-creation,hook-succeeded
spec:
from: test1.example.io
to: 8.8.8.8
---
apiVersion: v1
kind: Pod
metadata:
name: {{ include "dns-masquerading-operator.fullname" . }}-test-1
labels:
{{- include "dns-masquerading-operator.labels" . | nindent 4 }}
annotations:
helm.sh/hook: test
helm.sh/hook-weight: "1"
helm.sh/hook-delete-policy: before-hook-creation,hook-succeeded
spec:
containers:
- name: kubectl
image: bitnami/kubectl:{{ .Capabilities.KubeVersion.Version | trimPrefix "v" }}
command:
- bash
- -ec
- |
kubectl wait masqueradingrules.dns.cs.sap.com/{{ $ruleName }} --for condition=Ready --timeout 120s
serviceAccountName: {{ include "dns-masquerading-operator.fullname" . }}-test
terminationGracePeriodSeconds: 3
restartPolicy: Never

0 comments on commit ea24e6a

Please sign in to comment.