在部署期间添加辅助数据库数据
Adding auxiliary DB data during deployment
我的应用程序由两个容器组成:应用程序本身和数据库。我打算将应用程序包装到图表中,从而为易于重现的部署铺平道路。
除了setting/reading environment envs(helm+kubernetes 似乎处理得很好),app 配置的一部分是:
making sure the database is pre-filled with special auxiliary data (e.g. admin user exists, some user role names required to create new users are there, etc.).
我喜欢让可读的 yaml 文件以人类可读的格式保存整个配置的想法。然而乍一看,helm
似乎对 this(数据库记录)类型的配置没有任何帮助。
也就是说,放置code/configuration 确保数据库包含某些辅助记录的最佳位置是什么?配置 yaml 文件?一个容器初始化脚本,写在 bash?
你是对的,Kubernetes 或 Helm 无法帮助你准备预填充的数据库 records/schema。
您可能应该让您的应用程序初始化那些预填充的数据。如果您不想将此逻辑放入您的应用程序中,您可以发送一个初始化脚本并使用 Kubernetes 配置一个 init container。
Kubernetes 确保每次您的应用程序容器重新启动时,init 容器首先运行。在 init 容器中,您可以执行 bash/python/... 脚本,确保您想要的记录在那里。
我的应用程序由两个容器组成:应用程序本身和数据库。我打算将应用程序包装到图表中,从而为易于重现的部署铺平道路。
除了setting/reading environment envs(helm+kubernetes 似乎处理得很好),app 配置的一部分是:
making sure the database is pre-filled with special auxiliary data (e.g. admin user exists, some user role names required to create new users are there, etc.).
我喜欢让可读的 yaml 文件以人类可读的格式保存整个配置的想法。然而乍一看,helm
似乎对 this(数据库记录)类型的配置没有任何帮助。
也就是说,放置code/configuration 确保数据库包含某些辅助记录的最佳位置是什么?配置 yaml 文件?一个容器初始化脚本,写在 bash?
你是对的,Kubernetes 或 Helm 无法帮助你准备预填充的数据库 records/schema。
您可能应该让您的应用程序初始化那些预填充的数据。如果您不想将此逻辑放入您的应用程序中,您可以发送一个初始化脚本并使用 Kubernetes 配置一个 init container。
Kubernetes 确保每次您的应用程序容器重新启动时,init 容器首先运行。在 init 容器中,您可以执行 bash/python/... 脚本,确保您想要的记录在那里。