环境:
1、准备好集群
2、采用nginx作为镜像,探针检测80端口
3、创建200个

过程:
1、准备好yaml文件
```html/xml
#采用ngix-
后面“-”是空的原因是为了shell里面把$i带进去!

apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-
namespace: testname
labels:
app: "nginx-"
spec:
selector:
matchLabels:
app: "nginx-"
replicas: 1
template:
metadata:
labels:
app: "nginx-"
spec:
containers:

  • name: nginx-
    image: nginx:1.12.2
    readinessProbe:
    httpGet:
    port: 80

2、使用shell脚本对yaml文件进行批量替换+创建
```html/xml
#!/bin/bash

for i  in {1..200}
do
    deploymentName=nginx-$i
    newYaml=tmp-$i.yaml
    cp test.yaml $newYaml
    sed -ie 's/nginx-/'"$deploymentName"'/g' $newYaml
    echo $newYaml
    kubectl apply -f $newYaml
    rm $newYaml
done
rm tmp-*

3、2个文件放在同一个目录,运行shell就可以创建了

4、补充:事后删除200个deployment
```html/xml
#!/bin/bash

for i in {1..200}
do
deploymentName=nginx-$i
newYaml=tmp-$i.yaml
cp test.yaml $newYaml
sed -ie 's/nginx-/'"$deploymentName"'/g' $newYaml
echo $newYaml
kubectl delete -f $newYaml
rm $newYaml
done

rm tmp-*