What is the difference between a pod and a deployment?

后端 未结 8 511
一向
一向 2020-11-30 16:56

I have been creating pods with type:deployment but I see that some documentation uses type:pod, more specifically the documentation for multi-conta

相关标签:
8条回答
  • 2020-11-30 17:15

    Kubernetes has three Object Types you should know about:

    • Pods - runs one or more closely related containers
    • Services - sets up networking in a Kubernetes cluster
    • Deployment - Maintains a set of identical pods, ensuring that they have the correct config and that the right number of them exist.

    Pods:

    • Runs a single set of containers
    • Good for one-off dev purposes
    • Rarely used directly in production

    Deployment:

    • Runs a set of identical pods
    • Monitors the state of each pod, updating as necessary
    • Good for dev
    • Good for production

    And I would agree with other answers, forget about Pods and just use Deployment. Why? Look at the second bullet point, it monitors the state of each pod, updating as necessary.

    So, instead of struggling with error messages such as this one:

    Forbidden: pod updates may not change fields other than spec.containers[*].image

    So just refactor or completely recreate your Pod into a Deployment that creates a pod to do what you need done. With Deployment you can change any piece of configuration you want to and you need not worry about seeing that error message.

    0 讨论(0)
  • 2020-11-30 17:23

    Pod is container instance.

    That is the output of replicas: 3

    Think of one deployment can have many running instances(replica).

    //deployment.yaml
    apiVersion: apps/v1beta2
    kind: Deployment
    metadata:
      name: tomcat-deployment222
    spec:
      selector:
        matchLabels:
          app: tomcat
      replicas: 3
      template:
        metadata:
          labels:
            app: tomcat
        spec:
          containers:
          - name: tomcat
            image: tomcat:9.0
            ports:
            - containerPort: 8080
    
    0 讨论(0)
提交回复
热议问题