Skip to content

Commit

Permalink
add kustomize configs for all intg test cases
Browse files Browse the repository at this point in the history
Signed-off-by: Mohamed Mahmoud <[email protected]>
  • Loading branch information
msherif1234 committed May 30, 2024
1 parent 1b38498 commit da52dac
Show file tree
Hide file tree
Showing 35 changed files with 619 additions and 15 deletions.
18 changes: 18 additions & 0 deletions test/integration/kprobe/base/bytecode.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
apiVersion: bpfman.io/v1alpha1
kind: KprobeProgram
metadata:
labels:
app.kubernetes.io/name: kprobeprogram
name: go-kprobe-counter-example
spec:
bpffunctionname: kprobe_counter
# Select all nodes
nodeselector: {}
func_name: try_to_wake_up
offset: 0
retprobe: false
bytecode:
image:
url: quay.io/bpfman-bytecode/go-kprobe-counter:latest
imagepullpolicy: IfNotPresent
69 changes: 69 additions & 0 deletions test/integration/kprobe/base/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---
apiVersion: v1
kind: Namespace
metadata:
name: go-kprobe-counter
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: bpfman-app-go-kprobe-counter
namespace: go-kprobe-counter
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: go-kprobe-counter-ds
namespace: go-kprobe-counter
labels:
k8s-app: go-kprobe-counter
spec:
selector:
matchLabels:
name: go-kprobe-counter
template:
metadata:
labels:
name: go-kprobe-counter
spec:
nodeSelector: {}
dnsPolicy: ClusterFirstWithHostNet
serviceAccountName: bpfman-app-go-kprobe-counter
securityContext:
runAsNonRoot: true
fsGroup: 65534
tolerations:
# these tolerations are to have the daemonset runnable on control plane nodes
# remove them if your control plane nodes should not run pods
- key: node-role.kubernetes.io/control-plane
operator: Exists
effect: NoSchedule
- key: node-role.kubernetes.io/master
operator: Exists
effect: NoSchedule
containers:
- name: go-kprobe-counter
image: quay.io/bpfman-userspace/go-kprobe-counter:latest
imagePullPolicy: IfNotPresent
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop: [ALL]
runAsUser: 65534
runAsGroup: 65534
env:
- name: NODENAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
volumeMounts:
- name: go-kprobe-counter-maps
mountPath: /run/kprobe/maps
readOnly: true
volumes:
- name: go-kprobe-counter-maps
csi:
driver: csi.bpfman.io
volumeAttributes:
csi.bpfman.io/program: go-kprobe-counter-example
csi.bpfman.io/maps: kprobe_stats_map
4 changes: 4 additions & 0 deletions test/integration/kprobe/base/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources: [bytecode.yaml, deployment.yaml]
18 changes: 18 additions & 0 deletions test/integration/kprobe/default/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
# Patch the deployment.yaml to change container image in Daemonset
# to new tag on the image.
images:
- name: quay.io/bpfman-userspace/go-kprobe-counter
newName: quay.io/bpfman-userspace/go-kprobe-counter
newTag: latest
# Patch the bytecode.yaml to change tag on the "url" field (which is an
# image) to new value. Since this is being done with an environment
# variable and using sed to replace, moved to patch.yaml.env which is
# converted to patch.yaml using the sed command in Makefile.
patches:
- path: patch.yaml
target:
kind: kprobeProgram
name: go-kprobe-counter-example
resources: [../../../test/integration/kprobe/base ]
5 changes: 5 additions & 0 deletions test/integration/kprobe/default/patch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Patch the bytecode.yaml to change image and tag on the "url" field
# (which is an image) to new value.
- op: replace
path: /spec/bytecode/image/url
value: quay.io/bpfman-bytecode/go-kprobe-counter:latest
5 changes: 5 additions & 0 deletions test/integration/kprobe/default/patch.yaml.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Patch the bytecode.yaml to change image and tag on the "url" field
# (which is an image) to new value.
- op: replace
path: "/spec/bytecode/image/url"
value: URL_BC
6 changes: 3 additions & 3 deletions test/integration/kprobe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
)

