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

feat: Add Env Secrets in Server API #533

Open
wants to merge 28 commits into
base: main
Choose a base branch
from

Conversation

jonas-martinez
Copy link
Collaborator

@jonas-martinez jonas-martinez commented Jan 19, 2024

About this PR

This PR enables the server to generate secrets on Kubernetes via the API, allowing OpenFaas to link these secrets when setting up an environment. This approach lets you utilize secrets in your application without embedding them directly into the Docker image.

Additionally, it introduces a new environment variable:

KUBERNETES_APPS_NAMESPACE:  A string representing the namespace in Kubernetes where the apps are located. The environment secrets will be created in this namespace.

Technical highlight/advice

How to test my changes

Checklist

  • I didn't over-scope my PR
  • My PR title matches the commit convention
  • I did not include breaking changes
  • I made my own code-review before requesting one

I included unit tests that cover my changes

  • 👍 yes
  • 🙅 no, because they aren't needed
  • 🙋 no, because I need help

I added/updated the documentation about my changes

  • 📜 README.md
  • 📕 docs/*.md
  • 📓 docs.lenra.io
  • 🙅 no documentation needed

@jonas-martinez jonas-martinez added the enhancement New feature or request label Jan 19, 2024
@shiipou shiipou force-pushed the feat/Add-Env-Secrets-in-Server-API branch from 6871e98 to ad3b028 Compare February 23, 2024 11:27
@shiipou
Copy link
Contributor

shiipou commented Feb 23, 2024

I still have an issue with the update
And the delete show an error but work and delete the key.

I have to find out why.

Copy link
Collaborator Author

@jonas-martinez jonas-martinez left a comment

Choose a reason for hiding this comment

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

Some refactoring must be done because there is functions definitions that have a quite high complexity as per the results of mix credo --strict.

We should make some functions easier to read and maintain.

Please look at mix credo --strict command for more information.


case secret_response do
{:ok, _} ->
{:ok} ->
Copy link
Collaborator Author

@jonas-martinez jonas-martinez Mar 2, 2024

Choose a reason for hiding this comment

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

You changed this case but it causes an error when trying to deploy an application.

Here are the logs :

11:10:37.446 request_id=F7juFiPvtMtTt9AAAprh [info] POST /api/apps/389/builds
11:10:37.582 request_id=F7juFiPvtMtTt9AAAprh [info] Sent 500 in 135ms
11:10:37.583 [error] #PID<0.24822.0> running LenraWeb.Endpoint (connection #PID<0.24819.0>, stream id 3) terminated
Server: api.staging.lenra.io:80 (http)
Request: POST /api/apps/389/builds
** (exit) an exception was raised:
    ** (CaseClauseError) no case clause matching: {:ok, %{APP_REPOSITORY: "https://github.com/lenra-io/template-bun-js.git", CALLBACK_URL: "http://lenra-server.lenra.svc.cluster.local:4000/runner/builds/915?secret=**********", IMAGE_NAME: "registry.gitlab.com/lenra/platform/lenra-ci/staging/dd14cd88-07d9-4711-9d4c-1a1d9d02b8b4:2", REPOSITORY_BRANCH: "secret"}}
        (lenra 0.1.0) lib/lenra/kubernetes/api_services.ex:56: Lenra.Kubernetes.ApiServices.create_pipeline/6
        (lenra 0.1.0) lib/lenra/apps.ex:266: Lenra.Apps.trigger_pipeline/3
        (lenra 0.1.0) lib/lenra/apps.ex:240: Lenra.Apps.create_build_and_deploy/3
        (lenra_web 0.1.0) lib/lenra_web/controllers/build_controller.ex:23: LenraWeb.BuildsController.create/2
        (lenra_web 0.1.0) lib/lenra_web/controllers/build_controller.ex:1: LenraWeb.BuildsController.action/2
        (lenra_web 0.1.0) lib/lenra_web/controllers/build_controller.ex:1: LenraWeb.BuildsController.phoenix_controller_pipeline/2
        (phoenix 1.6.16) lib/phoenix/router.ex:354: Phoenix.Router.__call__/2
        (lenra_web 0.1.0) lib/lenra_web/endpoint.ex:1: LenraWeb.Endpoint.plug_builder_call/2

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@shiipou I'm tagging you because I can't set this comment as blocking for the PR as I am the creator.

@jonas-martinez
Copy link
Collaborator Author

@shiipou I don't know why but when using this branch, the server won't open the websocket to the app.

I tried to find the origin of the problem but there is no error on the server.

@shiipou
Copy link
Contributor

shiipou commented Jun 17, 2024

@shiipou I don't know why but when using this branch, the server won't open the websocket to the app.

I tried to find the origin of the problem but there is no error on the server.

@jonas-martinez I'll check this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: 🟢 In Progress
Development

Successfully merging this pull request may close these issues.

2 participants