Multiple pods using same database on kubernetes












1















I would like to know if it is possible for multiple pods in the same Kubernetes cluster to access a database which is configured using persistent volumes on a Google cloud persistent disk.



Currently I am building a microservices achitecture web app which has 3 node apis in different pods all accessing the same database. So how do I achieve this with kubernetes.



Kindly let me know if my architecture is right as well










share|improve this question























  • This architecture is reasonable: as long as the database can handle the expected number of incoming connections, and the credentials are configured correctly in the pods, there should be no issue accessing the database with all APIs. Are there any specific concerns that you'd had about your design decisions here?

    – Monkeyanator
    Dec 30 '18 at 17:27






  • 1





    Are you talking about a networked database like Postgres or MySQL, or some kind of local file database like Sqlite or BDB?

    – coderanger
    Dec 30 '18 at 20:24











  • I am using a mongo db @coderanger. I also want to access the database outside the cluster as well. So I want it to be highly available

    – suprith
    Jan 1 at 20:04













  • MongoDB (the company) offers an operator (a custom Kubernetes controller), probably start with that.

    – coderanger
    Jan 1 at 21:10
















1















I would like to know if it is possible for multiple pods in the same Kubernetes cluster to access a database which is configured using persistent volumes on a Google cloud persistent disk.



Currently I am building a microservices achitecture web app which has 3 node apis in different pods all accessing the same database. So how do I achieve this with kubernetes.



Kindly let me know if my architecture is right as well










share|improve this question























  • This architecture is reasonable: as long as the database can handle the expected number of incoming connections, and the credentials are configured correctly in the pods, there should be no issue accessing the database with all APIs. Are there any specific concerns that you'd had about your design decisions here?

    – Monkeyanator
    Dec 30 '18 at 17:27






  • 1





    Are you talking about a networked database like Postgres or MySQL, or some kind of local file database like Sqlite or BDB?

    – coderanger
    Dec 30 '18 at 20:24











  • I am using a mongo db @coderanger. I also want to access the database outside the cluster as well. So I want it to be highly available

    – suprith
    Jan 1 at 20:04













  • MongoDB (the company) offers an operator (a custom Kubernetes controller), probably start with that.

    – coderanger
    Jan 1 at 21:10














1












1








1








I would like to know if it is possible for multiple pods in the same Kubernetes cluster to access a database which is configured using persistent volumes on a Google cloud persistent disk.



Currently I am building a microservices achitecture web app which has 3 node apis in different pods all accessing the same database. So how do I achieve this with kubernetes.



Kindly let me know if my architecture is right as well










share|improve this question














I would like to know if it is possible for multiple pods in the same Kubernetes cluster to access a database which is configured using persistent volumes on a Google cloud persistent disk.



Currently I am building a microservices achitecture web app which has 3 node apis in different pods all accessing the same database. So how do I achieve this with kubernetes.



Kindly let me know if my architecture is right as well







kubernetes google-kubernetes-engine persistent-volumes persistent-volume-claims google-persistent-disk






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Dec 30 '18 at 14:56









suprithsuprith

83




83













  • This architecture is reasonable: as long as the database can handle the expected number of incoming connections, and the credentials are configured correctly in the pods, there should be no issue accessing the database with all APIs. Are there any specific concerns that you'd had about your design decisions here?

    – Monkeyanator
    Dec 30 '18 at 17:27






  • 1





    Are you talking about a networked database like Postgres or MySQL, or some kind of local file database like Sqlite or BDB?

    – coderanger
    Dec 30 '18 at 20:24











  • I am using a mongo db @coderanger. I also want to access the database outside the cluster as well. So I want it to be highly available

    – suprith
    Jan 1 at 20:04













  • MongoDB (the company) offers an operator (a custom Kubernetes controller), probably start with that.

    – coderanger
    Jan 1 at 21:10



















  • This architecture is reasonable: as long as the database can handle the expected number of incoming connections, and the credentials are configured correctly in the pods, there should be no issue accessing the database with all APIs. Are there any specific concerns that you'd had about your design decisions here?

    – Monkeyanator
    Dec 30 '18 at 17:27






  • 1





    Are you talking about a networked database like Postgres or MySQL, or some kind of local file database like Sqlite or BDB?

    – coderanger
    Dec 30 '18 at 20:24











  • I am using a mongo db @coderanger. I also want to access the database outside the cluster as well. So I want it to be highly available

    – suprith
    Jan 1 at 20:04













  • MongoDB (the company) offers an operator (a custom Kubernetes controller), probably start with that.

    – coderanger
    Jan 1 at 21:10

















