Giter Club home page Giter Club logo

Comments (3)

AhmedGrati avatar AhmedGrati commented on May 24, 2024

@dgarciabriseno with the following docker-compose.yml I couldn't reproduce the issue:

version: '3.8'
services:
  mongodb:
    image: mongo:latest
    restart: always
    expose:
      - 27017
    secrets:
    - config-ini

secrets:
  config-ini:
    file: secrets/Config.ini

The created secret and deployment are created as expected without any problem. Apart from that if you need to use Subpath you can use the label kompose.volume.subpath.
You can provide us with your docker-compose file for further help.

from kompose.

dgarciabriseno avatar dgarciabriseno commented on May 24, 2024

Sorry I was unresponsive, I hadn't worked on getting my compose project into kubernetes in a while. It looks like you guys may have found the issue since there's an open PR.

Here's an actual kubernetes deployment that shows the issue:

deployment:

apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    kompose.cmd: kompose convert -f ../compose.prod.yaml
    kompose.version: 1.31.2 (HEAD)
  creationTimestamp: null
  labels:
    io.kompose.service: database
  name: database
spec:
  replicas: 1
  selector:
    matchLabels:
      io.kompose.service: database
  strategy: {}
  template:
    metadata:
      annotations:
        kompose.cmd: kompose convert -f ../compose.prod.yaml
        kompose.version: 1.31.2 (HEAD)
      creationTimestamp: null
      labels:
        io.kompose.network/project-default: "true"
        io.kompose.service: database
    spec:
      containers:
        - env:
            - name: MARIADB_ROOT_PASSWORD_FILE
              value: /run/secrets/mariadb-password
          image: mariadb:11
          livenessProbe:
            exec:
              command:
                - bash
                - /usr/local/bin/healthcheck.sh
                - --connect
            failureThreshold: 3
            periodSeconds: 5
            timeoutSeconds: 5
          name: database
          resources: {}
          volumeMounts:
            - mountPath: /run/secrets/mariadb-password
              name: mariadb-password
      restartPolicy: Always
      volumes:
        - name: mariadb-password
          secret:
            items:
              - key: mariadb-password
                path: mariadb-password
            secretName: mariadb-password
status: {}

And password secret:

apiVersion: v1
data:
  mariadb-password: Zm9yLWtvbXBvc2UtdGVzdGluZwo=
kind: Secret
metadata:
  creationTimestamp: null
  labels:
    io.kompose.service: mariadb-password
  name: mariadb-password
type: Opaque

Put these in a folder and run:

$ kubectl apply -f .
deployment.apps/database created
secret/mariadb-password created

And I get this result:

$ kubectl get pod
NAME                       READY   STATUS             RESTARTS      AGE
database-9cd769646-52gd4   0/1     CrashLoopBackOff   2 (16s ago)   32s
$ kubectl logs database-9cd769646-52gd4
2024-02-09 19:56:49+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:11.2.2+maria~ubu2204 started.

Kind of weird that the error doesn't show up saying I'm missing the environment variable for the password.

But then if I edit volume mounts to include the subPath:

          volumeMounts:
            - mountPath: /run/secrets/mariadb-password
              subPath: mariadb-password
              name: mariadb-password

And reapply with kubectl apply -f .

Then all is good.

$ kubectl get pod
NAME                        READY   STATUS    RESTARTS   AGE
database-5955d99cb4-mpscc   1/1     Running   0          27s

from kompose.

sosan avatar sosan commented on May 24, 2024

updated fix to contemplate mays in secrets:

version: "3.9"
services:
  database:
    image: mariadb:11
    deploy:
      replicas: 1
    environment:
      MARIADB_ROOT_PASSWORD_FILE: /run/secrets/MARIADB_PASSWORD
    secrets:
      - MARIADB_PASSWORD
secrets:
  MARIADB_PASSWORD:
    file: "./mariadb-password.txt"

from kompose.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.