Kubernetes - can a Deployment contain a Service?









up vote
0
down vote

favorite












Just finished reading Nigel Poulton's The Kubernetes Book, but I am somewhat puzzled with Services.



Could a Service be added to the Deployment manifest below somehow?Or does the Service have to be POSTed on its own? Isn't the whole purpose of a deployment to specify everything needed for the app to run?



apiVersion: apps/v1beta2
kind: Deployment
metadata:
name: hello-deploy
spec:
replicas: 10
selector:
matchLabels:
app: hello-world
minReadySeconds: 10
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 1
maxSurge: 1
template:
metadata:
labels:
app: hello-world
spec:
containers:
- name: hello-pod
image: nigelpoulton/k8sbook : latest
ports:
- containerPort: 8080









share|improve this question

























    up vote
    0
    down vote

    favorite












    Just finished reading Nigel Poulton's The Kubernetes Book, but I am somewhat puzzled with Services.



    Could a Service be added to the Deployment manifest below somehow?Or does the Service have to be POSTed on its own? Isn't the whole purpose of a deployment to specify everything needed for the app to run?



    apiVersion: apps/v1beta2
    kind: Deployment
    metadata:
    name: hello-deploy
    spec:
    replicas: 10
    selector:
    matchLabels:
    app: hello-world
    minReadySeconds: 10
    strategy:
    type: RollingUpdate
    rollingUpdate:
    maxUnavailable: 1
    maxSurge: 1
    template:
    metadata:
    labels:
    app: hello-world
    spec:
    containers:
    - name: hello-pod
    image: nigelpoulton/k8sbook : latest
    ports:
    - containerPort: 8080









    share|improve this question























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      Just finished reading Nigel Poulton's The Kubernetes Book, but I am somewhat puzzled with Services.



      Could a Service be added to the Deployment manifest below somehow?Or does the Service have to be POSTed on its own? Isn't the whole purpose of a deployment to specify everything needed for the app to run?



      apiVersion: apps/v1beta2
      kind: Deployment
      metadata:
      name: hello-deploy
      spec:
      replicas: 10
      selector:
      matchLabels:
      app: hello-world
      minReadySeconds: 10
      strategy:
      type: RollingUpdate
      rollingUpdate:
      maxUnavailable: 1
      maxSurge: 1
      template:
      metadata:
      labels:
      app: hello-world
      spec:
      containers:
      - name: hello-pod
      image: nigelpoulton/k8sbook : latest
      ports:
      - containerPort: 8080









      share|improve this question













      Just finished reading Nigel Poulton's The Kubernetes Book, but I am somewhat puzzled with Services.



      Could a Service be added to the Deployment manifest below somehow?Or does the Service have to be POSTed on its own? Isn't the whole purpose of a deployment to specify everything needed for the app to run?



      apiVersion: apps/v1beta2
      kind: Deployment
      metadata:
      name: hello-deploy
      spec:
      replicas: 10
      selector:
      matchLabels:
      app: hello-world
      minReadySeconds: 10
      strategy:
      type: RollingUpdate
      rollingUpdate:
      maxUnavailable: 1
      maxSurge: 1
      template:
      metadata:
      labels:
      app: hello-world
      spec:
      containers:
      - name: hello-pod
      image: nigelpoulton/k8sbook : latest
      ports:
      - containerPort: 8080






      kubernetes microservices






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 10 at 22:28









      HashRocketSyntax

      473726




      473726






















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          5
          down vote



          accepted










          They're different objects and you have to submit them separately (HTTP POST, kubectl apply, ...).



          There are a couple of tricks you can do to minimize the impact of this:




          • You can use a multi-document YAML file and submit that as a single thing, like



            ---
            apiVersion: apps/v1
            kind: Deployment
            ...
            ---
            apiVersion: v1
            kind: Service
            ...



          • There is an undocumented kind: List that could embed multiple objects



            apiVersion: v1
            kind: List
            items:
            - apiVersion: apps/v1
            kind: Deployment
            ...
            - apiVersion: v1
            kind: Service
            ...


          • You can use a higher-level deployment manager such as Helm that lets you keep each object in a separate file, but deploy them in a single command.


          It's perhaps unfortunate that a couple of Kubernetes objects have names that are different from their plain English meanings (a Deployment doesn't cover all of the steps or parts of deploying a whole application; a Service is just an IP/DNS pointer and not a service implementation) but that's the way it is. I tend to capitalize the Kubernetes object names when it will disambiguate things.






          share|improve this answer



























            up vote
            0
            down vote














            Isn't the whole purpose of a deployment to specify everything needed for the app to run?




            The whole purpose of "Deployment" is to manage the deployment of pods/replicasets including replication, scaling, rolling update, rollbacks. The DeploymentController is part of the master node's controller manager, and it makes sure that the current state always matches the desired state.




            does the Service have to be POSTed on its own?




            If you are familiar with Load balancers terminology, Services are frontends and Pods are its backends. Since it is frontend, Service forwards requests to its backend (pods).






            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',
              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%2f53244055%2fkubernetes-can-a-deployment-contain-a-service%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








              up vote
              5
              down vote



              accepted










              They're different objects and you have to submit them separately (HTTP POST, kubectl apply, ...).



              There are a couple of tricks you can do to minimize the impact of this:




              • You can use a multi-document YAML file and submit that as a single thing, like



                ---
                apiVersion: apps/v1
                kind: Deployment
                ...
                ---
                apiVersion: v1
                kind: Service
                ...



              • There is an undocumented kind: List that could embed multiple objects



                apiVersion: v1
                kind: List
                items:
                - apiVersion: apps/v1
                kind: Deployment
                ...
                - apiVersion: v1
                kind: Service
                ...


              • You can use a higher-level deployment manager such as Helm that lets you keep each object in a separate file, but deploy them in a single command.


              It's perhaps unfortunate that a couple of Kubernetes objects have names that are different from their plain English meanings (a Deployment doesn't cover all of the steps or parts of deploying a whole application; a Service is just an IP/DNS pointer and not a service implementation) but that's the way it is. I tend to capitalize the Kubernetes object names when it will disambiguate things.






              share|improve this answer
























                up vote
                5
                down vote



                accepted










                They're different objects and you have to submit them separately (HTTP POST, kubectl apply, ...).



                There are a couple of tricks you can do to minimize the impact of this:




                • You can use a multi-document YAML file and submit that as a single thing, like



                  ---
                  apiVersion: apps/v1
                  kind: Deployment
                  ...
                  ---
                  apiVersion: v1
                  kind: Service
                  ...



                • There is an undocumented kind: List that could embed multiple objects



                  apiVersion: v1
                  kind: List
                  items:
                  - apiVersion: apps/v1
                  kind: Deployment
                  ...
                  - apiVersion: v1
                  kind: Service
                  ...


                • You can use a higher-level deployment manager such as Helm that lets you keep each object in a separate file, but deploy them in a single command.


                It's perhaps unfortunate that a couple of Kubernetes objects have names that are different from their plain English meanings (a Deployment doesn't cover all of the steps or parts of deploying a whole application; a Service is just an IP/DNS pointer and not a service implementation) but that's the way it is. I tend to capitalize the Kubernetes object names when it will disambiguate things.






                share|improve this answer






















                  up vote
                  5
                  down vote



                  accepted







                  up vote
                  5
                  down vote



                  accepted






                  They're different objects and you have to submit them separately (HTTP POST, kubectl apply, ...).



                  There are a couple of tricks you can do to minimize the impact of this:




                  • You can use a multi-document YAML file and submit that as a single thing, like



                    ---
                    apiVersion: apps/v1
                    kind: Deployment
                    ...
                    ---
                    apiVersion: v1
                    kind: Service
                    ...



                  • There is an undocumented kind: List that could embed multiple objects



                    apiVersion: v1
                    kind: List
                    items:
                    - apiVersion: apps/v1
                    kind: Deployment
                    ...
                    - apiVersion: v1
                    kind: Service
                    ...


                  • You can use a higher-level deployment manager such as Helm that lets you keep each object in a separate file, but deploy them in a single command.


                  It's perhaps unfortunate that a couple of Kubernetes objects have names that are different from their plain English meanings (a Deployment doesn't cover all of the steps or parts of deploying a whole application; a Service is just an IP/DNS pointer and not a service implementation) but that's the way it is. I tend to capitalize the Kubernetes object names when it will disambiguate things.






                  share|improve this answer












                  They're different objects and you have to submit them separately (HTTP POST, kubectl apply, ...).



                  There are a couple of tricks you can do to minimize the impact of this:




                  • You can use a multi-document YAML file and submit that as a single thing, like



                    ---
                    apiVersion: apps/v1
                    kind: Deployment
                    ...
                    ---
                    apiVersion: v1
                    kind: Service
                    ...



                  • There is an undocumented kind: List that could embed multiple objects



                    apiVersion: v1
                    kind: List
                    items:
                    - apiVersion: apps/v1
                    kind: Deployment
                    ...
                    - apiVersion: v1
                    kind: Service
                    ...


                  • You can use a higher-level deployment manager such as Helm that lets you keep each object in a separate file, but deploy them in a single command.


                  It's perhaps unfortunate that a couple of Kubernetes objects have names that are different from their plain English meanings (a Deployment doesn't cover all of the steps or parts of deploying a whole application; a Service is just an IP/DNS pointer and not a service implementation) but that's the way it is. I tend to capitalize the Kubernetes object names when it will disambiguate things.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 10 at 22:55









                  David Maze

                  7,9732821




                  7,9732821






















                      up vote
                      0
                      down vote














                      Isn't the whole purpose of a deployment to specify everything needed for the app to run?




                      The whole purpose of "Deployment" is to manage the deployment of pods/replicasets including replication, scaling, rolling update, rollbacks. The DeploymentController is part of the master node's controller manager, and it makes sure that the current state always matches the desired state.




                      does the Service have to be POSTed on its own?




                      If you are familiar with Load balancers terminology, Services are frontends and Pods are its backends. Since it is frontend, Service forwards requests to its backend (pods).






                      share|improve this answer
























                        up vote
                        0
                        down vote














                        Isn't the whole purpose of a deployment to specify everything needed for the app to run?




                        The whole purpose of "Deployment" is to manage the deployment of pods/replicasets including replication, scaling, rolling update, rollbacks. The DeploymentController is part of the master node's controller manager, and it makes sure that the current state always matches the desired state.




                        does the Service have to be POSTed on its own?




                        If you are familiar with Load balancers terminology, Services are frontends and Pods are its backends. Since it is frontend, Service forwards requests to its backend (pods).






                        share|improve this answer






















                          up vote
                          0
                          down vote










                          up vote
                          0
                          down vote










                          Isn't the whole purpose of a deployment to specify everything needed for the app to run?




                          The whole purpose of "Deployment" is to manage the deployment of pods/replicasets including replication, scaling, rolling update, rollbacks. The DeploymentController is part of the master node's controller manager, and it makes sure that the current state always matches the desired state.




                          does the Service have to be POSTed on its own?




                          If you are familiar with Load balancers terminology, Services are frontends and Pods are its backends. Since it is frontend, Service forwards requests to its backend (pods).






                          share|improve this answer













                          Isn't the whole purpose of a deployment to specify everything needed for the app to run?




                          The whole purpose of "Deployment" is to manage the deployment of pods/replicasets including replication, scaling, rolling update, rollbacks. The DeploymentController is part of the master node's controller manager, and it makes sure that the current state always matches the desired state.




                          does the Service have to be POSTed on its own?




                          If you are familiar with Load balancers terminology, Services are frontends and Pods are its backends. Since it is frontend, Service forwards requests to its backend (pods).







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Nov 11 at 2:52









                          Abdennour TOUMI

                          31.8k15137152




                          31.8k15137152



























                               

                              draft saved


                              draft discarded















































                               


                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53244055%2fkubernetes-can-a-deployment-contain-a-service%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

                              Top Tejano songwriter Luis Silva dead of heart attack at 64

                              ReactJS Fetched API data displays live - need Data displayed static

                              Evgeni Malkin