Java教程

批量创建deployment资源脚本

本文主要是介绍批量创建deployment资源脚本,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
  • 资源文件内容
apiVersion: apps/v1
kind: Deployment
metadata:
  name: deployment-
  labels:
    test_rollingupgrade: "123456"
spec:
  selector:
    matchLabels:
     app : "1234"
  replicas: 1
  template:
    metadata:
      labels:
        app: "123"
    spec:
      containers:
      - name: test-pod
        image: nginx:1.12.2
  • 脚本内容
#!/bin/bash

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

rm tmp-*

批量删除直接把kubectl apply 改为kubectl delete即可

这篇关于批量创建deployment资源脚本的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!