This architecture is reasonable: as long as the database can handle the expected number of incoming connections, and the credentials are configured correctly in the pods, there should be no issue accessing the database with all APIs. Are there any specific concerns that you'd had about your design decisions here?

– Monkeyanator
Dec 30 '18 at 17:27





This architecture is reasonable: as long as the database can handle the expected number of incoming connections, and the credentials are configured correctly in the pods, there should be no issue accessing the database with all APIs. Are there any specific concerns that you'd had about your design decisions here?

– Monkeyanator
Dec 30 '18 at 17:27




1




1





Are you talking about a networked database like Postgres or MySQL, or some kind of local file database like Sqlite or BDB?

– coderanger
Dec 30 '18 at 20:24





Are you talking about a networked database like Postgres or MySQL, or some kind of local file database like Sqlite or BDB?

– coderanger
Dec 30 '18 at 20:24













I am using a mongo db @coderanger. I also want to access the database outside the cluster as well. So I want it to be highly available

– suprith
Jan 1 at 20:04







I am using a mongo db @coderanger. I also want to access the database outside the cluster as well. So I want it to be highly available

– suprith
Jan 1 at 20:04















MongoDB (the company) offers an operator (a custom Kubernetes controller), probably start with that.

– coderanger
Jan 1 at 21:10





MongoDB (the company) offers an operator (a custom Kubernetes controller), probably start with that.

– coderanger
Jan 1 at 21:10












1 Answer
1






active

oldest

votes


















1














You can certainly connect multiple node-based app pods to the same database. It is sometimes said that microservices shouldn't share a database but this depends on what your apps are doing, the project history and the extent to which you want the parts to be worked on separately.



There are questions you have to answer about running databases at scale, such as your future load and whether you want to use relational databases if you're going to try to span availability zones. And there are
some specific to kubernetes, especially around how you associate DB Pods to data. See https://stackoverflow.com/a/53980021/9705485. Another popular option is to use a managed DB service from a cloud provider. If you do run the DB in k8s then I'd suggest looking for a helm chart or looking at an operator, such as the kubeDB operator, to avoid crafting the kubernetes descriptors yourself and to get more guidance on running the DB and setting it up.



