forked from kubearmor/KubeArmor
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'non-k8s-hsp-test' into main
- Loading branch information
Showing
45 changed files
with
1,946 additions
and
34 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
name: ci-test-docker | ||
|
||
on: | ||
push: | ||
branches: [main, non-k8s-hsp-test] | ||
paths: | ||
- "KubeArmor/**" | ||
- ".github/workflows/ci-test-docker.yaml" | ||
- "!STABLE-RELEASE" | ||
- "tests/nonk8s_env/**" | ||
|
||
jobs: | ||
build-and-run: | ||
name: Build KubeArmor artifacts and run tests / ${{ matrix.os }} | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ubuntu-latest] | ||
timeout-minutes: 60 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
submodules: true | ||
|
||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version-file: 'KubeArmor/go.mod' | ||
|
||
- name: Install the latest LLVM toolchain | ||
run: ./.github/workflows/install-llvm.sh | ||
|
||
- name: Compile libbpf | ||
run: ./.github/workflows/install-libbpf.sh | ||
|
||
- name: Generate KubeArmor artifacts | ||
run: | | ||
GITHUB_SHA=$GITHUB_SHA ./KubeArmor/build/build_kubearmor.sh | ||
# - name: Run KubeArmor init container | ||
# run: | | ||
# docker run --name kubearmor-init -v /tmp/:/opt/kubearmor/BPF kubearmor/kubearmor-init | ||
|
||
# - name: Run KubeArmor container | ||
# run: | | ||
# docker run -d --name kubearmor --privileged --pid host -p 32767:32767 \ | ||
# -v /tmp/:/opt/kubearmor/BPF \ | ||
# -v /sys/fs/bpf:/sys/fs/bpf \ | ||
# -v /sys/kernel/security:/sys/kernel/security \ | ||
# -v /sys/kernel/debug:/sys/kernel/debug \ | ||
# -v /var/run/docker.sock:/var/run/docker.sock \ | ||
# -v /var/lib/docker:/var/lib/docker \ | ||
# -v /etc/apparmor.d:/etc/apparmor.d \ | ||
# kubearmor/kubearmor -k8s=false -enableKubeArmorHostPolicy | ||
|
||
- name: Run KubeArmor with docker-compose | ||
run: | | ||
docker-compose -f docker-compose.yaml up -d | ||
- name: Test KubeArmor using Ginkgo | ||
run: | | ||
go install -mod=mod github.com/onsi/ginkgo/v2/ginkgo | ||
make | ||
working-directory: ./tests/nonk8s_env | ||
timeout-minutes: 30 | ||
|
||
- name: Archive log artifacts | ||
if: ${{ failure() }} | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: kubearmor.logs | ||
path: | | ||
/tmp/kubearmor/ | ||
/tmp/kubearmor.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/bash | ||
|
||
DAEMONSET_NAME=$(kubectl get daemonset -n kubearmor -o jsonpath='{.items[0].metadata.name}') | ||
|
||
kubectl patch daemonset $DAEMONSET_NAME -n kubearmor --type='json' -p='[ | ||
{ | ||
"op": "add", | ||
"path": "/spec/template/spec/containers/0/args/-", | ||
"value": "-enableKubeArmorHostPolicy" | ||
} | ||
]' | ||
|
||
sleep 16 | ||
|
||
# Apply annotations to the node | ||
NODE_NAME=$(kubectl get nodes -o=jsonpath='{.items[0].metadata.name}') | ||
kubectl annotate node $NODE_NAME "kubearmorvisibility=process,file,network,capabilities" | ||
kubectl get no -o wide |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
coverage: | ||
status: | ||
project: | ||
default: | ||
target: auto | ||
threshold: 5% | ||
base: auto | ||
|
||
ignore: | ||
- "KubeArmor/enforcer/SELinuxEnforcer.go" | ||
- "KubeArmor/enforcer/SELinuxEnforcer_test.go" | ||
- "KubeArmor/enforcer/SELinuxHostProfile.go" | ||
- "KubeArmor/kvmAgent" | ||
- "KubeArmor/state" | ||
|
||
comment: | ||
layout: "reach, diff, flags, files" | ||
behavior: default | ||
require_changes: true | ||
|
||
parsers: | ||
gcov: | ||
branch_detection: | ||
conditional: yes | ||
loop: yes | ||
method: no | ||
macro: no |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
services: | ||
kubearmor-init: | ||
image: kubearmor/kubearmor-init:stable | ||
volumes: | ||
- /tmp/:/opt/kubearmor/BPF | ||
|
||
kubearmor: | ||
image: kubearmor/kubearmor:latest | ||
depends_on: | ||
kubearmor-init: | ||
condition: service_completed_successfully | ||
privileged: true | ||
command: ["-k8s=false", "-enableKubeArmorHostPolicy"] | ||
pid: "host" | ||
ports: | ||
- "32767:32767" | ||
volumes: | ||
- /tmp/:/opt/kubearmor/BPF | ||
- /sys/fs/bpf:/sys/fs/bpf | ||
- /sys/kernel/security:/sys/kernel/security | ||
- /sys/kernel/debug:/sys/kernel/debug | ||
- /var/run/docker.sock:/var/run/docker.sock | ||
- /var/lib/docker:/var/lib/docker | ||
- /etc/apparmor.d:/etc/apparmor.d |
30 changes: 30 additions & 0 deletions
30
pkg/KubeArmorOperator/config/samples/kubearmor-coverage.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
apiVersion: operator.kubearmor.com/v1 | ||
kind: KubeArmorConfig | ||
metadata: | ||
labels: | ||
app.kubernetes.io/name: kubearmorconfig | ||
app.kubernetes.io/instance: kubearmorconfig-sample | ||
app.kubernetes.io/part-of: kubearmoroperator | ||
app.kubernetes.io/managed-by: kustomize | ||
app.kubernetes.io/created-by: kubearmoroperator | ||
name: kubearmorconfig-test | ||
namespace: kubearmor | ||
spec: | ||
defaultCapabilitiesPosture: block | ||
defaultFilePosture: block | ||
defaultNetworkPosture: block | ||
defaultVisibility: process,file,network,capabilities | ||
seccompEnabled: false | ||
kubearmorImage: | ||
image: kubearmor/kubearmor-test:latest | ||
imagePullPolicy: Never | ||
kubearmorInitImage: | ||
image: kubearmor/kubearmor-test-init:latest | ||
imagePullPolicy: Never | ||
kubearmorRelayImage: | ||
image: kubearmor/kubearmor-relay-server:latest | ||
imagePullPolicy: Always | ||
kubearmorControllerImage: | ||
image: kubearmor/kubearmor-controller:latest | ||
imagePullPolicy: Always | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.