Skip to content

[BUG] Kompose does not mount secrets like compose #1778

@dgarciabriseno

Description

@dgarciabriseno

Expected Behavior

secrets defined in compose.yaml should be mounted in the pods in /run/secrets/<secret>

Actual Behavior

/run/secrets/<secret> is mounted as a directory

Steps To Reproduce

  1. Add secrets to compose.yaml
services:
  myservice:
    ...
    secrets:
      - config-ini

secrets:
  config-ini:
    file: secrets/Config.ini
  1. kompose convert

  2. examine generated pod config file:

The result is:

volumeMounts:
  - mountPath: /run/secrets/config-ini
     name: config-ini

Which appears correct at a glance, but when running, I get the error that config-ini is a directory.

Kompose Version

1.31.2 (HEAD)

Docker-Compose file

No response

Anything else?

I was able to fix the pod file by adding subPath:

volumeMounts:
  - mountPath: /run/secrets/config-ini
    subPath: config-ini
    name: config-ini

With subPath, it gets mounted as a file instead of a directory.

I don't know k8 very well, I would guess it's mounted as a directory because secrets can hold more than one key-value pair. In that case it wouldn't necessarily make sense to put all the key-value pairs into one file, especially if each key should be its own file.

But with docker compose, secrets are only one key->value, so that behavior should be translated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions