K8S pod learning

1, when to use multiple containers in the pod?
    The primary reason for adding a plurality of containers are applied to a single pod may have a primary process and the composition of one or more secondary processes.

2, N or two containers placed in a pod or a separate pod, we need to consider the following questions. 
    They need to run together or can be run on a different host?
    They represent a whole or independent components?
    They must be expanded together or can be separately?
3, the principle:
    although multiple containers can be placed in a pod, but we have to keep it simple, it is recommended that a container is placed in a pod.

4, create a simple description file yaml POD 
    
    apiVersion: v1 # description file followed v1 version of the API Kubernetes
    kind: We describe a # POD POD
    the Metadata:
        name: kubia-manua1 #pod name
    spec:
        Containers:
        - Image: luksa / kubia # create a container used for image
          name: kubia # container name
          the ports:
          - containerPort: 8080 # listening port
            protocol: TCP

5, create a pod: Use kubectl create command to create a pod from yaml file.
    Kubectl create -f kubia-random file name manual1.yaml #

    #kubectl create -f command to create any resources from yaml or json file (not just the pod)

    After the pod is created we can view the complete profile of the pod by the following command.

    kubectl get po kubia-manua1 (pod name) -o yaml # return yaml format
    kubectl get po kubia-manua1 -o json # return json format 
6, see the creation of pod
    kubectl GET # PODS can view the operating status of the pod.

    kubectl logs kubia-manua1 # log acquisition pod (container log)
    kubectl logs kubia-manua1 -C kubia # log acquisition pod plurality of containers in a container. 
7, will be forwarded to the local network port pod in 
    kubectl port-forward kubia-manual 8888 : 8080 # 8888 local port mapped to the pod in 8080

  ------- To be continued

Guess you like

Origin blog.csdn.net/qq_42409788/article/details/93755352