Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Helm tests #11

Merged
merged 4 commits into from
Dec 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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