Featured image of post Interview | Zhishupu Huazhang Operations Engineer

Interview | Zhishupu Huazhang Operations Engineer

Sorting files by modification time with ls

1
ls -lt

Two files line-by-line diff

1
2
3
diff -w test.sh test2.sh

diff test.sh test2.sh 

Using awk to get the last line

1
awk '{print $NF}'

Several probe types in Kubernetes

  • livenessProbe detects deadlocks and determines when to restart the container.
  • readinessProbe checks if the container is ready to receive traffic.
  • startupProbe checks if the service inside the container has started, which can be used for slow-starting containers for liveness detection, to avoid them being killed by kubelet before they start running.

Components of a Kubernetes cluster

  • kube-apiserver

  • etcd

  • kube-controller-manager

  • kube-scheduler

  • kubelet

  • kube-proxy

  • Container runtime (e.g., Docker)

  • Network plugins (e.g., Calico, Flannel)

  • Storage plugins (e.g., Ceph, NFS)

Process of creating a pod

  • The user submits the pod’s YAML configuration to the API Server via kubectl or other tools.
  • The API server receives the request, validates it, and stores the configuration information in etcd.
  • Scheduler detects a new pod creation and schedules the pod to a node based on scheduling policies.
  • The kubelet detects that the node needs to create a pod:
    • Pulls the image
    • Creates a sandbox, where all containers share the network and storage namespaces
    • Calls the container runtime to create containers in the pod
    • If there are init containers, kubelet starts them before the application containers
    • aws-node creates pod network interface and assigns an IP address
  • Health checks, liveness probe, readiness probe, and startup probe are started and run.
  • The kubelet updates the pod status to the API server, and the information is uploaded to etcd to achieve global consistency.

Creating an Ingress

YAML configuration…

Differences between ADD and COPY in Dockerfile

  • ADD: Use when you need to download from a URL or automatically unzip a local compressed file.
    • If the source is a local compressed file, it will automatically unzip.
    • Can fetch resources from a remote URL, such as downloading files from an HTTP server.
  • Prefer using COPY.

How to reduce the size of an image

  • Use a small base image
  • Each FROM, RUN, COPY command in the Dockerfile creates a separate layer, which increases the overall size and build time of the image. Combine multiple commands into a single layer.
  • Use multi-stage builds
  • Clean up unnecessary files (e.g., yum clean all to delete package management cache)
  • Finally, delete the installation packages
  • Copy library files or installation packages into the image instead of installing them directly
  • Use a .dockerignore file

How to commit a running container to an image

1
docker commit <container_id> <image_name>

ps: docker save saves the image as a tar file, and docker load loads the image from a tar file.

CI/CD pipeline

1
git clone -- complie -- build -- push
Licensed under CC BY-NC-SA 4.0
Built with Hugo
Theme Stack designed by Jimmy 🚀
Published: 58 Posts  |  Total Views: ... views
Uptime: ...  |  Site Visits: ... views