diff --git a/apis/apps/v1beta1/configconstraint_types.go b/apis/apps/v1beta1/configconstraint_types.go
index 31a6ad42be8..4a09b1983ec 100644
--- a/apis/apps/v1beta1/configconstraint_types.go
+++ b/apis/apps/v1beta1/configconstraint_types.go
@@ -289,6 +289,56 @@ type ToolConfig struct {
// +kubebuilder:validation:Pattern:=`^[a-z]([a-z0-9\-]*[a-z0-9])?$`
Name string `json:"name,omitempty"`
+ // Indicates whether the tool image should be used as the container image for a sidecar.
+ // This is useful for large tool images, such as those for C++ tools, which may depend on
+ // numerous libraries (e.g., *.so files).
+ //
+ // If enabled, the tool image is deployed as a sidecar container image.
+ //
+ // Examples:
+ // ```yaml
+ // reloadToolsImage:
+ // mountPoint: /kb_tools
+ // toolConfigs:
+ // - name: kb-tools
+ // asContainerImage: true
+ // image: apecloud/oceanbase:4.2.0.0-100010032023083021
+ // ```
+ //
+ // generated containers:
+ // ```yaml
+ // initContainers:
+ // - name: install-config-manager-tool
+ // image: apecloud/kubeblocks-tools:${version}
+ // command:
+ // - cp
+ // - /bin/config_render
+ // - /opt/tools
+ // volumemounts:
+ // - name: kb-tools
+ // mountpath: /opt/tools
+ //
+ // containers:
+ // - name: config-manager
+ // image: apecloud/oceanbase:4.2.0.0-100010032023083021
+ // imagePullPolicy: IfNotPresent
+ // command:
+ // - /opt/tools/reloader
+ // - --log-level
+ // - info
+ // - --operator-update-enable
+ // - --tcp
+ // - "9901"
+ // - --config
+ // - /opt/config-manager/config-manager.yaml
+ // volumemounts:
+ // - name: kb-tools
+ // mountpath: /opt/tools
+ // ```
+ //
+ // +optional
+ AsContainerImage *bool `json:"asContainerImage,omitempty"`
+
// Specifies the tool container image.
//
// +optional
@@ -296,8 +346,8 @@ type ToolConfig struct {
// Specifies the command to be executed by the init container.
//
- // +kubebuilder:validation:Required
- Command []string `json:"command"`
+ // +optional
+ Command []string `json:"command,omitempty"`
}
// DownwardAction defines an action that triggers specific commands in response to changes in Pod labels.
diff --git a/apis/apps/v1beta1/meta.go b/apis/apps/v1beta1/meta.go
index 98a27b1dd7e..ea697164bee 100644
--- a/apis/apps/v1beta1/meta.go
+++ b/apis/apps/v1beta1/meta.go
@@ -43,3 +43,9 @@ func (in *ConfigConstraintSpec) BatchReload() bool {
func (cs *ConfigConstraintStatus) ConfigConstraintTerminalPhases() bool {
return cs.Phase == CCAvailablePhase
}
+
+func (tc *ToolConfig) AsSidecarContainerImage() bool {
+ return tc != nil &&
+ tc.AsContainerImage != nil &&
+ *tc.AsContainerImage
+}
diff --git a/apis/apps/v1beta1/zz_generated.deepcopy.go b/apis/apps/v1beta1/zz_generated.deepcopy.go
index 95e1235802b..ea1400a1236 100644
--- a/apis/apps/v1beta1/zz_generated.deepcopy.go
+++ b/apis/apps/v1beta1/zz_generated.deepcopy.go
@@ -419,6 +419,11 @@ func (in *TPLScriptTrigger) DeepCopy() *TPLScriptTrigger {
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ToolConfig) DeepCopyInto(out *ToolConfig) {
*out = *in
+ if in.AsContainerImage != nil {
+ in, out := &in.AsContainerImage, &out.AsContainerImage
+ *out = new(bool)
+ **out = **in
+ }
if in.Command != nil {
in, out := &in.Command, &out.Command
*out = make([]string, len(*in))
diff --git a/config/crd/bases/apps.kubeblocks.io_configconstraints.yaml b/config/crd/bases/apps.kubeblocks.io_configconstraints.yaml
index 85ec6fd443d..e622ac8c04d 100644
--- a/config/crd/bases/apps.kubeblocks.io_configconstraints.yaml
+++ b/config/crd/bases/apps.kubeblocks.io_configconstraints.yaml
@@ -533,6 +533,25 @@ spec:
description: ToolConfig specifies the settings of an init container
that prepare tools for dynamic reload.
properties:
+ asContainerImage:
+ description: "Indicates whether the tool image should be
+ used as the container image for a sidecar. This is useful
+ for large tool images, such as those for C++ tools, which
+ may depend on numerous libraries (e.g., *.so files). \n
+ If enabled, the tool image is deployed as a sidecar container
+ image. \n Examples: ```yaml reloadToolsImage: mountPoint:
+ /kb_tools toolConfigs: - name: kb-tools asContainerImage:
+ true image: apecloud/oceanbase:4.2.0.0-100010032023083021
+ ``` \n generated containers: ```yaml initContainers: -
+ name: install-config-manager-tool image: apecloud/kubeblocks-tools:${version}
+ command: - cp - /bin/config_render - /opt/tools volumemounts:
+ - name: kb-tools mountpath: /opt/tools \n containers:
+ - name: config-manager image: apecloud/oceanbase:4.2.0.0-100010032023083021
+ imagePullPolicy: IfNotPresent command: - /opt/tools/reloader
+ - --log-level - info - --operator-update-enable - --tcp
+ - \"9901\" - --config - /opt/config-manager/config-manager.yaml
+ volumemounts: - name: kb-tools mountpath: /opt/tools ```"
+ type: boolean
command:
description: Specifies the command to be executed by the
init container.
@@ -547,8 +566,6 @@ spec:
maxLength: 63
pattern: ^[a-z]([a-z0-9\-]*[a-z0-9])?$
type: string
- required:
- - command
type: object
type: array
required:
@@ -1063,6 +1080,25 @@ spec:
description: ToolConfig specifies the settings of an init container
that prepare tools for dynamic reload.
properties:
+ asContainerImage:
+ description: "Indicates whether the tool image should be
+ used as the container image for a sidecar. This is useful
+ for large tool images, such as those for C++ tools, which
+ may depend on numerous libraries (e.g., *.so files). \n
+ If enabled, the tool image is deployed as a sidecar container
+ image. \n Examples: ```yaml reloadToolsImage: mountPoint:
+ /kb_tools toolConfigs: - name: kb-tools asContainerImage:
+ true image: apecloud/oceanbase:4.2.0.0-100010032023083021
+ ``` \n generated containers: ```yaml initContainers: -
+ name: install-config-manager-tool image: apecloud/kubeblocks-tools:${version}
+ command: - cp - /bin/config_render - /opt/tools volumemounts:
+ - name: kb-tools mountpath: /opt/tools \n containers:
+ - name: config-manager image: apecloud/oceanbase:4.2.0.0-100010032023083021
+ imagePullPolicy: IfNotPresent command: - /opt/tools/reloader
+ - --log-level - info - --operator-update-enable - --tcp
+ - \"9901\" - --config - /opt/config-manager/config-manager.yaml
+ volumemounts: - name: kb-tools mountpath: /opt/tools ```"
+ type: boolean
command:
description: Specifies the command to be executed by the
init container.
@@ -1077,8 +1113,6 @@ spec:
maxLength: 63
pattern: ^[a-z]([a-z0-9\-]*[a-z0-9])?$
type: string
- required:
- - command
type: object
type: array
required:
diff --git a/deploy/helm/crds/apps.kubeblocks.io_configconstraints.yaml b/deploy/helm/crds/apps.kubeblocks.io_configconstraints.yaml
index 85ec6fd443d..e622ac8c04d 100644
--- a/deploy/helm/crds/apps.kubeblocks.io_configconstraints.yaml
+++ b/deploy/helm/crds/apps.kubeblocks.io_configconstraints.yaml
@@ -533,6 +533,25 @@ spec:
description: ToolConfig specifies the settings of an init container
that prepare tools for dynamic reload.
properties:
+ asContainerImage:
+ description: "Indicates whether the tool image should be
+ used as the container image for a sidecar. This is useful
+ for large tool images, such as those for C++ tools, which
+ may depend on numerous libraries (e.g., *.so files). \n
+ If enabled, the tool image is deployed as a sidecar container
+ image. \n Examples: ```yaml reloadToolsImage: mountPoint:
+ /kb_tools toolConfigs: - name: kb-tools asContainerImage:
+ true image: apecloud/oceanbase:4.2.0.0-100010032023083021
+ ``` \n generated containers: ```yaml initContainers: -
+ name: install-config-manager-tool image: apecloud/kubeblocks-tools:${version}
+ command: - cp - /bin/config_render - /opt/tools volumemounts:
+ - name: kb-tools mountpath: /opt/tools \n containers:
+ - name: config-manager image: apecloud/oceanbase:4.2.0.0-100010032023083021
+ imagePullPolicy: IfNotPresent command: - /opt/tools/reloader
+ - --log-level - info - --operator-update-enable - --tcp
+ - \"9901\" - --config - /opt/config-manager/config-manager.yaml
+ volumemounts: - name: kb-tools mountpath: /opt/tools ```"
+ type: boolean
command:
description: Specifies the command to be executed by the
init container.
@@ -547,8 +566,6 @@ spec:
maxLength: 63
pattern: ^[a-z]([a-z0-9\-]*[a-z0-9])?$
type: string
- required:
- - command
type: object
type: array
required:
@@ -1063,6 +1080,25 @@ spec:
description: ToolConfig specifies the settings of an init container
that prepare tools for dynamic reload.
properties:
+ asContainerImage:
+ description: "Indicates whether the tool image should be
+ used as the container image for a sidecar. This is useful
+ for large tool images, such as those for C++ tools, which
+ may depend on numerous libraries (e.g., *.so files). \n
+ If enabled, the tool image is deployed as a sidecar container
+ image. \n Examples: ```yaml reloadToolsImage: mountPoint:
+ /kb_tools toolConfigs: - name: kb-tools asContainerImage:
+ true image: apecloud/oceanbase:4.2.0.0-100010032023083021
+ ``` \n generated containers: ```yaml initContainers: -
+ name: install-config-manager-tool image: apecloud/kubeblocks-tools:${version}
+ command: - cp - /bin/config_render - /opt/tools volumemounts:
+ - name: kb-tools mountpath: /opt/tools \n containers:
+ - name: config-manager image: apecloud/oceanbase:4.2.0.0-100010032023083021
+ imagePullPolicy: IfNotPresent command: - /opt/tools/reloader
+ - --log-level - info - --operator-update-enable - --tcp
+ - \"9901\" - --config - /opt/config-manager/config-manager.yaml
+ volumemounts: - name: kb-tools mountpath: /opt/tools ```"
+ type: boolean
command:
description: Specifies the command to be executed by the
init container.
@@ -1077,8 +1113,6 @@ spec:
maxLength: 63
pattern: ^[a-z]([a-z0-9\-]*[a-z0-9])?$
type: string
- required:
- - command
type: object
type: array
required:
diff --git a/docs/developer_docs/api-reference/cluster.md b/docs/developer_docs/api-reference/cluster.md
index 115baab0b31..ca01d866bfb 100644
--- a/docs/developer_docs/api-reference/cluster.md
+++ b/docs/developer_docs/api-reference/cluster.md
@@ -22138,6 +22138,57 @@ string
+asContainerImage
+
+bool
+
+ |
+
+(Optional)
+ Indicates whether the tool image should be used as the container image for a sidecar.
+This is useful for large tool images, such as those for C++ tools, which may depend on
+numerous libraries (e.g., *.so files).
+If enabled, the tool image is deployed as a sidecar container image.
+Examples:
+ reloadToolsImage:
+ mountPoint: /kb_tools
+ toolConfigs:
+ - name: kb-tools
+ asContainerImage: true
+ image: apecloud/oceanbase:4.2.0.0-100010032023083021
+
+generated containers:
+initContainers:
+ - name: install-config-manager-tool
+ image: apecloud/kubeblocks-tools:${version}
+ command:
+ - cp
+ - /bin/config_render
+ - /opt/tools
+ volumemounts:
+ - name: kb-tools
+ mountpath: /opt/tools
+containers:
+ - name: config-manager
+ image: apecloud/oceanbase:4.2.0.0-100010032023083021
+ imagePullPolicy: IfNotPresent
+ command:
+ - /opt/tools/reloader
+ - --log-level
+ - info
+ - --operator-update-enable
+ - --tcp
+ - "9901"
+ - --config
+ - /opt/config-manager/config-manager.yaml
+ volumemounts:
+ - name: kb-tools
+ mountpath: /opt/tools
+
+ |
+
+
+
image
string
@@ -22156,6 +22207,7 @@ string
|
+(Optional)
Specifies the command to be executed by the init container.
|
diff --git a/pkg/configuration/config_manager/handler_util.go b/pkg/configuration/config_manager/handler_util.go
index 276728b683a..8d942b405fb 100644
--- a/pkg/configuration/config_manager/handler_util.go
+++ b/pkg/configuration/config_manager/handler_util.go
@@ -58,6 +58,9 @@ type CfgManagerBuildParams struct {
CMConfigVolumes []corev1.Volume
ConfigLazyRenderedVolumes map[string]corev1.VolumeMount
+ // support custom config manager sidecar
+ ConfigManagerReloadPath string `json:"configManagerReloadPath"`
+
// support host network
ContainerPort int32 `json:"containerPort"`
}
diff --git a/pkg/constant/config.go b/pkg/constant/config.go
new file mode 100644
index 00000000000..2535fe22b4d
--- /dev/null
+++ b/pkg/constant/config.go
@@ -0,0 +1,22 @@
+/*
+Copyright (C) 2022-2024 ApeCloud Co., Ltd
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package constant
+
+const (
+ TPLRenderToolPath = "/bin/config_render"
+ ConfigManagerToolPath = "/bin/reloader"
+)
diff --git a/pkg/controller/configuration/config_utils.go b/pkg/controller/configuration/config_utils.go
index d3725f08325..63abde1d8a6 100644
--- a/pkg/controller/configuration/config_utils.go
+++ b/pkg/controller/configuration/config_utils.go
@@ -115,7 +115,7 @@ func buildConfigManagerWithComponent(podSpec *corev1.PodSpec, configSpecs []apps
func checkAndUpdateSharProcessNamespace(podSpec *corev1.PodSpec, buildParams *cfgcm.CfgManagerBuildParams, configSpecMetas []cfgcm.ConfigSpecMeta) {
shared := cfgcm.NeedSharedProcessNamespace(configSpecMetas)
if shared {
- podSpec.ShareProcessNamespace = func() *bool { b := true; return &b }()
+ podSpec.ShareProcessNamespace = cfgutil.ToPointer(true)
}
buildParams.ShareProcessNamespace = shared
}
@@ -228,7 +228,7 @@ func buildConfigManagerParams(cli client.Client, ctx context.Context, cluster *a
if err := cfgcm.BuildConfigManagerContainerParams(cli, ctx, cfgManagerParams, volumeDirs); err != nil {
return nil, err
}
- if err := buildConfigToolsContainer(cfgManagerParams, podSpec, comp); err != nil {
+ if err := buildReloadToolsContainer(cfgManagerParams, podSpec); err != nil {
return nil, err
}
return cfgManagerParams, nil
diff --git a/pkg/controller/configuration/tool_image_builder.go b/pkg/controller/configuration/tool_image_builder.go
index e0b1f1c6f94..32701cd517b 100644
--- a/pkg/controller/configuration/tool_image_builder.go
+++ b/pkg/controller/configuration/tool_image_builder.go
@@ -20,67 +20,85 @@ along with this program. If not, see .
package configuration
import (
+ "path/filepath"
+
corev1 "k8s.io/api/core/v1"
appsv1beta1 "github.com/apecloud/kubeblocks/apis/apps/v1beta1"
cfgcm "github.com/apecloud/kubeblocks/pkg/configuration/config_manager"
"github.com/apecloud/kubeblocks/pkg/constant"
- "github.com/apecloud/kubeblocks/pkg/controller/component"
"github.com/apecloud/kubeblocks/pkg/controller/factory"
intctrlutil "github.com/apecloud/kubeblocks/pkg/controllerutil"
viper "github.com/apecloud/kubeblocks/pkg/viperx"
)
const (
- toolsVolumeName = "kb-tools"
- initSecRenderedToolContainerName = "init-secondary-rendered-tool"
-
- tplRenderToolPath = "/bin/config_render"
+ toolsVolumeName = "kb-tools"
+ initSecRenderedToolContainerName = "init-secondary-rendered-tool"
+ installConfigMangerToolContainerName = "install-config-manager-tool"
)
-func buildConfigToolsContainer(cfgManagerParams *cfgcm.CfgManagerBuildParams, podSpec *corev1.PodSpec, comp *component.SynthesizedComponent) error {
+func buildReloadToolsContainer(cfgManagerParams *cfgcm.CfgManagerBuildParams, podSpec *corev1.PodSpec) error {
if len(cfgManagerParams.ConfigSpecsBuildParams) == 0 {
return nil
}
// construct config manager tools volume
- toolContainers := make([]appsv1beta1.ToolConfig, 0)
- toolsMap := make(map[string]cfgcm.ConfigSpecMeta)
+ toolsImageMap := make(map[string]cfgcm.ConfigSpecMeta)
+
+ var toolsPath string
+ var sidecarImage string
+ var toolContainers []appsv1beta1.ToolConfig
for _, buildParam := range cfgManagerParams.ConfigSpecsBuildParams {
if buildParam.ToolsImageSpec == nil {
continue
}
- for _, toolConfig := range buildParam.ToolsImageSpec.ToolConfigs {
- if _, ok := toolsMap[toolConfig.Name]; !ok {
- replaceToolsImageHolder(&toolConfig, podSpec, buildParam.ConfigSpec.VolumeName)
- toolContainers = append(toolContainers, toolConfig)
- toolsMap[toolConfig.Name] = buildParam
+ for _, toolImage := range buildParam.ToolsImageSpec.ToolConfigs {
+ if _, ok := toolsImageMap[toolImage.Name]; ok {
+ continue
+ }
+ toolsImageMap[toolImage.Name] = buildParam
+ replaceToolsImageHolder(&toolImage, podSpec, buildParam.ConfigSpec.VolumeName)
+ if toolImage.AsSidecarContainerImage() && sidecarImage == "" {
+ sidecarImage = toolImage.Image
+ } else {
+ toolContainers = append(toolContainers, toolImage)
}
}
buildToolsVolumeMount(cfgManagerParams, podSpec, buildParam.ConfigSpec.VolumeName, buildParam.ToolsImageSpec.MountPoint)
}
// Ensure that the order in which iniContainers are generated does not change
- toolContainers = checkAndInstallToolsImageVolume(toolContainers, cfgManagerParams.ConfigSpecsBuildParams)
+ toolContainers, toolsPath = checkAndInstallToolsImageVolume(toolContainers, cfgManagerParams.ConfigSpecsBuildParams, sidecarImage == "")
if len(toolContainers) == 0 {
return nil
}
-
- containers, err := factory.BuildCfgManagerToolsContainer(cfgManagerParams, comp, toolContainers, toolsMap)
+ if sidecarImage != "" {
+ cfgManagerParams.Image = sidecarImage
+ }
+ if toolsPath != "" {
+ cfgManagerParams.ConfigManagerReloadPath = toolsPath
+ }
+ containers, err := factory.BuildCfgManagerToolsContainer(cfgManagerParams, toolContainers, toolsImageMap)
if err == nil {
cfgManagerParams.ToolsContainers = containers
}
return err
}
-func checkAndInstallToolsImageVolume(toolContainers []appsv1beta1.ToolConfig, buildParams []cfgcm.ConfigSpecMeta) []appsv1beta1.ToolConfig {
+func checkAndInstallToolsImageVolume(toolContainers []appsv1beta1.ToolConfig, buildParams []cfgcm.ConfigSpecMeta, useBuiltinSidecarImage bool) ([]appsv1beta1.ToolConfig, string) {
+ var configManagerBinaryPath string
for _, buildParam := range buildParams {
if buildParam.ToolsImageSpec != nil && buildParam.ConfigSpec.LegacyRenderedConfigSpec != nil {
// auto install config_render tool
toolContainers = checkAndCreateRenderedInitContainer(toolContainers, buildParam.ToolsImageSpec.MountPoint)
}
+ if !useBuiltinSidecarImage {
+ toolContainers = checkAndCreateConfigManagerToolsContainer(toolContainers, buildParam.ToolsImageSpec.MountPoint)
+ configManagerBinaryPath = filepath.Join(buildParam.ToolsImageSpec.MountPoint, filepath.Base(constant.ConfigManagerToolPath))
+ }
}
- return toolContainers
+ return toolContainers, configManagerBinaryPath
}
func checkAndCreateRenderedInitContainer(toolContainers []appsv1beta1.ToolConfig, mountPoint string) []appsv1beta1.ToolConfig {
@@ -93,7 +111,22 @@ func checkAndCreateRenderedInitContainer(toolContainers []appsv1beta1.ToolConfig
toolContainers = append(toolContainers, appsv1beta1.ToolConfig{
Name: initSecRenderedToolContainerName,
Image: kbToolsImage,
- Command: []string{"cp", tplRenderToolPath, mountPoint},
+ Command: []string{"cp", constant.ConfigManagerToolPath, mountPoint},
+ })
+ return toolContainers
+}
+
+func checkAndCreateConfigManagerToolsContainer(toolContainers []appsv1beta1.ToolConfig, mountPoint string) []appsv1beta1.ToolConfig {
+ kbToolsImage := viper.GetString(constant.KBToolsImage)
+ for _, container := range toolContainers {
+ if container.Name == installConfigMangerToolContainerName {
+ return nil
+ }
+ }
+ toolContainers = append(toolContainers, appsv1beta1.ToolConfig{
+ Name: installConfigMangerToolContainerName,
+ Image: kbToolsImage,
+ Command: []string{"cp", constant.TPLRenderToolPath, mountPoint},
})
return toolContainers
}
diff --git a/pkg/controller/configuration/tool_image_builder_test.go b/pkg/controller/configuration/tool_image_builder_test.go
index ea17223db72..1d04c28533c 100644
--- a/pkg/controller/configuration/tool_image_builder_test.go
+++ b/pkg/controller/configuration/tool_image_builder_test.go
@@ -75,7 +75,7 @@ var _ = Describe("ToolsImageBuilderTest", func() {
FormatterConfig: appsv1beta1.FormatterConfig{},
},
ToolsImageSpec: &appsv1beta1.ReloadToolsImage{
- MountPoint: "/opt/images",
+ MountPoint: "/opt/tools",
ToolConfigs: []appsv1beta1.ToolConfig{
{
Name: "test",
@@ -86,6 +86,7 @@ var _ = Describe("ToolsImageBuilderTest", func() {
Name: "test2",
Image: "",
Command: noneCommand,
+ // AsContainerImage: cfgutil.ToPointer(true),
},
{
Name: "test3",
@@ -105,7 +106,7 @@ var _ = Describe("ToolsImageBuilderTest", func() {
Policy: appsv1alpha1.NoneMergePolicy,
},
}
- Expect(buildConfigToolsContainer(cfgManagerParams, &its.Spec.Template.Spec, clusterComponent)).Should(Succeed())
+ Expect(buildReloadToolsContainer(cfgManagerParams, &its.Spec.Template.Spec)).Should(Succeed())
Expect(4).Should(BeEquivalentTo(len(cfgManagerParams.ToolsContainers)))
Expect("test_images").Should(BeEquivalentTo(cfgManagerParams.ToolsContainers[0].Image))
Expect(its.Spec.Template.Spec.Containers[0].Image).Should(BeEquivalentTo(cfgManagerParams.ToolsContainers[1].Image))
diff --git a/pkg/controller/factory/builder.go b/pkg/controller/factory/builder.go
index 1844908664b..539f18c6656 100644
--- a/pkg/controller/factory/builder.go
+++ b/pkg/controller/factory/builder.go
@@ -460,7 +460,7 @@ func BuildCfgManagerContainer(sidecarRenderedParam *cfgcm.CfgManagerBuildParams,
containerBuilder := builder.NewContainerBuilder(sidecarRenderedParam.ManagerName).
AddCommands("env").
AddArgs("PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$(TOOLS_PATH)").
- AddArgs("/bin/reloader").
+ AddArgs(getSidecarBinaryPath(sidecarRenderedParam)).
AddArgs(sidecarRenderedParam.Args...).
AddEnv(env...).
SetImage(sidecarRenderedParam.Image).
@@ -475,7 +475,14 @@ func BuildCfgManagerContainer(sidecarRenderedParam *cfgcm.CfgManagerBuildParams,
return containerBuilder.GetObject(), nil
}
-func BuildCfgManagerToolsContainer(sidecarRenderedParam *cfgcm.CfgManagerBuildParams, component *component.SynthesizedComponent, toolsMetas []appsv1beta1.ToolConfig, toolsMap map[string]cfgcm.ConfigSpecMeta) ([]corev1.Container, error) {
+func getSidecarBinaryPath(buildParams *cfgcm.CfgManagerBuildParams) string {
+ if buildParams.ConfigManagerReloadPath != "" {
+ return buildParams.ConfigManagerReloadPath
+ }
+ return constant.ConfigManagerToolPath
+}
+
+func BuildCfgManagerToolsContainer(sidecarRenderedParam *cfgcm.CfgManagerBuildParams, toolsMetas []appsv1beta1.ToolConfig, toolsMap map[string]cfgcm.ConfigSpecMeta) ([]corev1.Container, error) {
toolContainers := make([]corev1.Container, 0, len(toolsMetas))
for _, toolConfig := range toolsMetas {
toolContainerBuilder := builder.NewContainerBuilder(toolConfig.Name).
diff --git a/pkg/controller/factory/builder_test.go b/pkg/controller/factory/builder_test.go
index 16ad030cba5..6b21e169926 100644
--- a/pkg/controller/factory/builder_test.go
+++ b/pkg/controller/factory/builder_test.go
@@ -411,7 +411,7 @@ var _ = Describe("builder", func() {
})
It("builds cfg manager tools correctly", func() {
- _, cluster, synthesizedComponent := newClusterObjs(nil)
+ _, cluster, _ := newClusterObjs(nil)
cfgManagerParams := &cfgcm.CfgManagerBuildParams{
ManagerName: constant.ConfigSidecarName,
SecreteName: constant.GenerateDefaultConnCredential(cluster.Name),
@@ -423,7 +423,7 @@ var _ = Describe("builder", func() {
{Name: "test-tool", Image: "test-image", Command: []string{"sh"}},
}
- obj, err := BuildCfgManagerToolsContainer(cfgManagerParams, synthesizedComponent, toolContainers, map[string]cfgcm.ConfigSpecMeta{})
+ obj, err := BuildCfgManagerToolsContainer(cfgManagerParams, toolContainers, map[string]cfgcm.ConfigSpecMeta{})
Expect(err).Should(BeNil())
Expect(obj).ShouldNot(BeEmpty())
})