Search code examples
springspring-bootenvironment-variablesopenshiftpersistent-volumes

Openshift details in spring boot


I'm new to openshift.. Does anyone know how to configure openshift volume details in application.properties file in a spring boot application? I'm trying to access that path to upload files from my application.


Solution

  • You need to specify:

    • Volumes

    • VolumeMounts

    • Point SpringBoot to the VolumeMounts full path.

    Example in your deployment config, you would define:

    In your deployment.yaml ,

    apiVersion: apps.openshift.io/v1
    kind: DeploymentConfig
    .
    .
    .
    .
    .
    volumes:
      - name: data
        persistentVolumeClaim:
          claimName: my-data
    
    volumeMounts:
      - mountPath: /data/logs
        name: data 
    

    Then in your springboot properties you would create a property that points to the mountPath:

    LOGS_DIR: /data/logs