Shared volume of 1 container into another container in Kubernates





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







1















I am stuck on a scenario where I have to get the log folder of container 1 into 2nd container. I have found a solution in which we will create a emptyDir directory.



spec:
containers:
- name: app
image: app-image
imagePullPolicy: Always
ports:
- containerPort: 8080
volumeMounts:
- name: logs
mountPath: /var/log/app/
- name: uf
image: splunk/splunkuniversalforwarder
...
volumeMounts:
- name: logs
mountPath: /var/log/app/
volumes:
- name: logs
emptyDir: {}


But in my situation I want to share /usr/var/log/tomcat/ of 1st container into /var/log/message. This is because splunkUF image will monitor /var/log/app/. so I want to share the log folder of different apps, be it /var/log/app/tomcat or /var/log/messages but at one same location with splunk container /var/log/app/.



I can run copy command to get the log 1 time but how to get the logs continuously?










share|improve this question























  • Which version of kubernetes are you using?

    – Urosh T.
    Nov 22 '18 at 8:39











  • I am using latest but does it make any difference? So that I document the version for my reference

    – gamechanger17
    Nov 22 '18 at 9:36











  • emptyDir is not good because it will be deleted once the pod is re-assigned. Also, are you using Volumes or PersistentVolumes? I asked for a version because there are some things in beta that might help you but it ain't easy. Example: kubernetes.io/docs/concepts/storage/volumes/#mount-propagation

    – Urosh T.
    Nov 22 '18 at 10:05











  • @UroshT. I am not using beta. So what could be my best options apart for the one present in beta?

    – gamechanger17
    Nov 22 '18 at 10:08











  • @gamechanger17, Have you considered to set remote logging via rsyslog and catch logs in /var/log/messages like described here? There is also solution for Tomcat.

    – mk_sta
    Nov 22 '18 at 11:36




















1















I am stuck on a scenario where I have to get the log folder of container 1 into 2nd container. I have found a solution in which we will create a emptyDir directory.



spec:
containers:
- name: app
image: app-image
imagePullPolicy: Always
ports:
- containerPort: 8080
volumeMounts:
- name: logs
mountPath: /var/log/app/
- name: uf
image: splunk/splunkuniversalforwarder
...
volumeMounts:
- name: logs
mountPath: /var/log/app/
volumes:
- name: logs
emptyDir: {}


But in my situation I want to share /usr/var/log/tomcat/ of 1st container into /var/log/message. This is because splunkUF image will monitor /var/log/app/. so I want to share the log folder of different apps, be it /var/log/app/tomcat or /var/log/messages but at one same location with splunk container /var/log/app/.



I can run copy command to get the log 1 time but how to get the logs continuously?










share|improve this question























  • Which version of kubernetes are you using?

    – Urosh T.
    Nov 22 '18 at 8:39











  • I am using latest but does it make any difference? So that I document the version for my reference

    – gamechanger17
    Nov 22 '18 at 9:36











  • emptyDir is not good because it will be deleted once the pod is re-assigned. Also, are you using Volumes or PersistentVolumes? I asked for a version because there are some things in beta that might help you but it ain't easy. Example: kubernetes.io/docs/concepts/storage/volumes/#mount-propagation

    – Urosh T.
    Nov 22 '18 at 10:05











  • @UroshT. I am not using beta. So what could be my best options apart for the one present in beta?

    – gamechanger17
    Nov 22 '18 at 10:08











  • @gamechanger17, Have you considered to set remote logging via rsyslog and catch logs in /var/log/messages like described here? There is also solution for Tomcat.

    – mk_sta
    Nov 22 '18 at 11:36
















1












1








1








I am stuck on a scenario where I have to get the log folder of container 1 into 2nd container. I have found a solution in which we will create a emptyDir directory.



spec:
containers:
- name: app
image: app-image
imagePullPolicy: Always
ports:
- containerPort: 8080
volumeMounts:
- name: logs
mountPath: /var/log/app/
- name: uf
image: splunk/splunkuniversalforwarder
...
volumeMounts:
- name: logs
mountPath: /var/log/app/
volumes:
- name: logs
emptyDir: {}


But in my situation I want to share /usr/var/log/tomcat/ of 1st container into /var/log/message. This is because splunkUF image will monitor /var/log/app/. so I want to share the log folder of different apps, be it /var/log/app/tomcat or /var/log/messages but at one same location with splunk container /var/log/app/.



