shell脚本逐个杀死k8s中某个应用的pod

#!/bin/bash

pod01=`kubectl get pod -o wide -n weifeng-system|grep official-ui-node-prod|awk -F : ‘NR==1‘|awk -F " " ‘{print $1}‘`
pod02=`kubectl get pod -o wide -n weifeng-system|grep official-ui-node-prod|awk -F : ‘NR==2‘|awk -F " " ‘{print $1}‘`
pod03=`kubectl get pod -o wide -n weifeng-system|grep official-ui-node-prod|awk -F : ‘NR==3‘|awk -F " " ‘{print $1}‘`

kubectl delete pod $pod01  -n weifeng-system

sleep 60

kubectl delete pod $pod02  -n weifeng-system

sleep 60

kubectl delete pod $pod03  -n weifeng-system

sleep 20

node_prod_status=`kubectl get pod -o wide -n weifeng-system|grep official-ui-node-prod|awk -F " " ‘{print $3}‘|grep -ci "Running"`

if [ $node_prod_status -eq 3 ];then

    echo -e "\033[32m[ the application official-ui-node-pre successfully deployed  ]\033[0m"

else
    echo -e "\033[31m\033[01m[ the application official-ui-node-pre deploy failed  ]\033[0m"

fi

  

原文地址:https://www.cnblogs.com/weifeng1463/p/10254951.html

时间: 2024-08-30 00:34:26

shell脚本逐个杀死k8s中某个应用的pod的相关文章

shell脚本练习题(更新中...)

练习题(这里贴的是自己写的代码, 网上给的题目代码我会附加在最下面) 1. 编写shell脚本,计算1-100的和: 1 #!/bin/bash 2 #caculate the sum of numbers from 1 to 100 3 4 sum=0 5 for i in `seq 1 100`; do 6 sum=$[$sum+$i] 7 done 8 echo $sum 2. 编写shell脚本,要求输入一个数字,然后计算出从1到输入数字的和,要求,如果输入的数字小于1,则重新输入,直到

shell 脚本迁移mysql数据库中的表

作为写脚本的,这次的重点在于实现了类似于其他语言的logging模块的输出功能.感觉还是蛮有用的,简单直观. 输出log如下所示: 2017-03-31 16:26:57 --- INFO --- You choose the name of the table below: 2017-03-31 16:26:57 --- INFO --- 2016_06_24_record_base_log 2017-03-31 16:26:57 --- INFO --- 2016_06_16_record_

(原创)Windows下编译的Shell脚本不能再Linux中运行的解决办法

一.原理 Windows编译的文件和Linux编译的文件格式不太一样,导致在Linux运行Shell脚本的时候会提示:/bin/bash^M: bad interpreter: 没有那个文件或目录. 原因是这样的: 1.Windows编译的文件结束时(回车+换行) 2.Linux编译的文件结束时(换行)             这样导致了Windows编译的文件放在Linux中会有[noeol]和[dos]的Flag标示. 如果运行CAT命令可以更直观的看到两个不同操作系统产生的文件差异,Win

echo -e 在SHELL脚本和命令行中表现不同一例问题排查

一开发同事反馈,在SHELL脚本中使用echo -e 将结果输出到文件中,表现与预期不同,具体如下:[echo 的man如下所示] 开发同事在脚本中是这样调用他写的脚本的: # vim a.sh sh b.sh [b.sh中包含echo -e操作] 操作系统:ubuntu14.04 脚本内容[示例]: # cat test01.sh #!/bin/bash echo -e "aa\nbb" > /tmp/test.log 执行后,得到的/tmp/test.log 的内容为 # s

将shell脚本加入到系统服务中去

有没有觉得执行脚本的时候需要写长长的绝对路径很难受,要想轻松很简单,把自己写的脚本通过开启服务一样运行,像启动apache一样启动你的脚步的.(PS:其实apache也是个脚本) 一.首先了解一下基本的知识和概念 系统运行级别: # 0 - 停机(千万不能把initdefault 设置为0 ) # 1 - 单用户模式 # s init s = init 1 # 2 - 多用户,没有 NFS # 3 - 完全多用户模式(标准的运行级) # 4 - 没有用到 # 5 - X11 多用户图形模式(xw

shell脚本从文件夹中递归提取文件

需求 前两天碰到需要在十层左右的文件夹中提取文件的需求,于是写了此脚本. 如下面这样的文件结构: dir1 ├── a │ ├── b │ │ └── file1 │ └── file2 ├── c │ └── d │ ├── e │ │ └── file4 │ └── file3 └── file5 我们需要将其中的file1~file5提取出来放到另一个文件夹中. 脚本 脚本getfilefromdir.sh如下: #!/bin/bash #desc: get file from direc

shell脚本--02修改配置文件中的IP

1.修改Json中的IP $ ./ip.sh '8.8.8.1' #!/bin/bash#localIP=$(command)#localIP='/sbin/ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|grep 8|awk '{print $2}'|tr -d "addr:"'for ip in $(< /home/.../conf/env.json);do if [ ${ip} == "9.9.0.224

shell 脚本获取MySQL数据库中所有表记录总数

近期遇到一个需求,Mysql数据库中需要统计所有表的记录数据:查了下资料可以调取information_schema数据表中数据获取所有表记录数据,但是查询出来的数据,发现和手动统计的记录数据不一致,information_schema查询出来的数据部分不准确[原因应该是部分表数据没有自动同步].折腾了下,于是还是自己手动写个脚本,分享下也做下次备用.程序结构:#!/bin/bash Author:Jerry tb_name=mysql -u账号 -p密码 -h192.168.x.x -P端口

shell脚本修改Linux系统中所有IP样例

#!/bin/sh CURR_DIR=$(cd $(dirname $0);pwd) TD_BASE=`su - tduser -c "echo "${TD_BASE}""` function change_app_ip() { if [ $# -ne 3 ];then echo "The param is not correct." exit 1 fi if [ "$1" != "app_ip" ];th