Linux Performance http://www.brendangregg.com/linuxperf.html nicolaka/ netshoot - https://github.com/nicolaka/netshoot • 技術上來說,一個基本 Linux Container 就是一 個 Linux Process,實踐來自於 Linux Kernel, 而所具備的資安能力也是一樣 • Linux Namespaces • cgroups v1/v2 • SELinux / Apparmor • SECCOMP • 大多數的常見系統工具都還是可以沿用 • Linux Performance Tools • Linux System Tools
• 可以在尚未部署到 Kubernetes 測試之前,以運行單一個 Pod 測試,儘早回饋修正 • 與 Kubernetes 相同,在 Pod 裡面也會有 Pause 容器,存在理由也是為了解決相同問 題,主要共享 Linux Namespace 資源 • 建立 Pod 之後,可以後面在新增想要放置的容器進去 19 $ podman run -dt --pod new:nginx-pod --publish=8080:80 docker.io/library/nginx:1.19.3 686db821c649832d6b6c7074fae13831477badf8dec8707000a41d5b11297111 $ podman ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 686db821c649 docker.io/library/nginx:1.19.3 nginx -g daemon o... About a minute ago Up About a minute ago 0.0.0.0:8080->80/tcp heuristic_blackburn e2306e151fed k8s.gcr.io/pause:3.2 About a minute ago Up About a minute ago 0.0.0.0:8080->80/tcp d0606265918b-infra Ref: Podman: Managing pods and containers in a local container runtime https://developers.redhat.com/blog/2019/01/15/podman-managing-containers-pods
YAML • Podman 2.x 之後開始支援產生 Kubernetes 相關物件 • 可以從既有的 Podman Pod 產生 Kubernetes Pod 跟 Service YAML • 雖然還在開發階段,但長遠來看是相當正確的路線,可以從 2.1.0 之後開始用起 20 $ podman generate kube --help Generate Kubernetes YAML from a container or pod. Description: Command generates Kubernetes pod and service YAML (v1 specification) from a Podman container or pod. Whether the input is for a container or pod, Podman will always generate the specification as a pod. $ podman generate kube --service d0606265918b apiVersion: v1 kind: Pod …omit… --- apiVersion: v1 kind: Service …omit… Ref: Moving from docker-compose to Podman pods https://www.redhat.com/sysadmin/compose-podman-pods
YAML • 既然可以輸出 Kubernetes YAML,當然也可以運行 Kubernetes YAML !!! • 連 replica 設定多少都會完全遵照執行 22 $ podman play kube --help Play a pod based on Kubernetes YAML. Description: Command reads in a structured file of Kubernetes YAML. It creates the pod and containers described in the YAML. The containers within the pod are then started and the ID of the new Pod is output. $ wget https://raw.githubusercontent.com/kubernetes/website/master/content/en/examples/controllers/nginx- deployment.yaml $ cat nginx-deployment.yaml | grep replicas replicas: 3 $ podman play kube ./nginx-deployment.yaml $ podman pod ps POD ID NAME STATUS CREATED # OF CONTAINERS INFRA ID 3856aa3a53fe nginx-deployment-pod-2 Running 26 seconds ago 2 aaff9084887c f03937100d9d nginx-deployment-pod-1 Running 26 seconds ago 2 db40e2417335 254f7faf3320 nginx-deployment-pod-0 Running 47 seconds ago 2 96a6d8c8593b Ref: The podman play kube command now supports deployments https://www.redhat.com/sysadmin/podman-play-kube