kubernetes 如何自动重新加载打开的shift config.yaml文件?

m4pnthwp  于 2023-08-03  发布在  Kubernetes
关注(0)|答案(1)|浏览(99)

当配置值更新时,如何自动重新加载打开的shift配置yaml文件?
当前我正在重新部署以重新加载打开的shift配置yaml。我不想因为配置值更改而再次重新部署应用程序?
下面是我的config.yaml文件。如何自动编写Trigger pod和redepoy pod的语法,并自动更改配置值?

apiVersion: template.openshift.io/v1
kind: Template
metadata:
  name: config
parameters:
- name: APPLICATION
  required: true
- name: BLUE_GREEN_VERSION
  required: true
- name: SQL_CONNECTION
  required: true
- name: API_URL
  required: true 
objects:
- apiVersion: v1
  kind: ConfigMap
  metadata:
    name: ${APPLICATION}-${BLUE_GREEN_VERSION}
  data:
    appsettings.json: |-
      {
        "ConnectionStrings": {
          "SQLDB": "${SQL_CONNECTION}"
        },
        "URL":"${API_URL}",
        "AllowedHosts": "*"
      }

字符串

2exbekwf

2exbekwf1#

我正在检查手表命令,它没有像预期的那样运行。
所以我做了一个简单的脚本并测试了它。

#!/bin/bash

# Set initial time of the last file update
INTIAL_LAST_MODIFICATION_TIME=`stat -c %Z $1`

while true
do
# Check time of the last time update
   LAST_MODIFICATIO_TIME=`stat -c %Z $1`

# Execute command, If file has changed
   if [[ "$LAST_MODIFICATIO_TIME" != "$INTIAL_LAST_MODIFICATION_TIME" ]]
   then
       $2
       INTIAL_LAST_MODIFICATION_TIME=$LAST_MODIFICATIO_TIME
   fi
   sleep ${3:-5}
done

字符串
示例用法将是,

./name_of_the_script 

{file_to_watch} 

{command_to_execute_if_file_have_changed} 

{time_to_wait_before_checking_again_in_seconds_default_is_5}


在您的示例中,将是如下./watch config.yaml "oc apply -f config.yaml" 2
希望这对你有帮助。而且很少有第三方库可以提供更多的选择。如entrinotify-toolswatch exec

相关问题