If it's a new project and you've not used k8s before then you'll also have to decide where to host your code, your docker images and your deployment descriptors and how to setup your CI pipelines. If you've not got answers to these questions already then I'd suggest looking at Jenkins-X as it will provide you with out of the box defaults for a whole cluster and CI setup and a template ('build pack') for building node apps and deploying them to staging and prod environments through a pipeline.






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%2f53978641%2fmultiple-pods-using-same-database-on-kubernetes%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    You can certainly connect multiple node-based app pods to the same database. It is sometimes said that microservices shouldn't share a database but this depends on what your apps are doing, the project history and the extent to which you want the parts to be worked on separately.



    There are questions you have to answer about running databases at scale, such as your future load and whether you want to use relational databases if you're going to try to span availability zones. And there are
    some specific to kubernetes, especially around how you associate DB Pods to data. See https://stackoverflow.com/a/53980021/9705485. Another popular option is to use a managed DB service from a cloud provider. If you do run the DB in k8s then I'd suggest looking for a helm chart or looking at an operator, such as the kubeDB operator, to avoid crafting the kubernetes descriptors yourself and to get more guidance on running the DB and setting it up.



    If it's a new project and you've not used k8s before then you'll also have to decide where to host your code, your docker images and your deployment descriptors and how to setup your CI pipelines. If you've not got answers to these questions already then I'd suggest looking at Jenkins-X as it will provide you with out of the box defaults for a whole cluster and CI setup and a template ('build pack') for building node apps and deploying them to staging and prod environments through a pipeline.






    share|improve this answer






























      1














      You can certainly connect multiple node-based app pods to the same database. It is sometimes said that microservices shouldn't share a database but this depends on what your apps are doing, the project history and the extent to which you want the parts to be worked on separately.



      There are questions you have to answer about running databases at scale, such as your future load and whether you want to use relational databases if you're going to try to span availability zones. And there are
      some specific to kubernetes, especially around how you associate DB Pods to data. See https://stackoverflow.com/a/53980021/9705485. Another popular option is to use a managed DB service from a cloud provider. If you do run the DB in k8s then I'd suggest looking for a helm chart or looking at an operator, such as the kubeDB operator, to avoid crafting the kubernetes descriptors yourself and to get more guidance on running the DB and setting it up.



      If it's a new project and you've not used k8s before then you'll also have to decide where to host your code, your docker images and your deployment descriptors and how to setup your CI pipelines. If you've not got answers to these questions already then I'd suggest looking at Jenkins-X as it will provide you with out of the box defaults for a whole cluster and CI setup and a template ('build pack') for building node apps and deploying them to staging and prod environments through a pipeline.






      share|improve this answer




























        1












        1








        1







        You can certainly connect multiple node-based app pods to the same database. It is sometimes said that microservices shouldn't share a database but this depends on what your apps are doing, the project history and the extent to which you want the parts to be worked on separately.



        There are questions you have to answer about running databases at scale, such as your future load and whether you want to use relational databases if you're going to try to span availability zones. And there are
        some specific to kubernetes, especially around how you associate DB Pods to data. See https://stackoverflow.com/a/53980021/9705485. Another popular option is to use a managed DB service from a cloud provider. If you do run the DB in k8s then I'd suggest looking for a helm chart or looking at an operator, such as the kubeDB operator, to avoid crafting the kubernetes descriptors yourself and to get more guidance on running the DB and setting it up.



        If it's a new project and you've not used k8s before then you'll also have to decide where to host your code, your docker images and your deployment descriptors and how to setup your CI pipelines. If you've not got answers to these questions already then I'd suggest looking at Jenkins-X as it will provide you with out of the box defaults for a whole cluster and CI setup and a template ('build pack') for building node apps and deploying them to staging and prod environments through a pipeline.






        share|improve this answer















        You can certainly connect multiple node-based app pods to the same database. It is sometimes said that microservices shouldn't share a database but this depends on what your apps are doing, the project history and the extent to which you want the parts to be worked on separately.



        There are questions you have to answer about running databases at scale, such as your future load and whether you want to use relational databases if you're going to try to span availability zones. And there are
        some specific to kubernetes, especially around how you associate DB Pods to data. See https://stackoverflow.com/a/53980021/9705485. Another popular option is to use a managed DB service from a cloud provider. If you do run the DB in k8s then I'd suggest looking for a helm chart or looking at an operator, such as the kubeDB operator, to avoid crafting the kubernetes descriptors yourself and to get more guidance on running the DB and setting it up.



        If it's a new project and you've not used k8s before then you'll also have to decide where to host your code, your docker images and your deployment descriptors and how to setup your CI pipelines. If you've not got answers to these questions already then I'd suggest looking at Jenkins-X as it will provide you with out of the box defaults for a whole cluster and CI setup and a template ('build pack') for building node apps and deploying them to staging and prod environments through a pipeline.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Jan 1 at 9:13

























        answered Dec 31 '18 at 9:06









        Ryan DawsonRyan Dawson

        4,5073425




        4,5073425






























            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%2f53978641%2fmultiple-pods-using-same-database-on-kubernetes%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

            Monofisismo

            Angular Downloading a file using contenturl with Basic Authentication

            Olmecas