没有不值得去解决的问题,也没有不值得去学习的技术!

Troubleshooting Rancher Environment Variables That Are Missing or Not Applied in Containers

Checking the file: /config/init/change.log. app/common/boot/bootstrap.lua does not exist

1. A total of 4 environment variables were configured in Rancher. See Figure 1.

A total of 4 environment variables were configured in Rancher
Figure 1

2. Checking the container logs, 2 environment variables are missing. See Figure 2.

Checking the container logs, 2 environment variables are missing
Figure 2

3. As a result, the 2 missing environment variables in the configuration file were not replaced. See Figure 3.

As a result, the 2 missing environment variables in the configuration file were not replaced
Figure 3

4. I noticed that the 2 missing environment variables have the prefix: MOREFUN_. The production environment variables have the prefix: MOREFUN_CFC_. I decided to adjust the prefix, but they were still not replaced after the adjustment.

5. I decided to change the configuration file name from CONFIG_BOOTSTRAP_FILE to CONFIG_BOOT_FILE. They were still not replaced after the adjustment.

6. I checked the file: /config/init/change.log. app/common/boot/bootstrap.lua does not exist. See Figure 4.

Checking the file: /config/init/change.log. app/common/boot/bootstrap.lua does not exist
Figure 4
Plaintext
[root@api-8464f5d654-zvf2r init]# cat change.log 
MOREFUN_CFC_REDIS_HOST replace 154.8.144.199 -> /app/common/lib/redis.lua
MOREFUN_CFC_REDIS_PORT replace 6379 -> /app/common/lib/redis.lua
MOREFUN_CFC_REDIS_DB replace 21 -> /app/common/lib/redis.lua
MOREFUN_CFC_REDIS_PASSWORD replace Redis -> /app/common/lib/redis.lua
app/common/boot/bootstrap.lua does not exist

7. I edited the config0.sh file. I changed CONFIG_BOOT_FILE=app/common/boot/bootstrap.lua to CONFIG_BOOT_FILE=/app/common/boot/bootstrap.lua, adding the forward slash for the root directory.

ShellScript

# 记录日志
DIR=/config/init
# 配置文件
CONFIG_FILE=/app/common/lib/redis.lua
CONFIG_BOOT_FILE=/app/common/boot/bootstrap.lua

8. Checking the container logs, all 4 variables are now present. See Figure 5.

Checking the container logs, all 4 variables are now present
Figure 5

9. The 2 environment variables in the configuration file have been replaced. See Figure 6.

The 2 environment variables in the configuration file have been replaced
Figure 6

关于作者 · 持续学习与技术实践

我是一名拥有 15 年以上开发经验的技术从业者,自 2013 年起持续运营个人技术博客,记录工作与个人项目中遇到的真实问题,以及解决问题过程中的探索、实践和思考。

除了技术写作,我也在持续开发和维护自己的独立项目,探索新技术和新工具在实际场景中的应用。我始终相信,没有不值得去解决的问题,也没有不值得去学习的技术。

如果这篇文章对你有所帮助,欢迎浏览博客中的其他文章,也欢迎交流技术经验与想法。

关于我  ·  GitHub  ·  邮件联系