skip to Main Content

I am setting up kubernetes for an application with 8 microservices,activemq,postgres,redis and mongodb.

After the entire configuration of pods and deployment ,is there any way to create a single master deployment yaml file which will create the entire set of services,replcas etc for the entire application.

Note:I will be using multiple deployment yaml files,statefulsets etc for all above mentioned services.

2

Answers


  1. You can use this script:

    NAMESPACE="your_namespace"
    RESOURCES="configmap secret daemonset deployment service hpa"
    
    for resource in ${RESOURCES};do
      rsrcs=$(kubectl -n ${NAMESPACE} get -o json ${resource}|jq '.items[].metadata.name'|sed "s/"//g")
      for r in ${rsrcs};do
        dir="${NAMESPACE}/${resource}"
        mkdir -p "${dir}"
        kubectl -n ${NAMESPACE} get -o yaml ${resource} ${r} > "${dir}/${r}.yaml"
      done
    done
    

    Remember to specify what resources you want exported in the script.

    More info here

    Login or Signup to reply.
  2. Is there any way to create a single master deployment yaml file which will create the entire set of services,replicas etc for the entire application.

    Since you already mentioned kubernetes-helm why don’t you actually used it for that exact purpose? In short helm is sort of package manager for Kubernetes, some say similar to yum or apt. It deploys charts which you can actually refer to as packed application. Its pack of all your pre-configured applications which can be deploy as one unit. It’s not entirely one file but more collection of files that build so called helm chart.

    What are the helm charts?

    Well they are basically K8s yaml manifest combined into a single package that can be installed to your cluster. And installing the package is just as simple as running single command such as helm install. Once done the charts are highly reusable which reduces the time for creating dev, test and prod environments.

    As an example of a complex helm chart deploying multiple resources you many want to check Stackstorm.
    Basically once deployed without any custom config this chart will deploy 2 replicas for each component of StackStorm as well as backends like RabbitMQ, MongoDB and Redis.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search