I can run copy command to get the log 1 time but how to get the logs continuously?










share|improve this question














I am stuck on a scenario where I have to get the log folder of container 1 into 2nd container. I have found a solution in which we will create a emptyDir directory.



spec:
containers:
- name: app
image: app-image
imagePullPolicy: Always
ports:
- containerPort: 8080
volumeMounts:
- name: logs
mountPath: /var/log/app/
- name: uf
image: splunk/splunkuniversalforwarder
...
volumeMounts:
- name: logs
mountPath: /var/log/app/
volumes:
- name: logs
emptyDir: {}


But in my situation I want to share /usr/var/log/tomcat/ of 1st container into /var/log/message. This is because splunkUF image will monitor /var/log/app/. so I want to share the log folder of different apps, be it /var/log/app/tomcat or /var/log/messages but at one same location with splunk container /var/log/app/.



I can run copy command to get the log 1 time but how to get the logs continuously?







kubernetes splunk






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 22 '18 at 7:51









gamechanger17gamechanger17

1831112




1831112













  • Which version of kubernetes are you using?

    – Urosh T.
    Nov 22 '18 at 8:39











  • I am using latest but does it make any difference? So that I document the version for my reference

    – gamechanger17
    Nov 22 '18 at 9:36











  • emptyDir is not good because it will be deleted once the pod is re-assigned. Also, are you using Volumes or PersistentVolumes? I asked for a version because there are some things in beta that might help you but it ain't easy. Example: kubernetes.io/docs/concepts/storage/volumes/#mount-propagation

    – Urosh T.
    Nov 22 '18 at 10:05











  • @UroshT. I am not using beta. So what could be my best options apart for the one present in beta?

    – gamechanger17
    Nov 22 '18 at 10:08











  • @gamechanger17, Have you considered to set remote logging via rsyslog and catch logs in /var/log/messages like described here? There is also solution for Tomcat.

    – mk_sta
    Nov 22 '18 at 11:36





















  • Which version of kubernetes are you using?

    – Urosh T.
    Nov 22 '18 at 8:39











  • I am using latest but does it make any difference? So that I document the version for my reference

    – gamechanger17
    Nov 22 '18 at 9:36











  • emptyDir is not good because it will be deleted once the pod is re-assigned. Also, are you using Volumes or PersistentVolumes? I asked for a version because there are some things in beta that might help you but it ain't easy. Example: kubernetes.io/docs/concepts/storage/volumes/#mount-propagation

    – Urosh T.
    Nov 22 '18 at 10:05











  • @UroshT. I am not using beta. So what could be my best options apart for the one present in beta?

    – gamechanger17
    Nov 22 '18 at 10:08











  • @gamechanger17, Have you considered to set remote logging via rsyslog and catch logs in /var/log/messages like described here? There is also solution for Tomcat.

    – mk_sta
    Nov 22 '18 at 11:36



















Which version of kubernetes are you using?

– Urosh T.
Nov 22 '18 at 8:39





Which version of kubernetes are you using?

– Urosh T.
Nov 22 '18 at 8:39













I am using latest but does it make any difference? So that I document the version for my reference

– gamechanger17
Nov 22 '18 at 9:36





I am using latest but does it make any difference? So that I document the version for my reference

– gamechanger17
Nov 22 '18 at 9:36













emptyDir is not good because it will be deleted once the pod is re-assigned. Also, are you using Volumes or PersistentVolumes? I asked for a version because there are some things in beta that might help you but it ain't easy. Example: kubernetes.io/docs/concepts/storage/volumes/#mount-propagation

– Urosh T.
Nov 22 '18 at 10:05





emptyDir is not good because it will be deleted once the pod is re-assigned. Also, are you using Volumes or PersistentVolumes? I asked for a version because there are some things in beta that might help you but it ain't easy. Example: kubernetes.io/docs/concepts/storage/volumes/#mount-propagation

– Urosh T.
Nov 22 '18 at 10:05













@UroshT. I am not using beta. So what could be my best options apart for the one present in beta?

– gamechanger17
Nov 22 '18 at 10:08





@UroshT. I am not using beta. So what could be my best options apart for the one present in beta?