const (
kprobeGoCounterKustomize = "../../../examples/config/default/go-kprobe-counter"
kprobeGoCounterKustomize = "../../test/integration/kprobe/default"
kprobeGoCounterUserspaceNs = "go-kprobe-counter"
kprobeGoCounterUserspaceDsName = "go-kprobe-counter-ds"
)
Expand All @@ -38,8 +38,8 @@ func TestKprobeGoCounter(t *testing.T) {
require.NoError(t, err)
return daemon.Status.DesiredNumberScheduled == daemon.Status.NumberAvailable
},
// Wait 5 minutes since cosign is slow, https://github.com/bpfman/bpfman/issues/1043
5*time.Minute, 10*time.Second)
// Wait 5 minutes since cosign is slow, https://github.com/bpfman/bpfman/issues/1043
5*time.Minute, 10*time.Second)

pods, err := env.Cluster().Client().CoreV1().Pods(kprobeGoCounterUserspaceNs).List(ctx, metav1.ListOptions{LabelSelector: "name=go-kprobe-counter"})
require.NoError(t, err)
Expand Down
18 changes: 18 additions & 0 deletions test/integration/tc/base/bytecode.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
apiVersion: bpfman.io/v1alpha1
kind: TcProgram
metadata:
labels:
app.kubernetes.io/name: tcprogram
name: go-tc-counter-example
spec:
bpffunctionname: stats
# Select all nodes
nodeselector: {}
interfaceselector:
primarynodeinterface: true
priority: 55
direction: ingress
bytecode:
image:
url: quay.io/bpfman-bytecode/go-tc-counter:latest
69 changes: 69 additions & 0 deletions test/integration/tc/base/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---
apiVersion: v1
kind: Namespace
metadata:
name: go-tc-counter
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: bpfman-app-go-tc-counter
namespace: go-tc-counter
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: go-tc-counter-ds
namespace: go-tc-counter
labels:
k8s-app: go-tc-counter
spec:
selector:
matchLabels:
name: go-tc-counter
template:
metadata:
labels:
name: go-tc-counter
spec:
nodeSelector: {}
dnsPolicy: ClusterFirstWithHostNet
serviceAccountName: bpfman-app-go-tc-counter
securityContext:
runAsNonRoot: true
fsGroup: 65534
tolerations:
# these tolerations are to have the daemonset runnable on control plane nodes
# remove them if your control plane nodes should not run pods
- key: node-role.kubernetes.io/control-plane
operator: Exists
effect: NoSchedule
- key: node-role.kubernetes.io/master
operator: Exists
effect: NoSchedule
containers:
- name: go-tc-counter
image: quay.io/bpfman-userspace/go-tc-counter:latest
imagePullPolicy: IfNotPresent
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop: [ALL]
runAsUser: 65534
runAsGroup: 65534
env:
- name: NODENAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
volumeMounts:
- name: go-tc-counter-maps
mountPath: /run/tc/maps
readOnly: true
volumes:
- name: go-tc-counter-maps
csi:
driver: csi.bpfman.io
volumeAttributes:
csi.bpfman.io/program: go-tc-counter-example
csi.bpfman.io/maps: tc_stats_map
4 changes: 4 additions & 0 deletions test/integration/tc/base/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources: [bytecode.yaml, deployment.yaml]
19 changes: 19 additions & 0 deletions test/integration/tc/default/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
# Patch the deployment.yaml to change container image in Daemonset
# to new tag on the image.
images:
- name: quay.io/bpfman-userspace/go-tc-counter
newName: quay.io/bpfman-userspace/go-tc-counter
newTag: latest
# Patch the bytecode.yaml to change tag on the "url" field (which is an
# image) to new value. Since this is being done with an environment
# variable and using sed to replace, moved to patch.yaml.env which is
# converted to patch.yaml using the sed command in Makefile.
patches:
- path: patch.yaml
target:
kind: TcProgram
name: go-tc-counter-example
resources: [../../../test/integration/tc/base ]
6 changes: 6 additions & 0 deletions test/integration/tc/default/patch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
# Patch the bytecode.yaml to change image and tag on the "url" field
# (which is an image) to new value.
- op: replace
path: /spec/bytecode/image/url
value: quay.io/bpfman-bytecode/go-tc-counter:latest
5 changes: 5 additions & 0 deletions test/integration/tc/default/patch.yaml.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Patch the bytecode.yaml to change image and tag on the "url" field
# (which is an image) to new value.
- op: replace
path: "/spec/bytecode/image/url"
value: URL_BC
8 changes: 4 additions & 4 deletions test/integration/tc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
)

