-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a9163fa
commit d5a4b87
Showing
2 changed files
with
74 additions
and
68 deletions.
There are no files selected for viewing
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,62 @@ | ||
You can find here also some indication on how to [set up a Microk8s environment in a Linux virtual machine](./microk8s.md). | ||
|
||
### How to initialize this project | ||
```sh | ||
helm create kapparmor | ||
sudo usermod -aG docker $USER | ||
|
||
# Create mod files in root dir | ||
go mod init github.com/tuxerrante/kapparmor | ||
go mod init ./go/src/app/ | ||
``` | ||
|
||
### Test the app locally | ||
|
||
Test Helm Chart creation | ||
```sh | ||
# --- Check the Helm chart | ||
# https://github.com/helm/chart-testing/issues/464 | ||
echo Linting the Helm chart | ||
helm lint --debug --strict charts/kapparmor/ | ||
|
||
docker run -it --network host --workdir=/data --volume ~/.kube/config:/root/.kube/config:ro \ | ||
--volume $(pwd):/data quay.io/helmpack/chart-testing:latest \ | ||
/bin/sh -c "git config --global --add safe.directory /data; ct lint --print-config --charts ./charts/kapparmor" | ||
|
||
# Replace here a commit id being part of an image tag | ||
export GITHUB_SHA="sha-93d0dc4c597a8ae8a9febe1d68e674daf1fa919a" | ||
helm install --dry-run --atomic --generate-name --timeout 30s --debug --set image.tag=$GITHUB_SHA charts/kapparmor/ | ||
|
||
``` | ||
|
||
Test the app inside a container: | ||
```sh | ||
# --- Build and run the container image | ||
docker build --quiet -t test-kapparmor --build-arg POLL_TIME=60 --build-arg PROFILES_DIR=/app/profiles -f Dockerfile . &&\ | ||
echo &&\ | ||
docker run --rm -it --privileged \ | ||
--mount type=bind,source='/sys/kernel/security',target='/sys/kernel/security' \ | ||
--mount type=bind,source='/etc',target='/etc'\ | ||
--name kapparmor test-kapparmor | ||
|
||
``` | ||
|
||
To test Helm chart installation in a MicroK8s cluster, follow `docs/microk8s.md` instructions if you don't have any local cluster. | ||
|
||
### Test on the Kubernetes cluster | ||
You can start a binary check inside the pod shell like this: | ||
```sh | ||
kapparmor_pod=$(kubectl get pods -l app.kubernetes.io/name=kapparmor --no-headers |grep Running |head -n1 |cut -d' ' -f1) | ||
kubectl exec -it $kapparmor_pod -- cat /proc/1/attr/current | ||
kubectl exec -it $kapparmor_pod -- cat /sys/module/apparmor/parameters/enabled | ||
kubectl exec -it $kapparmor_pod -- cat /sys/kernel/security/apparmor/profiles |sort | ||
|
||
# --- https://github.com/genuinetools/amicontained/releases | ||
export AMICONTAINED_SHA256="d8c49e2cf44ee9668219acd092ed961fc1aa420a6e036e0822d7a31033776c9f" | ||
curl -fSL "https://github.com/genuinetools/amicontained/releases/download/v0.4.9/amicontained-linux-amd64" -o "/usr/local/bin/amicontained" \ | ||
&& echo "${AMICONTAINED_SHA256} /usr/local/bin/amicontained" | sha256sum -c - \ | ||
&& chmod a+x "/usr/local/bin/amicontained" | ||
amicontained -h | ||
|
||
|
||
``` |