CKS/CKA tips
- 1 minutes read - 174 wordsThe fastest way to get nodes
Many times, I run "kubectl get nodes" to get nodes I need to connect to make changes. In the question description section of tasks, master nodes and worker nodes are given. I think the fastest way to get nodes and I wasted some time on getting that info from commands.
Get events
Now kubectl has events command. The events command has intuitive options and less keystokes.
# intuitive options
#--for pod/web-pod-13je7 --watch --types=Warning,Normal
kubectl events
#vs
kubectl get events
Quickly get vulnerabilitiy info of images using trivy
cat <<EOF | xargs -I{} sh -c 'trivy -q image {} | grep -B2 -E "Total:"'
nginx:1.19.1-alpine-perl
nginx:1.20.2-alpine
httpd:2.4.39-alpine
EOF
cat <<EOF | xargs -I{} sh -c 'trivy -q image --severity=HIGH,CRITICAL {} | grep -B2 -E "Total:"'
nginx:1.19.1-alpine-perl
nginx:1.20.2-alpine
httpd:2.4.39-alpine
EOF
cat <<EOF | xargs -I{} sh -c 'trivy -q image --severity=HIGH,CRITICAL {} | grep -B2 -E "Total:"'
nginx:1.19.1-alpine-perl
nginx:1.20.2-alpine
httpd:2.4.39-alpine
EOF
cat <<EOF | xargs -I{} sh -c "echo '{}(CVE-2021-28831|CVE-2016-9841)';trivy -q image {}| grep -E '(CVE-2021-28831)|(CVE-2016-9841)'"
nginx:1.19.1-alpine-perl
nginx:1.20.2-alpine
httpd:2.4.39-alpine
EOF