Sorting files by modification time with ls
| |
Two files line-by-line diff
| |
Using awk to get the last line
| |
Several probe types in Kubernetes
livenessProbedetects deadlocks and determines when to restart the container.readinessProbechecks if the container is ready to receive traffic.startupProbechecks 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-apiserveretcdkube-controller-managerkube-schedulerkubeletkube-proxyContainer 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
kubectlor 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-nodecreates 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,COPYcommand 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 allto 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
.dockerignorefile
How to commit a running container to an image
| |
ps: docker save saves the image as a tar file, and docker load loads the image from a tar file.
CI/CD pipeline
| |
