Skip to content

Commit b1ef09d

Browse files
author
Amit Kumar Das
authored
chore(ci): re-arrange ci artifacts (#103)
This commit re-arranges the ci artifacts that build the ci framework required to run end to end tests for d-operators. README about E to E has been updated to make it simpler to understand the motive behind this custom ci framework. Signed-off-by: AmitKumarDas <[email protected]>
1 parent 7e3d9b5 commit b1ef09d

File tree

5 files changed

+124
-47
lines changed

5 files changed

+124
-47
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ It is important to understand that these declarative patterns are built upon pro
1010
D-operators is not meant to build complex controller logic like Deployment, StatefulSet or Pod in a declarative yaml. However, if one needs to use available Kubernetes resources to build new k8s controller(s) then d-operators should be considered to build one. D-operators helps implement the last mile automation needed to manage applications & infrastructure in Kubernetes clusters.
1111

1212
### E to E testing
13-
D-operators make use of d-operators _(i.e. its own self)_ to test its controllers. It does not need kubectl, bash, sed, awk etc to test its controllers. In addition, it does not depend on writing go code to write tests. It makes use of declarative YAMLs to test its controllers.
13+
D-operators make use of its custom resource(s) to test its controllers. One can imagine these custom resources acting as the building blocks to implement a custom CI framework. One of the primary advantages with this approach, is to let custom resources remove the need to write code to implement test cases.
1414

15-
_NOTE: One can make use of these YAMLs (kind: Recipe) to test any Kubernetes controllers declaratively_
15+
_NOTE: One can make use of these YAMLs (kind: Recipe) to test their own Kubernetes controllers declaratively_
1616

1717
Navigate to test/experiments to learn more on these YAMLs.
1818

test/e2e/ci.yaml

+114
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
# This yaml file demonstrates the use of Kubernetes
2+
# and few custom resources to build a custom CI
3+
# infrastructure. In this infrastructure, Kubernetes
4+
# is the CI runner and custom resources are the test
5+
# cases.
6+
---
7+
# d-testing is the Kubernetes namespace that can
8+
# be used to deploy any test artifacts
9+
apiVersion: v1
10+
kind: Namespace
11+
metadata:
12+
name: d-testing
13+
---
14+
# dope is the Kubernetes namespace used to deploy
15+
# dope statefulset
16+
apiVersion: v1
17+
kind: Namespace
18+
metadata:
19+
name: dope
20+
---
21+
# Recipe custom resource is used to write test cases
22+
# in a declarative approach
23+
apiVersion: apiextensions.k8s.io/v1beta1
24+
kind: CustomResourceDefinition
25+
metadata:
26+
annotations:
27+
name: recipes.dope.metacontroller.io
28+
spec:
29+
group: dope.metacontroller.io
30+
names:
31+
kind: Recipe
32+
listKind: RecipeList
33+
plural: recipes
34+
shortNames:
35+
- rcp
36+
singular: recipe
37+
scope: Namespaced
38+
subresources:
39+
status: {}
40+
version: v1
41+
versions:
42+
- name: v1
43+
served: true
44+
storage: true
45+
---
46+
# dope is the Kubernetes service account that has
47+
# all priviledges to manage any Kubernetes resources
48+
apiVersion: v1
49+
kind: ServiceAccount
50+
metadata:
51+
name: dope
52+
namespace: dope
53+
---
54+
apiVersion: rbac.authorization.k8s.io/v1
55+
kind: ClusterRole
56+
metadata:
57+
name: dope
58+
rules:
59+
- apiGroups:
60+
- "*"
61+
resources:
62+
- "*"
63+
verbs:
64+
- "*"
65+
---
66+
apiVersion: rbac.authorization.k8s.io/v1
67+
kind: ClusterRoleBinding
68+
metadata:
69+
name: dope
70+
subjects:
71+
- kind: ServiceAccount
72+
name: dope
73+
namespace: dope
74+
roleRef:
75+
kind: ClusterRole
76+
name: dope
77+
apiGroup: rbac.authorization.k8s.io
78+
---
79+
# dope statefulset holds the dope binary which is responsible
80+
# to reconcile all Recipe custom resources
81+
apiVersion: apps/v1
82+
kind: StatefulSet
83+
metadata:
84+
labels:
85+
app.mayadata.io/name: dope
86+
name: dope
87+
namespace: dope
88+
spec:
89+
replicas: 1
90+
selector:
91+
matchLabels:
92+
app.mayadata.io/name: dope
93+
serviceName: ""
94+
template:
95+
metadata:
96+
labels:
97+
app.mayadata.io/name: dope
98+
spec:
99+
serviceAccountName: dope
100+
containers:
101+
- name: dope
102+
# this may be replaced by a stable release tag
103+
#
104+
# Since dope itself is the target under test, this
105+
# ci.yaml uses the master build available in the local
106+
# container registry
107+
image: localhost:5000/dope
108+
command: ["/usr/bin/dope"]
109+
args:
110+
- --logtostderr
111+
- --run-as-local
112+
- -v=1
113+
- --discovery-interval=30s
114+
- --cache-flush-interval=240s
File renamed without changes.

test/e2e/namespace.yaml

-4
This file was deleted.

test/e2e/suite.sh

+8-41
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ echo "--------------------------"
4444
echo "++ E to E suite started"
4545
echo "--------------------------"
4646

47-
# Name of the Kubernetes controller binary under test
47+
# Name of the targeted controller binary under test
4848
ctrlbin="dope"
4949

50-
# kind: Recipe custom resource is used to build the test cases
50+
# group that defines the Recipe custom resource
5151
group="recipes.dope.metacontroller.io"
5252

53-
# Namespace used by all Recipe custom resources
53+
# Namespace used by inference Recipe custom resource
5454
ns="d-testing"
5555

5656
echo -e "\n Remove locally cached image $ctrlbin:e2e"
@@ -87,44 +87,11 @@ fi
8787
echo -e "\n Verify if K3s is up and running"
8888
k3s kubectl get node
8989

90-
echo -e "\n Apply $ctrlbin manifests to K3s cluster..."
91-
k3s kubectl apply -f ./../../manifests/
92-
93-
echo -e "\n Apply $ctrlbin as a statefulset to K3s cluster..."
94-
cat <<EOF | k3s kubectl apply -f -
95-
apiVersion: apps/v1
96-
kind: StatefulSet
97-
metadata:
98-
labels:
99-
app.mayadata.io/name: dope
100-
name: dope
101-
namespace: dope
102-
spec:
103-
replicas: 1
104-
selector:
105-
matchLabels:
106-
app.mayadata.io/name: dope
107-
serviceName: ""
108-
template:
109-
metadata:
110-
labels:
111-
app.mayadata.io/name: dope
112-
spec:
113-
serviceAccountName: dope
114-
containers:
115-
- name: dope
116-
image: localhost:5000/dope
117-
command: ["/usr/bin/dope"]
118-
args:
119-
- --logtostderr
120-
- --run-as-local
121-
- -v=1
122-
- --discovery-interval=30s
123-
- --cache-flush-interval=240s
124-
EOF
125-
126-
echo -e "\n Apply test namespace to K3s cluster"
127-
k3s kubectl apply -f namespace.yaml
90+
echo -e "\n Apply d-operators based ci to K3s cluster"
91+
k3s kubectl apply -f ci.yaml
92+
93+
echo -e "\n Apply ci inference to K3s cluster"
94+
k3s kubectl apply -f inference.yaml
12895

12996
echo -e "\n Apply test experiments to K3s cluster"
13097
k3s kubectl apply -f ./../experiments/

0 commit comments

Comments
 (0)