Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Review #1

Open
wants to merge 27 commits into
base: empty
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
1826af6
initial commit
NissesSenap May 1, 2021
cef7ce4
Update yaml
NissesSenap May 1, 2021
f5ca713
pipelinerun not pipline in triggerTemplate
NissesSenap May 2, 2021
4e984ea
Removal of all extra params
NissesSenap May 2, 2021
fc6503e
go code that works
NissesSenap May 2, 2021
ebed023
change hello task image to poddeleter:3a9d3d5
NissesSenap May 2, 2021
a5cdefd
Improve instructions
NissesSenap May 2, 2021
c3b292b
Merge branch 'main' into review
NissesSenap May 3, 2021
b118f1d
Split up main in a few functions
NissesSenap May 3, 2021
1662cc9
Merge branch 'main' into review
NissesSenap May 3, 2021
4dc3cc3
Change from hello task to pod-delete
NissesSenap May 3, 2021
290d77a
Rename param body to falco-event
NissesSenap May 3, 2021
829dcc2
Update README to match the new names
NissesSenap May 3, 2021
fb02076
Merge branch 'main' into review
NissesSenap May 3, 2021
30caa0b
Fix spelling errors
NissesSenap May 3, 2021
1746d57
Merge branch 'main' into review
NissesSenap May 3, 2021
5bb363e
Use hash map instead of []string
NissesSenap May 3, 2021
57b8fa4
minor updates to README
NissesSenap May 3, 2021
0191e76
Merge branch 'main' into review
NissesSenap May 3, 2021
abcecf9
use hash map correct...
NissesSenap May 3, 2021
c5d7068
Merge branch 'main' into review
NissesSenap May 3, 2021
d0ff146
Update README to match go code
NissesSenap May 3, 2021
b77e9c5
Merge branch 'main' into review
NissesSenap May 3, 2021
a0037ab
Being more consistent in main.go
NissesSenap May 4, 2021
bfd4f47
Merge branch 'main' into review
NissesSenap May 4, 2021
a4d9897
Update docker tag to latest
NissesSenap May 4, 2021
42ae948
Merge branch 'main' into review
NissesSenap May 4, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
FROM golang:1.16-buster as builder

WORKDIR /app

COPY go.mod go.sum ./

RUN go mod download

COPY . .

RUN make bin/pc

FROM debian:buster-slim

ARG VERSION=0.0.1
ARG BUILD_DATE=2021-05-1

LABEL \
org.opencontainers.image.created="$BUILD_DATE" \
org.opencontainers.image.authors="[email protected]" \
org.opencontainers.image.homepage="https://github.com/NissesSenap/falcosidekick-tekton" \
org.opencontainers.image.documentation="https://github.com/NissesSenap/falcosidekick-tekton" \
org.opencontainers.image.source="https://github.com/NissesSenap/falcosidekick-tekton" \
org.opencontainers.image.version="$VERSION" \
org.opencontainers.image.vendor="GitHub" \
org.opencontainers.image.licenses="MIT" \
summary="Kubernetes response Engine deletes pods after commands from falcosidekick" \
description="Kubernetes response Engine delete pods is meant to be run inside k8s and delete pods after getting instructions from falcosidekick." \
name="podDeleter"

RUN apt-get update && apt-get upgrade -y \
&& rm -rf /var/lib/apt/lists/*

USER 1001

WORKDIR /app

COPY --from=builder /app/bin/poddeleter .

CMD ["/app/poddeleter"]
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 Edvin N

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
28 changes: 28 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
BUILD_FILES = $(shell go list -f '{{range .GoFiles}}{{$$.Dir}}/{{.}}\
{{end}}' ./...)

GH_VERSION ?= $(shell git describe --tags 2>/dev/null || git rev-parse --short HEAD)
DATE_FMT = +%Y-%m-%d
BUILD_DATE = $(shell date "$(DATE_FMT)")
IMAGE_REPO = "quay.io/nissessenap/poddeleter"

print-% : ; @echo $* = $($*)

bin/pc: $(BUILD_FILES)
@go build -trimpath -o bin/poddeleter ./main.go

bin/container:
docker build --build-arg BUILD_DATE=$(BUILD_DATE) --build-arg VERSION=$(GH_VERSION) . -t $(IMAGE_REPO):$(GH_VERSION)
.PHONY: bin/container

bin/push:
docker push $(IMAGE_REPO):$(GH_VERSION)
NissesSenap marked this conversation as resolved.
Show resolved Hide resolved
.PHONY: bin/push

clean:
rm -rf ./bin ./share
.PHONY: clean

test:
go test ./...
.PHONY: test
16 changes: 16 additions & 0 deletions NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Ideas

## TODO

- Create a super simple go app that works with the incoming data.
- probably just a single body for now, then discuss with falco community.
- Create a Dockerfile
- Push dockerfile to quay.io
- Verify e2e workflow

## Output example

This is how I can easily test my go application.
This output is from a command that is not okay in falco.

export BODY='{"output":"17:30:51.428027354: Notice A shell was spawned in a container with an attached terminal (user=root user_loginuid=-1 k8s.ns=falcoresponse k8s.pod=alpine container=ac7c5359a04b shell=sh parent=runc cmdline=sh -c cat /etc/resolv.conf terminal=34816 container_id=ac7c5359a04b image=alpine) k8s.ns=falcoresponse k8s.pod=alpine container=ac7c5359a04b k8s.ns=falcoresponse k8s.pod=alpine container=ac7c5359a04b","priority":"Notice","rule":"Terminal shell in container","time":"2021-05-02T17:30:51.428027354Z", "output_fields": {"container.id":"ac7c5359a04b","container.image.repository":"alpine","evt.time":1619976651428027354,"k8s.ns.name":"falcoresponse","k8s.pod.name":"alpine","proc.cmdline":"sh -c cat /etc/resolv.conf","proc.name":"sh","proc.pname":"runc","proc.tty":34816,"user.loginuid":-1,"user.name":"root"}}'
Loading