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

ci: generate seccomp profile within pipeline #1325

Merged

Conversation

alegrey91
Copy link
Contributor

@alegrey91 alegrey91 commented Jan 19, 2025

This PR introduces the ability of generating seccomp profiles within the pipeline.
This will be helpful in case some user wants to secure his capsule installation by leveraging the power of seccomp.

To do so, capsule container image is built replacing the base image with the one provided by harpoon. This will allow the execution of capsule through harpoon.
Then, set up a Kubernetes cluster using kind with a shared folder that is used to retrieve the metadata generated by harpoon during the e2e tests execution.
Capsule image is consequently installed on the cluster with a customized values file from helm, and the e2e could start.
Once finished, the results are merged with the tracing of the unit tests (handled by harpoon).
This generates the seccomp profile tailored for capsule, which is going to be uploaded with the other artifacts in the upcoming releases.

Copy link

netlify bot commented Jan 19, 2025

Deploy Preview for capsule-documentation canceled.

Name Link
🔨 Latest commit f24d2f1
🔍 Latest deploy log https://app.netlify.com/sites/capsule-documentation/deploys/67a473946e8924000889ef25

@alegrey91 alegrey91 changed the title Ci/harpoon integration ci: generate seccomp profiles Jan 19, 2025
@alegrey91 alegrey91 force-pushed the ci/harpoon-integration branch from 2816ee9 to 62f2e5f Compare January 28, 2025 17:27
@alegrey91 alegrey91 changed the title ci: generate seccomp profiles ci: generate seccomp profiles within pipeline Jan 28, 2025
@alegrey91 alegrey91 changed the title ci: generate seccomp profiles within pipeline ci: generate seccomp profile within pipeline Jan 28, 2025
@alegrey91 alegrey91 marked this pull request as ready for review January 28, 2025 17:42
Copy link
Collaborator

@oliverbaehler oliverbaehler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @alegrey91 great tool, hope we can get you gain some traction as example. I have requested changes regarding the chart

Makefile Outdated
Comment on lines 241 to 243
harpoon: ## Download harpoon locally if necessary.
@curl -s https://raw.githubusercontent.com/alegrey91/harpoon/main/install | \
sudo bash -s -- --install-version $(HARPOON_VERSION)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a big fan of this, we should try to install binaries into the project's bin/ folder, i am assuming this is going to install harpoon at system level. Since it,s go, can't we make a target like the other binary dependencies:

HARPOON = $(shell pwd)/bin/harpoon
HARPOON_VERSION = v0.9.4
harpoon:
	$(call go-install-tool,$(HARPOON),github.com/alegrey91/harpoon@$(HARPOON_VERSION))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @oliverbaehler, unfortunately I don't think we can currently use go install with harpoon.
The project has a complex toolchain that requires a separated compilation of the ebpf object.
About the installation directory, I think this is fine, I can set the location through the install script.

charts/capsule/values-tracing.yaml Outdated Show resolved Hide resolved
charts/capsule/templates/deployment.yaml Show resolved Hide resolved
charts/capsule/templates/deployment.yaml Outdated Show resolved Hide resolved
@alegrey91
Copy link
Contributor Author

Hello @oliverbaehler, I'm having a problem with the Test charts pipeline.
It's failing due to my values file ci/tracing-values.yaml because this specific configuration needs kind to be configured with an extraMount (see hack/kind-cluster.yml). Without this cluster config, the chart is unable to mount the volumes specified within the values file.
What can we do to fix it?

@alegrey91
Copy link
Contributor Author

Hello @oliverbaehler, I'm having a problem with the Test charts pipeline. It's failing due to my values file ci/tracing-values.yaml because this specific configuration needs kind to be configured with an extraMount (see hack/kind-cluster.yml). Without this cluster config, the chart is unable to mount the volumes specified within the values file. What can we do to fix it?

I'm thinking about a possible solution for that. Since the ci/tracing-values.yaml is not a "production" values file, we could skip its test with ct and create a dedicated workflow to generate seccomp profiles for each PR. This way we will check its validity every time a new PR is coming. Integrate it with ct is quite hard because there are several pre-requirements:

  • build the custom capsule image with harpoon within the container
  • create a kind cluster with a custom configuration to share folders with the container

@oliverbaehler
Copy link
Collaborator

@alegrey91 can you grant me access to your fork?

@alegrey91
Copy link
Contributor Author

@alegrey91 can you grant me access to your fork?

You should have access now.

@oliverbaehler
Copy link
Collaborator

@alegrey91 I can't invest more time into this, sorry. I heave reconciled your targets and simplified the approach. It should now work better.

@alegrey91
Copy link
Contributor Author

@oliverbaehler any reasons why the other workflows are not starting anymore?

@oliverbaehler
Copy link
Collaborator

@alegrey91 conflicts?

@alegrey91 alegrey91 force-pushed the ci/harpoon-integration branch 4 times, most recently from 186a22f to a0f3d18 Compare February 5, 2025 22:49
@alegrey91
Copy link
Contributor Author

alegrey91 commented Feb 5, 2025

@oliverbaehler ready for review.
thanks for the fixes :)
P.s. the seccomp ci is currently failing due to the docker hub pull rate limit 😅
You could re-run it separately and should work.

Copy link
Collaborator

@oliverbaehler oliverbaehler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final changes, sowy :3

.github/workflows/seccomp.yaml Outdated Show resolved Hide resolved
@alegrey91 alegrey91 force-pushed the ci/harpoon-integration branch from a0f3d18 to f24d2f1 Compare February 6, 2025 08:32
@alegrey91
Copy link
Contributor Author

@oliverbaehler can you please re-run the CI?

@oliverbaehler oliverbaehler merged commit b7a2072 into projectcapsule:main Feb 6, 2025
18 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants