diff --git a/docs/user-manuals/crd-upgrade/yurtmanager-crd-upgrade.md b/docs/user-manuals/crd-upgrade/yurtmanager-crd-upgrade.md new file mode 100644 index 0000000000..527e926546 --- /dev/null +++ b/docs/user-manuals/crd-upgrade/yurtmanager-crd-upgrade.md @@ -0,0 +1,44 @@ +--- +title: seamless CRDs upgrade +--- + +## Brackgound introduction + +There is no support at this time for upgrading Custom Resource Definitions (CRDs) using Helm. This was an explicit decision after much community discussion due to the danger for unintentional data loss. Furthermore, there is currently no community consensus around how to handle CRDs and their lifecycle. + +As a consequence, it is necessary to manually apply to update CRDs one by one. It is troublesome and the upgrade process should be automated. + +## Automation Implementation +Init containers can contain utilities or setup scripts not present in an app image. +We can utilize init container to upgrade CRDs. We can copy all CRDs related files into images and iterate through each crd yaml to update the crd using server side apply, as follows: + +```go +filepath.Walk(CRD_DIR, func(path string, info fs.FileInfo, err error) error { + if err != nil { + return err + } + switch { + case info.Mode().IsDir(): + return nil + case info.Mode().IsRegular(): + // ... + // client apply crd to upgrade + } + return nil +}) +``` + +## How to use + +Using yurt-manager as an example, we only need to copy the binary in and execute it in the command. + +```yaml +initContainers: +- image: {{ .Values.image.registry }}/{{ .Values.image.repository }}:{{ .Values.image.tag }} + name: crd-upgrader + imagePullPolicy: IfNotPresent + command: + - /usr/local/bin/crd-upgrader +``` + +We also should make sure to provide CRD-related permissions to the service account. \ No newline at end of file diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/user-manuals/crd-upgrade/yurtmanager-crd-upgrade.md b/i18n/zh/docusaurus-plugin-content-docs/current/user-manuals/crd-upgrade/yurtmanager-crd-upgrade.md new file mode 100644 index 0000000000..0d88eef6c8 --- /dev/null +++ b/i18n/zh/docusaurus-plugin-content-docs/current/user-manuals/crd-upgrade/yurtmanager-crd-upgrade.md @@ -0,0 +1,44 @@ +--- +title: 无缝升级CRDs +--- + +## 背景介绍 + +目前不支持使用Helm升级或删除CRDs。由于数据意外丢失的风险,这是经过多次社区讨论后作出的明确决定。对于如何处理CRD及其生命周期, 目前社区还未达成共识。 + +因此,用户必须逐个手动申请更新CRDs。这是一件很繁琐的事情,升级过程应该自动化。 + +## 自动化实现 +Init容器可以包含应用程序镜像中不存在的实用工具和安装脚本。 +我们可以利用Init容器升级 CRD。我们可以将所有与 CRD 相关的文件复制到映像中,然后遍历每个crd yaml,使用服务器端应用更新 crd,如下所示: + +```go +filepath.Walk(CRD_DIR, func(path string, info fs.FileInfo, err error) error { + if err != nil { + return err + } + switch { + case info.Mode().IsDir(): + return nil + case info.Mode().IsRegular(): + // ... + // client apply crd to upgrade + } + return nil +}) +``` + +## 如何使用 + +以 yurt-manager 为例,我们只需复制二进制文件并在命令中执行即可。 + +```yaml +initContainers: +- image: {{ .Values.image.registry }}/{{ .Values.image.repository }}:{{ .Values.image.tag }} + name: crd-upgrader + imagePullPolicy: IfNotPresent + command: + - /usr/local/bin/crd-upgrader +``` + +需要注意的是,我们还应确保为服务账户提供与 CRD 相关的权限。 \ No newline at end of file diff --git a/sidebars.js b/sidebars.js index e3710e181a..3d9ccfaded 100644 --- a/sidebars.js +++ b/sidebars.js @@ -94,6 +94,11 @@ module.exports = { 'IOT': [ 'user-manuals/iot/edgex-foundry', ] + }, + { + 'crd-upgrade': [ + 'user-manuals/crd-upgrade/yurtmanager-crd-upgrade', + ] } ] },