const (
tcGoCounterKustomize = "../../../examples/config/default/go-tc-counter"
tcGoCounterKustomize = "../../test/integration/tc/default"
tcGoCounterUserspaceNs = "go-tc-counter"
tcGoCounterUserspaceDsName = "go-tc-counter-ds"
)
Expand All @@ -36,9 +36,9 @@ func TestTcGoCounter(t *testing.T) {
daemon, err := env.Cluster().Client().AppsV1().DaemonSets(tcGoCounterUserspaceNs).Get(ctx, tcGoCounterUserspaceDsName, metav1.GetOptions{})
require.NoError(t, err)
return daemon.Status.DesiredNumberScheduled == daemon.Status.NumberAvailable
},
// Wait 5 minutes since cosign is slow, https://github.com/bpfman/bpfman/issues/1043
5 * time.Minute, 10 * time.Second)
},
// Wait 5 minutes since cosign is slow, https://github.com/bpfman/bpfman/issues/1043
5*time.Minute, 10*time.Second)

pods, err := env.Cluster().Client().CoreV1().Pods(tcGoCounterUserspaceNs).List(ctx, metav1.ListOptions{LabelSelector: "name=go-tc-counter"})
require.NoError(t, err)
Expand Down
16 changes: 16 additions & 0 deletions test/integration/tracepoint/base/bytecode.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
apiVersion: bpfman.io/v1alpha1
kind: TracepointProgram
metadata:
labels:
app.kubernetes.io/name: tracepointprogram
name: go-tracepoint-counter-example
spec:
bpffunctionname: tracepoint_kill_recorder
# Select all nodes
nodeselector: {}
names: [syscalls/sys_enter_kill]
bytecode:
image:
url: quay.io/bpfman-bytecode/go-tracepoint-counter:latest
imagepullpolicy: IfNotPresent
69 changes: 69 additions & 0 deletions test/integration/tracepoint/base/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---
apiVersion: v1
kind: Namespace
metadata:
name: go-tracepoint-counter
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: bpfman-app-go-tracepoint-counter
namespace: go-tracepoint-counter
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: go-tracepoint-counter-ds
namespace: go-tracepoint-counter
labels:
k8s-app: go-tracepoint-counter
spec:
selector:
matchLabels:
name: go-tracepoint-counter
template:
metadata:
labels:
name: go-tracepoint-counter
spec:
nodeSelector: {}
dnsPolicy: ClusterFirstWithHostNet
securityContext:
runAsNonRoot: true
fsGroup: 65534
serviceAccountName: bpfman-app-go-tracepoint-counter
tolerations:
# these tolerations are to have the daemonset runnable on control plane nodes
# remove them if your control plane nodes should not run pods
- key: node-role.kubernetes.io/control-plane
operator: Exists
effect: NoSchedule
- key: node-role.kubernetes.io/master
operator: Exists
effect: NoSchedule
containers:
- name: go-tracepoint-counter
image: quay.io/bpfman-userspace/go-tracepoint-counter:latest
imagePullPolicy: IfNotPresent
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop: [ALL]
runAsUser: 65534
runAsGroup: 65534
env:
- name: NODENAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
volumeMounts:
- name: go-tracepoint-counter-maps
mountPath: /run/tracepoint/maps
readOnly: true
volumes:
- name: go-tracepoint-counter-maps
csi:
driver: csi.bpfman.io
volumeAttributes:
csi.bpfman.io/program: go-tracepoint-counter-example
csi.bpfman.io/maps: tracepoint_stats_map
4 changes: 4 additions & 0 deletions test/integration/tracepoint/base/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources: [bytecode.yaml, deployment.yaml]
Loading

0 comments on commit da52dac

Please sign in to comment.