🦊
kubernetes exam in action
  • kubernetes exam in action
  • 云原生
  • KCNA 考试
    • KCNA 1:云原生架构
    • KCNA 2:容器编排
    • KCNA 3:kubernetes基础知识
    • KCNA 4:kubernetes实践
    • KCNA 5:持续交付
    • KCNA 6:监控与探测
    • KCNA 7:测试题
  • CKA考试
    • CKA、CKAD考试经验
    • CKA试题
  • CKAD考试
    • 1. Core Concepts (13%)
    • 2. Configuration (18%)
    • 3. Multi-Container Pods (10%)
    • 4. Observability (18%)
    • 5. Pod Design (20%)
    • 6. Networking (13%)
    • 7. State Persistence (8%)
    • 8. 考试小技巧
  • CKS考试
    • cks 试题
    • RBAC
    • Dashboard
    • Secure Ingress
    • Node Metadata
    • CIS Benchmarks
    • Verify Platform
    • Networkpolicy
    • Restrict API Access
    • ServiceAccounts
    • Upgrade Kubernetes
    • Secrets 安全
    • Container Runtime Sandboxes
    • securityContext and podsecurityPolicies
    • SecurityContext and StartupProbe
    • Open Policy Agent (OPA)
    • Image build
    • Image Vulnerability Scanning(Trivy)
    • ImagePolicyWebhook
    • Static Analysis(OPA)
    • /proc and Env
    • Auditing
    • Apparmor
    • Falco
    • Strace
由 GitBook 提供支持
在本页
  • Using an alias for kubectl
  • Setting the namespace per context
  • Deleting Kubernetes objects quickly
  • Bash Commands
  • Kubernetes Object Information
  1. CKAD考试

8. 考试小技巧

Using an alias for kubectl

$ alias k=kubectl
$ k version

Setting the namespace per context

$ kubectl config set-context <context-of-question> --namespace=<namespace-of-question>

Deleting Kubernetes objects quickly

$ kubectl delete pod nginx --grace-period=0 --force

Bash Commands

编写一个bash一线式文件,~/tmp/date.txt每5秒将当前日期写入文件中。创建目录(如果尚不存在)。新日期不会覆盖文件中的现有日期,而是将其追加。

if [ ! -d ~/tmp ]; then mkdir -p ~/tmp; fi; while true; do echo $(date) >> ~/tmp/date.txt; sleep 5; done;

编写一个bash一线式脚本,它定义一个counter初始值为0的变量。每秒递增一次该变量,然后将其值打印到控制台。

counter=0; while true; do counter=$((counter+1)); echo "$counter"; sleep 1; done;

编写一个bash一线式代码,该值定义了一个介于1到100之间的值的变量。在循环中,如果变量的值小于50,则打印该变量的值。如果该值大于或等于50,则中断该循环并打印出消息“结束:$值”。

while true; do random=$(((RANDOM % 100) + 1)); if [ $random -le 50 ]; then echo "$random"; else echo "END: $random"; break; fi; sleep 1; done;

Kubernetes Object Information

Finding specific annotations

为带有注释的任何现有Pod打印约10行Pod描述author=John Doe。

kubectl describe pods | grep -C 10 "author=John Doe"

Finding all labels

打印所有Pod的标签并确定其Pod名称。以YAML格式呈现输出。

kubectl get pods -o yaml | grep -C 5 labels:
上一页7. State Persistence (8%)下一页CKS考试

最后更新于3年前