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

[BUG] Multiple secrets for single service result in non-unique "mountPath" error #1894

Open
gramian opened this issue Jun 5, 2024 · 6 comments
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@gramian
Copy link

gramian commented Jun 5, 2024

Expected Behavior

Multiple secrets for a single service are correctly translated.

Actual Behavior

"kubectl" reports:

Error from server (Invalid): error when creating "service-deployment.yaml": Deployment.apps "service" is invalid: spec.template.spec.containers[0].volumeMounts[1].mountPath: Invalid value: "/run/secrets": must be unique

Steps To Reproduce

  1. Prepare first secret: echo -n 'password1' > textfile1
  2. Prepare second secret: echo -n 'password2' > textfile2
  3. kompose convert -f compose.yaml
  4. minikube start
  5. kubectl apply -f .

Kompose Version

1.34 (cbf2835db)

Docker-Compose file

name: "test"

secrets:
  "secret1":
    file: "textfile1"
  "secret2":
    file: "textfile2"

services:

  "service":
    image: "hello-world:latest"
    ports:
      - "80:80"
    secrets:
      - "secret1"
      - "secret2"

Anything else?

No response

@gramian gramian added the kind/bug Categorizes issue or PR as related to a bug. label Jun 5, 2024
@cdrage
Copy link
Member

cdrage commented Jun 5, 2024

@sosan @gramian Do you think #1877 caused this? / same issue?

@gramian
Copy link
Author

gramian commented Jul 23, 2024

@cdrage @sosan The error is also happening for kompose 1.33, but not in kompose 1.32, if that helps.

@gramian
Copy link
Author

gramian commented Jul 25, 2024

I think I have an answer to this issue, and it should affect all secrets not only if there are multiple per service, just in this case it produces an error.

Since a workaround seems to be to append the secret's volume subPath to the mountPath, I think the conversion of the Compose file's services/servicename/secrets/target property to the pod's containers/volumeMounts/mountPath needs to be fixed in kompose.

For example, currently in 1.34, if the mountPath becomes /my/secrets then secrets becomes the file holding the secret and not the folder holding the secret.

@cdrage
Copy link
Member

cdrage commented Jul 25, 2024

I think I have an answer to this issue, and it should affect all secrets not only if there are multiple per service, just in this case it produces an error.

Since a workaround seems to be to append the secret's volume subPath to the mountPath, I think the conversion of the Compose file's services/servicename/secrets/target property to the pod's containers/volumeMounts/mountPath needs to be fixed in kompose.

For example, currently in 1.34, if the mountPath becomes /my/secrets then secrets becomes the file holding the secret and not the folder holding the secret.

Hi sorry for the late reply and thank you for investigating.

At the moment we do not have enough resources to fix this, but if there is any way you can open a PR, we could review it as well as make any changes / help out with tests if you're willing!

If not no worries, we'll most likely have more resources next month and can work on this.

@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle stale
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Oct 23, 2024
@gramian
Copy link
Author

gramian commented Oct 23, 2024

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

No branches or pull requests

4 participants