Skip to content

命令

ak8s 根据选择目录下所有的yaml文件,批量创建资源对象

[root@k8s-master01 9]# cat /usr/local/bin/ak8s 
#!/bin/bash
if [ -d $1 ];then
  echo "======================applying...======================="
else
  [ $1 == "--help" ] && echo "Usage: ak8s [directory]" && exit
  echo -e "Error: unknown command "$1" for "ak8s" \n Run 'ak8s --help' for usage."
  exit
fi
find $1 -name "*.yaml" > apply.txt
for i in $(cat apply.txt)
do
  kubectl apply -f $i
done
rm -rf apply.txt

ck8s 根据选择目录下所有的yaml文件,批量删除资源对象

[root@k8s-master01 9]# cat /usr/local/bin/ck8s 
#!/bin/bash
if [ -d $1 ];then
  echo "======================deleteing...======================="
else
  [ $1 == "--help" ] && echo "Usage: ck8s [directory]" && exit
  echo -e "Error: unknown command "$1" for "ck8s" \n Run 'ck8s --help' for usage."
  exit
fi
find $1 -name "*.yaml" > clean.txt
for i in $(cat clean.txt)
do
  kubectl delete -f $i
done
rm -rf clean.txt