CKAD 8. Bonus Exercises考试必背

简介: CKAD 8. Bonus Exercises考试必背

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:


相关文章
|
C++ 网络架构
【PAT甲级 - C++题解】1013 Battle Over Cities
【PAT甲级 - C++题解】1013 Battle Over Cities
56 1
|
程序员
ACM刷题之路(一)第K个排列问题 Ignatius and the Princess II
ACM刷题之路(一)第K个排列问题 Ignatius and the Princess II
ACM刷题之路(二十一)大素数筛选 2019暑期集训 POJ 2689 Prime Distance
ACM刷题之路(二十一)大素数筛选 2019暑期集训 POJ 2689 Prime Distance
ACM刷题之路(十九)二分+尺取 2019暑期集训 HDU6231 K-th Number
ACM刷题之路(十九)二分+尺取 2019暑期集训 HDU6231 K-th Number
|
存储 C++
【PAT甲级 - C++题解】1056 Mice and Rice
【PAT甲级 - C++题解】1056 Mice and Rice
53 0
|
存储 C++
【PAT甲级 - C++题解】1036 Boys vs Girls
【PAT甲级 - C++题解】1036 Boys vs Girls
64 0
|
C++
【PAT甲级 - C++题解】1005 Spell It Right
【PAT甲级 - C++题解】1005 Spell It Right
55 0
|
C++
【PAT甲级 - C++题解】1061 Dating
【PAT甲级 - C++题解】1061 Dating
60 0
|
缓存 网络协议 Unix
网络协议分析02(zhuan 程震老师 用于期末复习)
网络协议分析02(zhuan 程震老师 用于期末复习)
111 0
网络协议分析02(zhuan 程震老师 用于期末复习)
|
存储 缓存 网络协议
网络协议分析03(zhuan 程震老师 用于期末复习)
网络协议分析03(zhuan 程震老师 用于期末复习)
114 0
网络协议分析03(zhuan 程震老师 用于期末复习)