– gamechanger17
Nov 22 '18 at 10:08













@gamechanger17, Have you considered to set remote logging via rsyslog and catch logs in /var/log/messages like described here? There is also solution for Tomcat.

– mk_sta
Nov 22 '18 at 11:36







@gamechanger17, Have you considered to set remote logging via rsyslog and catch logs in /var/log/messages like described here? There is also solution for Tomcat.

– mk_sta
Nov 22 '18 at 11:36














2 Answers
2






active

oldest

votes


















2














I don't see an issue here.
you can mount the same volume at a different location in each container.



According to your description this should be something like this:



spec:
containers:
- name: app
image: app-image
...
volumeMounts:
- name: logs
mountPath: /usr/var/log/tomcat/
- name: uf
image: splunk/splunkuniversalforwarder
...
volumeMounts:
- name: logs
mountPath: /var/log/app/
volumes:
- name: logs
emptyDir: {}





share|improve this answer


























  • Yes that is the issue. but I don't see the logs in /var/log/app/ location if I go inside the uf container.

    – gamechanger17
    Nov 22 '18 at 12:27













  • And you do see them in /usr/var/log/tomcat/ in the tomcat one?

    – antweiss
    Nov 22 '18 at 12:57











  • Now I can see the logs on the shared volume but Splunkuf is not forwarding the logs to the server. I have created a new thread: stackoverflow.com/questions/53669208/…

    – gamechanger17
    Dec 10 '18 at 6:24





















0














If you are using PersistentVolumeClaim or PersistentVolume, I got bad news because the access modes are pretty limited. The one you would want is ReadWriteMany but it has a really limited support ATM. See more info here.



You could do with this however it has limitations of having to share a node host which not might be a desirable behaviour. I believe that something that would best suit your case would be this.






