sh 用于创建Kubernetes规范文件的填充脚本

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh 用于创建Kubernetes规范文件的填充脚本相关的知识,希望对你有一定的参考价值。

#!/bin/bash

if [ $# -lt 2 ]; then
  echo 'Expects 2 arguments: ./populate.sh APPLICATION K8S_ENVIRONMENT'
  exit 1
fi

extra_vars="--extra-vars @group_vars/secrets.yml"
application=$1
k8s_environment=$2
vault_password_file="${VAULT_PASSWORD_FILE:-./my-vault-stuff/vault-password}"

if [ ! -f "${application}.yml" ]; then
  echo "Could not find expected playbook ${application}.yml"
  exit 1
else
  extra_vars="${extra_vars} --extra-vars application=${application}"
fi

# Make sure the k8s_environment is set
if [ "${k8s_environment}" = 'dev' ] || [ "${k8s_environment}" = 'prod' ] || \
   [ "${k8s_environment}" = 'staging' ] || [ "${k8s_environment}" = 'test' ]; then
  extra_vars="${extra_vars} --extra-vars k8s_environment=$k8s_environment"
else
  echo 'You must specify $k8s_environment as dev|prod|staging|test'
  exit 1
fi

if [ -f "group_vars/${application}/${k8s_environment}.yml" ]; then
  extra_vars="${extra_vars} --extra-vars @group_vars/${application}/${k8s_environment}.yml"
else
  echo "Did not find file: group_vars/${application}/${k8s_environment}.yml"
fi

if [ -f "group_vars/${k8s_environment}.yml" ]; then
  extra_vars="${extra_vars} --extra-vars @group_vars/${k8s_environment}.yml"
else
  echo "Did not find file: group_vars/${k8s_environment}.yml"
fi

# add extra secrets variables if the files exist
if [ -f "group_vars/${application}/secrets.yml" ]; then
  extra_vars="${extra_vars} --extra-vars @group_vars/${application}/secrets.yml"
fi

if [ -f "group_vars/${application}/secrets/${k8s_environment}.yml" ]; then
  extra_vars="${extra_vars} --extra-vars @group_vars/${application}/secrets/${k8s_environment}.yml"
fi

echo "Populating ${application} into environment ${K8S_ENVIRONMENT}"

ansible-playbook "${application}.yml" $extra_vars --vault-password-file=$vault_password_file

以上是关于sh 用于创建Kubernetes规范文件的填充脚本的主要内容,如果未能解决你的问题,请参考以下文章

sh 简单的Kubernetes仪表板管理,用于本地开发

在 Android 的 WebView 中使用 LoadUrl 用页眉和页脚包装内容

Kubernetes多master部署---创建Node节点kubeconfig文件

FPGA管脚约束

sh Kubernetes Auto GlusterFS光伏创建

Mpdf 删除页脚并将其空间用于内容