Linux operation and maintenance engineer interview questions (9)

Linux operation and maintenance engineer interview questions (9)

I wish you all the best of luck in finding the job you want.
Continuous learning will not be eliminated.
The earth doesn't explode, we don't take holidays.
Opportunities are always reserved for those who are prepared.
Come on, hit the workers!

1 pod life cycle

The first stage:

  • Pending: The Pod is being created but not all containers in the Pod have been created. A Pod in this state should check whether the storage that the Pod depends on has permission to mount, whether the image can be downloaded, and whether the scheduling is normal.
  • Failed: A container in the Pod failed to start, causing the Pod to work abnormally.
  • Unknown: The current state of the pod cannot be obtained for some reason, usually due to a communication error with the node where the pod resides.
  • Succeeded: All containers in the Pod have been successfully terminated, that is, all containers in the pod have been terminated.

second stage:

  • Unschedulable: Pod cannot be scheduled, kube-scheduler does not match a suitable node node
    • Insufficient CPU resources, insufficient memory resources
    • Hit the labels tag
  • PodScheduled: The pod is being scheduled. When the kube-scheduler first starts scheduling, the pod has not been assigned to the specified node. After filtering out a suitable node, the etcd data will be updated and the pod will be assigned to the specified node.
  • Initialized: The initialization containers in all pods have been completed
  • ImagePullBackOff: The node where the Pod resides failed to download the image
    • The node node cannot download the image
    • Internet problem
    • Permissions issue
    • The image address or name is wrong
  • Running: The container inside the Pod has been created and started
  • Ready: Indicates that the containers in the pod can already provide access services

2 Probe Types

  • livenessProbe : a liveness probe, which detects whether the container is running. If the liveness probe fails, the kubelet will kill the container, and the container will be affected by its restart strategy. If the container does not provide a liveness probe, the default state is Success, livenessProbe user Controls whether pods are restarted.
  • readinessProbe : readiness probe, if the readiness probe fails, the endpoint controller will delete the Pod's IP address from the endpoints of all Services that match the Pod, the readiness state before the initial delay defaults to Failure, if the container does not provide a readiness probe, The default status is Success, and readinessProbe is used to control whether the pod is added to the service.

Comparison of livenessProbe and readinessProbe

The configuration parameters are the same

livenessProbe: If continuous detection fails, the pod will be restarted and rebuilt. ReadinessProbe will not restart or rebuild the pod.

livenessProbe: After the specified number of consecutive detection failures, the container will be placed (Crash Loop BackOff) and must be unavailable, readinessProbe will not

ReadinessProbe: If continuous detection fails, the Pod will be deleted from the endpointd of the service. livenessProbe does not have this function, but the container will be suspended livenessProbe

The livenessProbe user controls whether to restart the pod, and the readinessProbe is used to control whether the pod is added to the service

3 probe method

  • ExecAction: Execute the specified command in the container. The diagnostic is considered successful if the command exits with a return code of 0.
  • TCPSocketAction: Performs a TCP check on the specified port on the container's IP address. The diagnosis is considered successful if the port is open.
  • HTTPGetAction: Performs an HTTP Get request on the specified port and path on the container's IP address. A diagnosis is considered successful if the response has a status code greater than or equal to 200 and less than 400.

4 Probe Results

  • Success: The container passed the diagnostics.
  • Failure: The container failed diagnostics.
  • Unknown: The diagnostic failed, so no action will be taken.

5 Pod restart strategy

restartPolicy:

  • Always: When the container is abnormal, k8s automatically restarts the container, ReplicationController/Replicaset/Deployment.
  • OnFailure: When the container fails (the container stops running and the exit code is not 0), k8s automatically restarts the container.
  • Never: The container, Job or CronJob will never be restarted regardless of the running state of the container.

6 Mirror acquisition strategy

imagePullPolicy:

  • Always: Download the image from the specified warehouse every time the Pod is started.
  • IfNotPresent: Download the image from the target repository only if the local image is missing.
  • Never: Do not download mirrors from the repository, only use local mirrors.

For the image file with the label latest, its default image acquisition strategy is Always;

Mirroring of other tags, the default policy is IfNotPresent.

7 k8s service type

  • ClusterIP: The service is exposed through the internal IP of the cluster. When this value is selected, the service can only be accessed within the cluster. This is also the default used typeif . You can expose services to the public using the Ingress or Gateway API .
  • NodePortNodePort: Expose the service via IP and static port ( ) on each node . To make the node ports available, Kubernetes sets the cluster IP address, which is equivalent to the service you are type: ClusterIPrequesting .
  • LoadBalancer: Use the cloud provider's load balancer to expose services externally. External load balancers can route traffic to automatically created NodePortservices and ClusterIPservices.
  • ExternalName: A service can be mapped to the contents of a field (for example, ) by returning CNAMEa record and corresponding value. There is no need to create any type of proxy.externalNamefoo.bar.example.com

The difference between service and ingress in 8 k8s

service can only be exposed through the four-layer load in the form of ip+port

Ingress can provide Layer 7 responsible for external exposure interfaces, and can schedule business traffic of different business domains and different url access paths.

9 Difference between stateful and stateless services

HTTP requests are stateless, and there is no dependency between multiple requests

Stateful means that there is an association between multiple visits, and the visit relationship between multiple visits needs to be recorded

10 What does service do in k8s?

The main purpose is to dynamically discover the endpoint of the backend host and provide an entry for load balancing.

The above interview questions are just a personal summary. Write whatever you think of, without any order. If there is anything wrong with the writing, please comment and leave a message, and I will correct it in time.

Original link: Linux operation and maintenance engineer interview questions (9) .

Guess you like

Origin blog.csdn.net/qq_45520116/article/details/129782784