share|improve this answer
























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53426160%2fshared-volume-of-1-container-into-another-container-in-kubernates%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2














    I don't see an issue here.
    you can mount the same volume at a different location in each container.



    According to your description this should be something like this:



    spec:
    containers:
    - name: app
    image: app-image
    ...
    volumeMounts:
    - name: logs
    mountPath: /usr/var/log/tomcat/
    - name: uf
    image: splunk/splunkuniversalforwarder
    ...
    volumeMounts:
    - name: logs
    mountPath: /var/log/app/
    volumes:
    - name: logs
    emptyDir: {}





    share|improve this answer


























    • Yes that is the issue. but I don't see the logs in /var/log/app/ location if I go inside the uf container.

      – gamechanger17
      Nov 22 '18 at 12:27













    • And you do see them in /usr/var/log/tomcat/ in the tomcat one?

      – antweiss
      Nov 22 '18 at 12:57











    • Now I can see the logs on the shared volume but Splunkuf is not forwarding the logs to the server. I have created a new thread: stackoverflow.com/questions/53669208/…

      – gamechanger17
      Dec 10 '18 at 6:24


















    2














    I don't see an issue here.
    you can mount the same volume at a different location in each container.



    According to your description this should be something like this:



    spec:
    containers:
    - name: app
    image: app-image
    ...
    volumeMounts:
    - name: logs
    mountPath: /usr/var/log/tomcat/
    - name: uf
    image: splunk/splunkuniversalforwarder
    ...
    volumeMounts:
    - name: logs
    mountPath: /var/log/app/
    volumes:
    - name: logs
    emptyDir: {}





    share|improve this answer


























    • Yes that is the issue. but I don't see the logs in /var/log/app/ location if I go inside the uf container.

      – gamechanger17
      Nov 22 '18 at 12:27













    • And you do see them in /usr/var/log/tomcat/ in the tomcat one?

      – antweiss
      Nov 22 '18 at 12:57











    • Now I can see the logs on the shared volume but Splunkuf is not forwarding the logs to the server. I have created a new thread: stackoverflow.com/questions/53669208/…

      – gamechanger17
      Dec 10 '18 at 6:24
















    2












    2








    2







    I don't see an issue here.
    you can mount the same volume at a different location in each container.



    According to your description this should be something like this:



    spec:
    containers:
    - name: app
    image: app-image
    ...
    volumeMounts:
    - name: logs
    mountPath: /usr/var/log/tomcat/
    - name: uf
    image: splunk/splunkuniversalforwarder
    ...
    volumeMounts:
    - name: logs
    mountPath: /var/log/app/
    volumes:
    - name: logs
    emptyDir: {}





    share|improve this answer















    I don't see an issue here.
    you can mount the same volume at a different location in each container.



    According to your description this should be something like this:



    spec:
    containers:
    - name: app
    image: app-image
    ...
    volumeMounts:
    - name: logs
    mountPath: /usr/var/log/tomcat/
    - name: uf
    image: splunk/splunkuniversalforwarder
    ...
    volumeMounts:
    - name: logs
    mountPath: /var/log/app/
    volumes:
    - name: logs
    emptyDir: {}






    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Nov 22 '18 at 18:51









    Clorichel

    8451517




    8451517










    answered Nov 22 '18 at 12:19









    antweissantweiss

    1,929187




    1,929187













    • Yes that is the issue. but I don't see the logs in /var/log/app/ location if I go inside the uf container.

      – gamechanger17
      Nov 22 '18 at 12:27













    • And you do see them in /usr/var/log/tomcat/ in the tomcat one?

      – antweiss
      Nov 22 '18 at 12:57











    • Now I can see the logs on the shared volume but Splunkuf is not forwarding the logs to the server. I have created a new thread: stackoverflow.com/questions/53669208/…

      – gamechanger17
      Dec 10 '18 at 6:24





















    • Yes that is the issue. but I don't see the logs in /var/log/app/ location if I go inside the uf container.

      – gamechanger17
      Nov 22 '18 at 12:27













    • And you do see them in /usr/var/log/tomcat/ in the tomcat one?

      – antweiss
      Nov 22 '18 at 12:57











    • Now I can see the logs on the shared volume but Splunkuf is not forwarding the logs to the server. I have created a new thread: stackoverflow.com/questions/53669208/…

      – gamechanger17
      Dec 10 '18 at 6:24



















    Yes that is the issue. but I don't see the logs in /var/log/app/ location if I go inside the uf container.

    – gamechanger17
    Nov 22 '18 at 12:27







    Yes that is the issue. but I don't see the logs in /var/log/app/ location if I go inside the uf container.

    – gamechanger17
    Nov 22 '18 at 12:27















    And you do see them in /usr/var/log/tomcat/ in the tomcat one?

    – antweiss
    Nov 22 '18 at 12:57





    And you do see them in /usr/var/log/tomcat/ in the tomcat one?

    – antweiss
    Nov 22 '18 at 12:57













    Now I can see the logs on the shared volume but Splunkuf is not forwarding the logs to the server. I have created a new thread: stackoverflow.com/questions/53669208/…

    – gamechanger17
    Dec 10 '18 at 6:24







    Now I can see the logs on the shared volume but Splunkuf is not forwarding the logs to the server. I have created a new thread: stackoverflow.com/questions/53669208/…

    – gamechanger17
    Dec 10 '18 at 6:24















    0














    If you are using PersistentVolumeClaim or PersistentVolume, I got bad news because the access modes are pretty limited. The one you would want is ReadWriteMany but it has a really limited support ATM. See more info here.



    You could do with this however it has limitations of having to share a node host which not might be a desirable behaviour. I believe that something that would best suit your case would be this.






    share|improve this answer




























      0














      If you are using PersistentVolumeClaim or PersistentVolume, I got bad news because the access modes are pretty limited. The one you would want is ReadWriteMany but it has a really limited support ATM. See more info here.



      You could do with this however it has limitations of having to share a node host which not might be a desirable behaviour. I believe that something that would best suit your case would be this.






      share|improve this answer


























        0












        0








        0







        If you are using PersistentVolumeClaim or PersistentVolume, I got bad news because the access modes are pretty limited. The one you would want is ReadWriteMany but it has a really limited support ATM. See more info here.



        You could do with this however it has limitations of having to share a node host which not might be a desirable behaviour. I believe that something that would best suit your case would be this.






        share|improve this answer













        If you are using PersistentVolumeClaim or PersistentVolume, I got bad news because the access modes are pretty limited. The one you would want is ReadWriteMany but it has a really limited support ATM. See more info here.



        You could do with this however it has limitations of having to share a node host which not might be a desirable behaviour. I believe that something that would best suit your case would be this.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 22 '18 at 10:21









        Urosh T.Urosh T.

        77821420




        77821420






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53426160%2fshared-volume-of-1-container-into-another-container-in-kubernates%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            鏡平學校

            ꓛꓣだゔៀៅຸ໢ທຮ໕໒ ,ໂ'໥໓າ໼ឨឲ៵៭ៈゎゔit''䖳𥁄卿' ☨₤₨こゎもょの;ꜹꟚꞖꞵꟅꞛေၦေɯ,ɨɡ𛃵𛁹ޝ޳ޠ޾,ޤޒޯ޾𫝒𫠁သ𛅤チョ'サノބޘދ𛁐ᶿᶇᶀᶋᶠ㨑㽹⻮ꧬ꧹؍۩وَؠ㇕㇃㇪ ㇦㇋㇋ṜẰᵡᴠ 軌ᵕ搜۳ٰޗޮ޷ސޯ𫖾𫅀ल, ꙭ꙰ꚅꙁꚊꞻꝔ꟠Ꝭㄤﺟޱސꧨꧼ꧴ꧯꧽ꧲ꧯ'⽹⽭⾁⿞⼳⽋២៩ញណើꩯꩤ꩸ꩮᶻᶺᶧᶂ𫳲𫪭𬸄𫵰𬖩𬫣𬊉ၲ𛅬㕦䬺𫝌𫝼,,𫟖𫞽ហៅ஫㆔ాఆఅꙒꚞꙍ,Ꙟ꙱エ ,ポテ,フࢰࢯ𫟠𫞶 𫝤𫟠ﺕﹱﻜﻣ𪵕𪭸𪻆𪾩𫔷ġ,ŧآꞪ꟥,ꞔꝻ♚☹⛵𛀌ꬷꭞȄƁƪƬșƦǙǗdžƝǯǧⱦⱰꓕꓢႋ神 ဴ၀க௭எ௫ឫោ ' េㇷㇴㇼ神ㇸㇲㇽㇴㇼㇻㇸ'ㇸㇿㇸㇹㇰㆣꓚꓤ₡₧ ㄨㄟ㄂ㄖㄎ໗ツڒذ₶।ऩछएोञयूटक़कयँृी,冬'𛅢𛅥ㇱㇵㇶ𥄥𦒽𠣧𠊓𧢖𥞘𩔋цѰㄠſtʯʭɿʆʗʍʩɷɛ,əʏダヵㄐㄘR{gỚṖḺờṠṫảḙḭᴮᵏᴘᵀᵷᵕᴜᴏᵾq﮲ﲿﴽﭙ軌ﰬﶚﶧ﫲Ҝжюїкӈㇴffצּ﬘﭅﬈軌'ffistfflſtffतभफɳɰʊɲʎ𛁱𛁖𛁮𛀉 𛂯𛀞నఋŀŲ 𫟲𫠖𫞺ຆຆ ໹້໕໗ๆทԊꧢꧠ꧰ꓱ⿝⼑ŎḬẃẖỐẅ ,ờỰỈỗﮊDžȩꭏꭎꬻ꭮ꬿꭖꭥꭅ㇭神 ⾈ꓵꓑ⺄㄄ㄪㄙㄅㄇstA۵䞽ॶ𫞑𫝄㇉㇇゜軌𩜛𩳠Jﻺ‚Üမ႕ႌႊၐၸဓၞၞၡ៸wyvtᶎᶪᶹစဎ꣡꣰꣢꣤ٗ؋لㇳㇾㇻㇱ㆐㆔,,㆟Ⱶヤマފ޼ޝަݿݞݠݷݐ',ݘ,ݪݙݵ𬝉𬜁𫝨𫞘くせぉて¼óû×ó£…𛅑הㄙくԗԀ5606神45,神796'𪤻𫞧ꓐ㄁ㄘɥɺꓵꓲ3''7034׉ⱦⱠˆ“𫝋ȍ,ꩲ軌꩷ꩶꩧꩫఞ۔فڱێظペサ神ナᴦᵑ47 9238їﻂ䐊䔉㠸﬎ffiﬣ,לּᴷᴦᵛᵽ,ᴨᵤ ᵸᵥᴗᵈꚏꚉꚟ⻆rtǟƴ𬎎

            Why https connections are so slow when debugging (stepping over) in Java?