Skip to Content
Kubernetes 认证管理员 (CKA) 学习指南 (Chinese Edition), 2nd Edition
book

Kubernetes 认证管理员 (CKA) 学习指南 (Chinese Edition), 2nd Edition

by Benjamin Muschko
January 2026
Intermediate to advanced
392 pages
4h 44m
Chinese
O'Reilly Media, Inc.
Content preview from Kubernetes 认证管理员 (CKA) 学习指南 (Chinese Edition), 2nd Edition

附录A. 复习题答案

第4章 集群安装与升级

  1. 使用以下命令列出集群节点。您应看到:

    $ kubectl get nodes
    NAME           STATUS   ROLES           AGE     VERSION
    minikube       Ready    control-plane   2m20s   v1.32.2
    minikube-m02   Ready    <none>          2m10s   v1.32.2
    minikube-m03   Ready    <none>          2m3s    v1.32.2
    minikube-m04   Ready    <none>          116s    v1.32.2
    

    使用以下命令调度 Pod:

    $ kubectl run nginx --image=nginx:1.27.4-alpine
    

    可通过显示信息识别Pod运行节点。该Pod正在名为minikube-m02的节点上运行:

    $ kubectl get pod nginx -o jsonpath='{.spec.nodeName}'
    minikube-m02
    

    使用kubectl drain命令驱逐节点上的所有Pod。此处节点名为minikube-m02。需添加--ignore-daemonsets参数仅删除非DaemonSet管理的Pod,并使用--force参数强制删除无控制器管理的Pod:

    $ kubectl drain minikube-m02 --ignore-daemonsets --force
    evicting pod default/nginx
    pod/nginx evicted
    node/minikube-m02 drained
    
  2. 本示例练习的解决方案需要大量手动操作。以下命令不会显示其输出结果。

    通过 Vagrant 打开控制平面节点的交互式 shell:

    $ vagrant ssh kube-control-plane
    

    kubeadm升级至 1.32.2 版本并应用更新:

    $ sudo apt-mark unhold kubeadm && sudo apt-get update && sudo apt-get \
      install -y kubeadm=1.32.2-1.1 && sudo apt-mark hold kubeadm
    $ sudo kubeadm upgrade apply v1.32.2
    

    清空节点资源、升级kubelet和kubectl、重启kubelet并解除节点隔离:

    $ kubectl drain kube-control-plane --ignore-daemonsets
    $ sudo apt-get update && sudo apt-get install -y \
      --allow-change-held-packages kubelet=1.32.2-1.1 kubectl=1.32.2-1.1
    $ sudo systemctl daemon-reload
    $ sudo systemctl restart kubelet
    $ kubectl uncordon kube-control-plane
    

    节点版本应显示为v1.32.2。退出节点:

    $ kubectl get nodes
    $ exit
    

    使用Vagrant在工作节点上打开交互式shell:

    $ vagrant ssh kube-worker-1
    

    将kubeadm升级至1.32.2版本并应用至节点:

    $ sudo apt-get update && sudo apt-get install -y \ --allow-change-held-packages ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Kubernetes 上的生成式人工智能 (Chinese Edition)

Kubernetes 上的生成式人工智能 (Chinese Edition)

Roland Huß, Daniele Zonca
游戏化头脑风暴

游戏化头脑风暴

Dave Gray, Sunni Brown, James Macanufo

Publisher Resources

ISBN: 0642572314712