Docker 與 Kubernetes 開發指引與常用操作。使用者觸發。
golang:x.xx-alpine build + scratch 或 distroless runnode:xx-alpine,Python 用 python:x.xx-slimlatest tag,明確指定版本.dockerignore 排除不必要檔案# 建構
docker build -t <name>:<tag> .
# 執行
docker run -d --name <name> -p <host>:<container> <image>
# 查看
docker ps -a
docker logs -f <container>
# 清理
docker system prune -af
compose.yaml(v2 格式)compose.yaml + compose.dev.yaml.env 檔,不寫死在 compose 裡# 查看資源
kubectl get pods -n <ns>
kubectl get svc -n <ns>
kubectl describe pod <name> -n <ns>
# 查看日誌
kubectl logs -f <pod> -n <ns>
kubectl logs -f <pod> -c <container> -n <ns>
# 進入 pod
kubectl exec -it <pod> -n <ns> -- /bin/sh
# 套用設定
kubectl apply -f <file>.yaml
kubectl apply -k <kustomize-dir>
# 偵錯
kubectl get events -n <ns> --sort-by=.lastTimestamp
kubectl top pods -n <ns>
readinessProbe 和 livenessProbeapp.kubernetes.io/name、app.kubernetes.io/component