github.com/voedger/voedger@v0.0.0-20240520144910-273e84102129/design/orchestration/10-review-existing-3-k8s.md (about)

     1  ### Kubernetes.Pod
     2  
     3  - https://cloud.google.com/kubernetes-engine/docs/concepts/pod
     4  - https://kubernetes.io/docs/concepts/workloads/pods/
     5  
     6  ```mermaid
     7  erDiagram
     8    Pod ||..|{ Container : "contains"
     9    Pod ||..|{ Resource : "describes"
    10    Container ||..|{ Resource : "shares"
    11    Pod ||..|| SmallestDeployableUnit : "is"
    12    Pod ||..|| Deployment: "'s deployment described by"
    13    Resource ||..|{ Storage : "can be"
    14    Resource ||..|{ Network : "can be"
    15    Resource ||..|{ CPU : "can be"
    16    Resource ||..|{ Memory : "can be"
    17  ```
    18  
    19  ### Kubernetes.Deployment
    20  
    21  ```mermaid
    22  erDiagram
    23    Deployment ||..|{ DeploymentSpec : "has spec"
    24    Deployment ||..|{ ObjectMeta : "has metadata"
    25    Deployment ||..|{ DeploymentStatus : "has status"
    26    DeploymentSpec ||..|| PodTemplateSpec : "has template"
    27    PodTemplateSpec ||..|| PodSpec : "has spec"
    28    PodSpec ||..|{ ContainerSpec : "has containers []"
    29  ```
    30  
    31  >A Deployment provides declarative updates for Pods and ReplicaSets.
    32  > You describe a desired state in a Deployment, and the Deployment Controller changes the actual state to the desired state at a controlled rate. You can define Deployments to create new ReplicaSets, or to remove existing Deployments and adopt all their resources with new Deployments.
    33  
    34  
    35  [Creating a multiple pod Deployment](https://www.reddit.com/r/kubernetes/comments/ci4297/creating_a_multiple_pod_deployment/)
    36  - I want to have a single deployment file that needs to run my containers in different pods. Right now, the deployment is creating a single pod with two containers inside. Is there a way i could deploy two pods, with different containers from the same deployment file?
    37  - Deployment only support a single pod, a pod can have multiple containers
    38    - But you can put multiple deployments in a single file, use --- to separate multiple documents
    39  
    40  
    41  
    42  
    43  #### Deployment
    44  
    45  - [OpenAPI.Deployment](https://elements-demo.stoplight.io/?spec=https://raw.githubusercontent.com/kubernetes/kubernetes/master/api/openapi-spec/swagger.json#/schemas/io.k8s.api.apps.v1.Deployment)
    46  - [Kubernetes Deployment spec example](https://www.tutorialworks.com/kubernetes-deployment-spec-examples/):
    47  ```yaml
    48  apiVersion: apps/v1
    49  kind: Deployment
    50  metadata:
    51    name: nginx-rolling
    52    labels:
    53      app: nginx-rolling
    54  spec:
    55    replicas: 1
    56    selector:
    57      matchLabels:
    58        app: nginx-rolling
    59    strategy:
    60      type: RollingUpdate   # Upgrade this application with a rolling strategy
    61      rollingUpdate:
    62        maxSurge: 1         # maximum number of pods that can be scheduled
    63                            # above the desired number of pods (replicas)
    64        maxUnavailable: 0   # the maximum number of pods that can be unavailable
    65                            # during the update
    66    template:
    67      metadata:
    68        labels:
    69          app: nginx-rolling
    70      spec:
    71        containers:
    72        - image: nginx
    73          name: nginx
    74          ports:
    75          - containerPort: 8080
    76  ```       
    77  
    78  
    79  #### ObjectMeta
    80  
    81  ObjectMeta is metadata that all persisted resources must have, which includes all objects users must create.
    82  
    83  ```mermaid
    84  erDiagram
    85  metadata{
    86    generation int64  "A sequence number representing a specific generation of the desired state."
    87    deletionGracePeriodSeconds int64
    88    labels map_string_string
    89    name string "Name must be unique within a namespace"
    90    ownerReferences arr-of-object "List of objects depended by this object"
    91    resourceVersion string
    92    uid string "UID is the unique in time and space value for this object"
    93  }
    94  ```
    95  - ownerReferences. List of objects depended by this object. If ALL objects in the list have been deleted, this object will be garbage collected. If this object is managed by a controller, then an entry in this list will point to this controller, with the controller field set to true. There cannot be more than one managing controller.
    96  - resourceVersion. An opaque value that represents the internal version of this object that can be used by clients to determine when objects have changed.
    97  
    98  #### DeploymentSpec
    99  ```mermaid
   100  erDiagram
   101  DeploymentSpec {
   102    strategy object "how to replace existing pods with new ones"
   103    selector object "A label selector is a label query over a set of resources. "
   104    replicas int32 "Number of desired pods"  
   105    template PodTemplateSpec "describes the data a pod should have when created from a template"
   106  }
   107  ```
   108  #### PodTemplateSpec
   109  
   110  ```mermaid
   111  erDiagram
   112  PodTemplateSpec  {
   113    metadata  ObjectMeta 
   114    spec      PodSpec "PodSpec is a description of a pod"
   115  }  
   116  ```  
   117  
   118  #### PodSpec
   119  ```mermaid
   120  erDiagram
   121  PodTemplateSpec  {
   122    metadata  object
   123    affinity  Affinity
   124    containers arr_of_Container
   125    hostname string
   126    initContainers arr_of_Container
   127    nodeName string "request to schedule this pod onto a specific node"
   128  }  
   129  ```  
   130  
   131  - [Resource Management for Pods and Containers](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/)
   132  
   133  ```yaml
   134  apiVersion: v1
   135  kind: Pod
   136  metadata:
   137    name: frontend
   138  spec:
   139    containers:
   140    - name: app
   141      image: images.my-company.example/app:v4
   142      resources:
   143        requests:
   144          memory: "64Mi"
   145          cpu: "250m"
   146        limits:
   147          memory: "128Mi"
   148          cpu: "500m"
   149    - name: log-aggregator
   150      image: images.my-company.example/log-aggregator:v6
   151      resources:
   152        requests:
   153          memory: "64Mi"
   154          cpu: "250m"
   155        limits:
   156          memory: "128Mi"
   157          cpu: "500m"
   158  ```        
   159  #### Deployment.status (DeploymentStatus)
   160  
   161  ```mermaid
   162  erDiagram
   163  status{
   164    availableReplicas   int32 "The number of available replicas (ready for at least minReadySeconds) for this deployment."
   165    observedGeneration  int64 "The generation observed by the deployment controller"
   166    readyReplicas       int32 "The number of ready replicas (ready for at least minReadySeconds) for this deployment"
   167    replicas            int32 "Total number of non-terminated pods targeted by this deployment (their labels match the selector)"
   168    updatedReplicas     int32 "The number of replicas that have a desired version matching the deployment's version"
   169  }
   170  ```
   171