Skip to content

Commit cfe7481

Browse files
Raffomloiseleur
andauthored
feat: end to end testing with coredns provider (#5933)
* end to end testing with local provider implementation Signed-off-by: Raffaele Di Fazio <difazio.raffaele@gmail.com> * Update .github/workflows/end-to-end-tests.yml Co-authored-by: Michel Loiseleur <97035654+mloiseleur@users.noreply.github.com> * Update e2e/deployment.yaml Co-authored-by: Michel Loiseleur <97035654+mloiseleur@users.noreply.github.com> * move e2e to coredns Signed-off-by: Raffaele Di Fazio <difazio.raffaele@gmail.com> * newlines Signed-off-by: Raffaele Di Fazio <difazio.raffaele@gmail.com> * Update scripts/e2e-test.sh Co-authored-by: Michel Loiseleur <97035654+mloiseleur@users.noreply.github.com> * drop all comments Signed-off-by: Raffaele Di Fazio <difazio.raffaele@gmail.com> * Update .github/workflows/end-to-end-tests.yml Co-authored-by: Michel Loiseleur <97035654+mloiseleur@users.noreply.github.com> --------- Signed-off-by: Raffaele Di Fazio <difazio.raffaele@gmail.com> Co-authored-by: Michel Loiseleur <97035654+mloiseleur@users.noreply.github.com>
1 parent 62f4d7d commit cfe7481

File tree

6 files changed

+499
-0
lines changed

6 files changed

+499
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: end to end test
2+
3+
on:
4+
push:
5+
branches:
6+
pull_request:
7+
branches: [ master ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
e2e-tests:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
- name: e2e
18+
run: |
19+
./scripts/e2e-test.sh

e2e/deployment.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
labels:
5+
app: demo-app
6+
name: demo-app
7+
spec:
8+
replicas: 1
9+
selector:
10+
matchLabels:
11+
app: demo-app
12+
template:
13+
metadata:
14+
labels:
15+
app: demo-app
16+
spec:
17+
containers:
18+
- image: traefik/whoami:latest # minimal demo app
19+
name: demo-app

e2e/provider/coredns.yaml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
---
2+
apiVersion: v1
3+
kind: ConfigMap
4+
metadata:
5+
name: coredns
6+
namespace: default
7+
data:
8+
Corefile: |
9+
external.dns:5353 {
10+
errors
11+
log
12+
etcd {
13+
stubzones
14+
path /skydns
15+
endpoint http://etcd-0.etcd:2379
16+
}
17+
cache 30
18+
forward . /etc/resolv.conf
19+
}
20+
---
21+
apiVersion: apps/v1
22+
kind: Deployment
23+
metadata:
24+
name: coredns
25+
namespace: default
26+
labels:
27+
app: coredns
28+
spec:
29+
replicas: 1
30+
selector:
31+
matchLabels:
32+
app: coredns
33+
template:
34+
metadata:
35+
labels:
36+
app: coredns
37+
spec:
38+
hostNetwork: true
39+
dnsPolicy: Default
40+
containers:
41+
- name: coredns
42+
image: coredns/coredns:1.13.1
43+
args: [ "-conf", "/etc/coredns/Corefile" ]
44+
volumeMounts:
45+
- name: config-volume
46+
mountPath: /etc/coredns
47+
ports:
48+
- containerPort: 5353
49+
name: dns
50+
protocol: UDP
51+
- containerPort: 5353
52+
name: dns-tcp
53+
protocol: TCP
54+
livenessProbe:
55+
httpGet:
56+
path: /health
57+
port: 8080
58+
scheme: HTTP
59+
initialDelaySeconds: 60
60+
timeoutSeconds: 5
61+
successThreshold: 1
62+
failureThreshold: 5
63+
readinessProbe:
64+
httpGet:
65+
path: /ready
66+
port: 8181
67+
scheme: HTTP
68+
initialDelaySeconds: 10
69+
timeoutSeconds: 5
70+
successThreshold: 1
71+
failureThreshold: 5
72+
volumes:
73+
- name: config-volume
74+
configMap:
75+
name: coredns
76+
items:
77+
- key: Corefile
78+
path: Corefile
79+
---
80+
apiVersion: v1
81+
kind: Service
82+
metadata:
83+
name: coredns
84+
namespace: default
85+
labels:
86+
app: coredns
87+
spec:
88+
selector:
89+
app: coredns
90+
ports:
91+
- name: dns
92+
port: 5353
93+
targetPort: 5353
94+
protocol: UDP
95+
- name: dns-tcp
96+
port: 5353
97+
targetPort: 5353
98+
protocol: TCP

e2e/provider/etcd.yaml

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
---
2+
apiVersion: v1
3+
kind: Service
4+
metadata:
5+
name: etcd
6+
namespace: default
7+
spec:
8+
type: ClusterIP
9+
clusterIP: None
10+
selector:
11+
app: etcd
12+
publishNotReadyAddresses: true
13+
ports:
14+
- name: etcd-client
15+
port: 2379
16+
- name: etcd-server
17+
port: 2380
18+
- name: etcd-metrics
19+
port: 8080
20+
---
21+
apiVersion: apps/v1
22+
kind: StatefulSet
23+
metadata:
24+
namespace: default
25+
name: etcd
26+
spec:
27+
serviceName: etcd
28+
replicas: 1
29+
podManagementPolicy: Parallel
30+
updateStrategy:
31+
type: RollingUpdate
32+
selector:
33+
matchLabels:
34+
app: etcd
35+
template:
36+
metadata:
37+
labels:
38+
app: etcd
39+
annotations:
40+
serviceName: etcd
41+
spec:
42+
affinity:
43+
podAntiAffinity:
44+
requiredDuringSchedulingIgnoredDuringExecution:
45+
- labelSelector:
46+
matchExpressions:
47+
- key: app
48+
operator: In
49+
values:
50+
- etcd
51+
topologyKey: "kubernetes.io/hostname"
52+
containers:
53+
- name: etcd
54+
image: quay.io/coreos/etcd:v3.6.0
55+
imagePullPolicy: IfNotPresent
56+
ports:
57+
- name: etcd-client
58+
containerPort: 2379
59+
- name: etcd-server
60+
containerPort: 2380
61+
- name: etcd-metrics
62+
containerPort: 8080
63+
readinessProbe:
64+
httpGet:
65+
path: /readyz
66+
port: 8080
67+
initialDelaySeconds: 10
68+
periodSeconds: 5
69+
timeoutSeconds: 5
70+
successThreshold: 1
71+
failureThreshold: 30
72+
livenessProbe:
73+
httpGet:
74+
path: /livez
75+
port: 8080
76+
initialDelaySeconds: 15
77+
periodSeconds: 10
78+
timeoutSeconds: 5
79+
failureThreshold: 3
80+
env:
81+
- name: K8S_NAMESPACE
82+
valueFrom:
83+
fieldRef:
84+
fieldPath: metadata.namespace
85+
- name: HOSTNAME
86+
valueFrom:
87+
fieldRef:
88+
fieldPath: metadata.name
89+
- name: SERVICE_NAME
90+
valueFrom:
91+
fieldRef:
92+
fieldPath: metadata.annotations['serviceName']
93+
- name: ETCDCTL_ENDPOINTS
94+
value: $(HOSTNAME).$(SERVICE_NAME):2379
95+
- name: URI_SCHEME
96+
value: "http"
97+
command:
98+
- /usr/local/bin/etcd
99+
args:
100+
- --name=$(HOSTNAME)
101+
- --data-dir=/data
102+
- --wal-dir=/data/wal
103+
- --listen-peer-urls=$(URI_SCHEME)://0.0.0.0:2380
104+
- --listen-client-urls=$(URI_SCHEME)://0.0.0.0:2379
105+
- --advertise-client-urls=$(URI_SCHEME)://$(HOSTNAME).$(SERVICE_NAME):2379
106+
- --initial-cluster-state=new
107+
- --initial-cluster-token=etcd-$(K8S_NAMESPACE)
108+
- --initial-cluster=etcd-0=$(URI_SCHEME)://etcd-0.$(SERVICE_NAME):2380
109+
- --initial-advertise-peer-urls=$(URI_SCHEME)://$(HOSTNAME).$(SERVICE_NAME):2380
110+
- --listen-metrics-urls=http://0.0.0.0:8080
111+
volumeMounts:
112+
- name: etcd-data
113+
mountPath: /data
114+
volumeClaimTemplates:
115+
- metadata:
116+
name: etcd-data
117+
spec:
118+
accessModes: ["ReadWriteOnce"]
119+
resources:
120+
requests:
121+
storage: 1Gi

e2e/service.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
labels:
5+
app: demo-app
6+
name: demo-app
7+
annotations:
8+
external-dns.alpha.kubernetes.io/hostname: externaldns-e2e.external.dns
9+
spec:
10+
ports:
11+
- port: 80
12+
protocol: TCP
13+
targetPort: 8080
14+
selector:
15+
app: demo-app
16+
clusterIP: None

0 commit comments

Comments
 (0)