You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by pc...@apache.org on 2023/06/28 06:47:08 UTC
[camel-k] 01/07: feat: remove the need for a storage
This is an automated email from the ASF dual-hosted git repository.
pcongiusti pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit 0dcf48672b67a45f3dbd582fbb1c57e8f38d7927
Author: Pasquale Congiusti <pa...@gmail.com>
AuthorDate: Tue Jun 13 12:16:22 2023 +0200
feat: remove the need for a storage
---
config/manager/kustomization.yaml | 4 --
config/manager/operator-pvc.yaml | 30 ----------
config/manager/patch-install-default-pvc.yaml | 28 ---------
e2e/commonwithcustominstall/builder_test.go | 20 -------
e2e/install/cli/install_test.go | 2 -
e2e/install/kustomize/operator_test.go | 2 -
e2e/install/olm/olm_install_test.go | 86 ---------------------------
e2e/support/test_support.go | 19 ------
pkg/apis/camel/v1/common_types.go | 9 ++-
pkg/cmd/install.go | 18 ------
pkg/cmd/install_test.go | 39 ------------
pkg/controller/build/build_pod.go | 19 ------
pkg/controller/integrationkit/build.go | 13 +---
pkg/install/operator.go | 81 -------------------------
pkg/resources/resources.go | 33 +++++-----
pkg/util/defaults/defaults.go | 3 -
script/Makefile | 6 +-
17 files changed, 27 insertions(+), 385 deletions(-)
diff --git a/config/manager/kustomization.yaml b/config/manager/kustomization.yaml
index 6f98412bc..38c67427f 100644
--- a/config/manager/kustomization.yaml
+++ b/config/manager/kustomization.yaml
@@ -19,7 +19,6 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
-- operator-pvc.yaml
- operator-deployment.yaml
- operator-service-account.yaml
@@ -31,6 +30,3 @@ patches:
- path: patch-log-level.yaml
target:
kind: Deployment
-- path: patch-install-default-pvc.yaml
- target:
- kind: Deployment
diff --git a/config/manager/operator-pvc.yaml b/config/manager/operator-pvc.yaml
deleted file mode 100644
index 6541740a3..000000000
--- a/config/manager/operator-pvc.yaml
+++ /dev/null
@@ -1,30 +0,0 @@
-# ---------------------------------------------------------------------------
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You 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.
-# ---------------------------------------------------------------------------
-
-apiVersion: v1
-kind: PersistentVolumeClaim
-metadata:
- name: camel-k-pvc
- labels:
- app: "camel-k"
-spec:
- accessModes:
- - ReadWriteOnce
- resources:
- requests:
- storage: 20Gi
- storageClassName: standard
diff --git a/config/manager/patch-install-default-pvc.yaml b/config/manager/patch-install-default-pvc.yaml
deleted file mode 100644
index c4f8990b2..000000000
--- a/config/manager/patch-install-default-pvc.yaml
+++ /dev/null
@@ -1,28 +0,0 @@
-# ---------------------------------------------------------------------------
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You 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.
-# ---------------------------------------------------------------------------
-
-- op: add
- path: /spec/template/spec/containers/0/volumeMounts
- value:
- - name: camel-k-pvc
- mountPath: /etc/maven/m2
-- op: add
- path: /spec/template/spec/volumes
- value:
- - name: camel-k-pvc
- persistentVolumeClaim:
- claimName: camel-k-pvc
diff --git a/e2e/commonwithcustominstall/builder_test.go b/e2e/commonwithcustominstall/builder_test.go
index 05c6d188d..245eb160f 100644
--- a/e2e/commonwithcustominstall/builder_test.go
+++ b/e2e/commonwithcustominstall/builder_test.go
@@ -35,26 +35,6 @@ import (
v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
)
-func TestBuilderPodFallback(t *testing.T) {
- WithNewTestNamespace(t, func(ns string) {
- operatorID := fmt.Sprintf("camel-k-%s", ns)
- Expect(KamelInstallWithID(operatorID, ns, "--storage=false").Execute()).To(Succeed())
- Eventually(OperatorPod(ns)).ShouldNot(BeNil())
- Eventually(Platform(ns)).ShouldNot(BeNil())
- Eventually(PlatformConditionStatus(ns, v1.IntegrationPlatformConditionReady), TestTimeoutShort).
- Should(Equal(corev1.ConditionTrue))
-
- t.Run("run yaml", func(t *testing.T) {
- Expect(KamelRunWithID(operatorID, ns, "files/yaml.yaml").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "yaml"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, "yaml", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, "yaml"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
-
- Eventually(Logs(ns, OperatorPod(ns)().Name, corev1.PodLogOptions{})).Should(ContainSubstring(`the operator was installed with an ephemeral storage, builder \"pod\" strategy is not supported: using \"routine\" build strategy as a fallback.`))
- })
- })
-}
-
func TestBuilderTimeout(t *testing.T) {
WithNewTestNamespace(t, func(ns string) {
operatorID := fmt.Sprintf("camel-k-%s", ns)
diff --git a/e2e/install/cli/install_test.go b/e2e/install/cli/install_test.go
index 40f52afc8..5e7f40a2d 100644
--- a/e2e/install/cli/install_test.go
+++ b/e2e/install/cli/install_test.go
@@ -54,7 +54,6 @@ func TestBasicInstallation(t *testing.T) {
Eventually(Platform(ns)).ShouldNot(BeNil())
Eventually(PlatformConditionStatus(ns, v1.IntegrationPlatformConditionReady), TestTimeoutShort).
Should(Equal(corev1.ConditionTrue))
- Eventually(OperatorPodPVCName(ns)).Should(Equal(defaults.DefaultPVC))
t.Run("run yaml", func(t *testing.T) {
Expect(KamelRunWithID(operatorID, ns, "files/yaml.yaml").Execute()).To(Succeed())
@@ -107,7 +106,6 @@ func TestEphemeralInstallation(t *testing.T) {
Eventually(Platform(ns)).ShouldNot(BeNil())
Eventually(PlatformConditionStatus(ns, v1.IntegrationPlatformConditionReady), TestTimeoutShort).
Should(Equal(corev1.ConditionTrue))
- Eventually(OperatorPodPVCName(ns)).Should(Equal(""))
})
}
diff --git a/e2e/install/kustomize/operator_test.go b/e2e/install/kustomize/operator_test.go
index c003dc6b6..4002604b2 100644
--- a/e2e/install/kustomize/operator_test.go
+++ b/e2e/install/kustomize/operator_test.go
@@ -31,7 +31,6 @@ import (
. "github.com/apache/camel-k/v2/e2e/support"
testutil "github.com/apache/camel-k/v2/e2e/support/util"
- "github.com/apache/camel-k/v2/pkg/util/defaults"
. "github.com/onsi/gomega"
)
@@ -61,7 +60,6 @@ func TestOperatorBasic(t *testing.T) {
Eventually(OperatorPod(ns)).ShouldNot(BeNil())
Eventually(OperatorPodPhase(ns), TestTimeoutMedium).Should(Equal(corev1.PodRunning))
Eventually(Platform(ns)).ShouldNot(BeNil())
- Eventually(OperatorPodPVCName(ns)).Should(Equal(defaults.DefaultPVC))
})
}
diff --git a/e2e/install/olm/olm_install_test.go b/e2e/install/olm/olm_install_test.go
index 4e631f39b..cdadbdded 100644
--- a/e2e/install/olm/olm_install_test.go
+++ b/e2e/install/olm/olm_install_test.go
@@ -35,9 +35,7 @@ import (
olm "github.com/operator-framework/api/pkg/operators/v1alpha1"
- v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
"github.com/apache/camel-k/v2/pkg/util/defaults"
- "github.com/apache/camel-k/v2/pkg/util/kubernetes"
"github.com/apache/camel-k/v2/pkg/util/openshift"
)
@@ -97,63 +95,6 @@ func TestOLMInstallation(t *testing.T) {
// Check the IntegrationPlatform has been reconciled
Eventually(PlatformVersion(ns)).Should(ContainSubstring(ipVersionPrefix))
- // By default, an OLM installation has no PVC installed
- Eventually(OperatorPodPVCName(ns)).Should(Equal(""))
-
- t.Run("run smoke test ephemeral", func(t *testing.T) {
- name := "yaml"
- Expect(Kamel("run", "-n", ns, "files/yaml.yaml").Execute()).To(Succeed())
- // Check the Integration runs correctly
- Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, name, v1.IntegrationConditionReady), TestTimeoutLong).Should(Equal(corev1.ConditionTrue))
- // Check the Integration version matches that of the current operator
- Expect(IntegrationVersion(ns, name)()).To(ContainSubstring(ipVersionPrefix))
- // Check the operator is warning
- Eventually(Logs(ns, OperatorPod(ns)().Name, corev1.PodLogOptions{})).Should(ContainSubstring(`the operator was installed with an ephemeral storage, builder \"pod\" strategy is not supported: using \"routine\" build strategy as a fallback.`))
- Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
- })
-
- t.Run("run smoke test pvc", func(t *testing.T) {
- pvc, err := createIfNotExistsCamelKPVC(ns)
- if err != nil {
- assert.Fail(t, err.Error())
- }
- // We alter the subscription to use a PVC
- subscription, err := GetSubscription(ns)
- Expect(err).To(BeNil())
- Expect(subscription).NotTo(BeNil())
- // Change the Subscription to let it use the PVC
- editedSubscription := subscription.DeepCopy()
- volume := corev1.Volume{
- Name: defaults.DefaultPVC,
- VolumeSource: corev1.VolumeSource{
- PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{
- ClaimName: pvc.Name,
- },
- },
- }
- if editedSubscription.Spec.Config.Volumes == nil {
- editedSubscription.Spec.Config.Volumes = make([]corev1.Volume, 0, 1)
- }
- editedSubscription.Spec.Config.Volumes = append(editedSubscription.Spec.Config.Volumes, volume)
- vm := corev1.VolumeMount{
- MountPath: defaults.LocalRepository,
- Name: volume.Name,
- }
- if editedSubscription.Spec.Config.VolumeMounts == nil {
- editedSubscription.Spec.Config.VolumeMounts = make([]corev1.VolumeMount, 0, 1)
- }
- editedSubscription.Spec.Config.VolumeMounts = append(editedSubscription.Spec.Config.VolumeMounts, vm)
-
- Expect(TestClient().Update(TestContext, editedSubscription)).To(Succeed())
-
- Eventually(OperatorPodPVCName(ns)).Should(Equal(defaults.DefaultPVC))
- Expect(KamelRun(ns, "files/yaml.yaml").Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "yaml"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, "yaml", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, "yaml"), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
- Eventually(Logs(ns, OperatorPod(ns)().Name, corev1.PodLogOptions{})).ShouldNot(ContainSubstring(`the operator was installed with an ephemeral storage, builder \"pod\" strategy is not supported: using \"routine\" build strategy as a fallback.`))
- })
// Clean up
Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
@@ -162,30 +103,3 @@ func TestOLMInstallation(t *testing.T) {
Expect(Kamel("uninstall", "--all", "-n", ns, "--olm=false").Execute()).To(Succeed())
})
}
-
-func createIfNotExistsCamelKPVC(ns string) (*corev1.PersistentVolumeClaim, error) {
- // Verify if a PVC already exists
- camelKPVC, err := kubernetes.LookupPersistentVolumeClaim(TestContext, TestClient(), ns, defaults.DefaultPVC)
- if err != nil {
- return nil, err
- }
- if camelKPVC != nil {
- fmt.Printf("A persistent volume claim for \"%s\" already exist, reusing it\n", defaults.DefaultPVC)
- return camelKPVC, nil
- }
-
- defaultStorageClass, err := kubernetes.LookupDefaultStorageClass(TestContext, TestClient())
- if err != nil {
- return nil, err
- }
-
- camelKPVC = kubernetes.NewPersistentVolumeClaim(
- ns,
- defaults.DefaultPVC,
- defaultStorageClass.Name,
- "20Gi",
- corev1.PersistentVolumeAccessMode("ReadWriteOnce"),
- )
-
- return camelKPVC, TestClient().Create(TestContext, camelKPVC)
-}
diff --git a/e2e/support/test_support.go b/e2e/support/test_support.go
index e42d687e2..efba69d6d 100644
--- a/e2e/support/test_support.go
+++ b/e2e/support/test_support.go
@@ -2025,25 +2025,6 @@ func OperatorPod(ns string) func() *corev1.Pod {
}
}
-func OperatorPodPVCName(ns string) func() string {
- return func() string {
- operatorPod := OperatorPod(ns)()
- if operatorPod.Spec.Volumes == nil {
- return ""
- }
- volumes := OperatorPod(ns)().Spec.Volumes
- if volumes == nil {
- return ""
- }
- for _, v := range volumes {
- if v.Name == defaults.DefaultPVC {
- return defaults.DefaultPVC
- }
- }
- return ""
- }
-}
-
// Find one Pod filtered by namespace ns and label app.kubernetes.io/name value appName.
func Pod(ns string, appName string) func() (*corev1.Pod, error) {
return func() (*corev1.Pod, error) {
diff --git a/pkg/apis/camel/v1/common_types.go b/pkg/apis/camel/v1/common_types.go
index ede52e028..4a4aaa2cf 100644
--- a/pkg/apis/camel/v1/common_types.go
+++ b/pkg/apis/camel/v1/common_types.go
@@ -61,11 +61,14 @@ type BuildStrategy string
const (
// BuildStrategyRoutine performs the build in a routine (will be executed as a process inside the same Camel K operator `Pod`).
- // A routine may be preferred to a `pod` strategy since it reuse the Maven repository dependency cached locally. It is executed as
+ // A routine may be preferred to a `pod` strategy since it is in general quicker to execute. It is executed as
// a parallel process, so you may need to consider the quantity of concurrent build process running simultaneously.
+ // Only available for Quarkus JVM mode.
BuildStrategyRoutine BuildStrategy = "routine"
- // BuildStrategyPod performs the build in a `Pod` (will schedule a new builder ephemeral `Pod` which will take care of the build action).
- // This strategy has the limitation that every build will have to download all the dependencies required by the Maven build.
+ // BuildStrategyPod performs the build in a `Pod` (will schedule a new builder `Pod` which will take care of the build action).
+ // This strategy has the limitation that every build will have to download all the dependencies required by the Maven build which should be
+ // mitigated by the presence of a Maven proxy.
+ // Available for both Quarkus JVM and Native mode.
BuildStrategyPod BuildStrategy = "pod"
)
diff --git a/pkg/cmd/install.go b/pkg/cmd/install.go
index 7c95ba1c2..cf68324c8 100644
--- a/pkg/cmd/install.go
+++ b/pkg/cmd/install.go
@@ -156,12 +156,6 @@ func newCmdInstall(rootCmdOptions *RootCmdOptions) (*cobra.Command, *installCmdO
// save
cmd.Flags().Bool("save", false, "Save the install parameters into the default kamel configuration file (kamel-config.yaml)")
- // Storage settings
- cmd.Flags().Bool("storage", true, "If false, it won't use a persistent storage (recommended for development purpose only)")
- cmd.Flags().String("storage-class-name", "", "Use a storage class name to create a dynamic volume (if empty will look up for cluster default)")
- cmd.Flags().String("storage-capacity", "20Gi", "How much capacity to use")
- cmd.Flags().String("storage-access-mode", "ReadWriteOnce", "Persistent Volume Access Mode (any of ReadWriteOnce, ReadOnlyMany, ReadWriteMany or ReadWriteOncePod)")
-
return &cmd, &options
}
@@ -213,8 +207,6 @@ type installCmdOptions struct {
registry v1.RegistrySpec
registryAuth registry.Auth
RegistryAuthFile string `mapstructure:"registry-auth-file"`
- Storage bool `mapstructure:"storage"`
- storageOptions install.OperatorStorageConfiguration
}
func (o *installCmdOptions) install(cmd *cobra.Command, _ []string) error {
@@ -445,9 +437,6 @@ func (o *installCmdOptions) setupOperator(
ResourcesRequirements: o.ResourcesRequirements,
EnvVars: o.EnvVars,
}
- if o.Storage {
- cfg.Storage = o.storageOptions
- }
return install.OperatorOrCollect(o.Context, cmd, c, cfg, output, o.Force)
}
@@ -701,13 +690,6 @@ func (o *installCmdOptions) decode(cmd *cobra.Command, _ []string) error {
o.olmOptions.StartingCSV = viper.GetString(path + ".olm-starting-csv")
o.olmOptions.GlobalNamespace = viper.GetString(path + ".olm-global-namespace")
- if o.Storage {
- o.storageOptions.Enabled = true
- o.storageOptions.ClassName = viper.GetString(path + ".storage-class-name")
- o.storageOptions.AccessMode = viper.GetString(path + ".storage-access-mode")
- o.storageOptions.Capacity = viper.GetString(path + ".storage-capacity")
- }
-
return nil
}
diff --git a/pkg/cmd/install_test.go b/pkg/cmd/install_test.go
index a34fdef83..fcfdb8ecd 100644
--- a/pkg/cmd/install_test.go
+++ b/pkg/cmd/install_test.go
@@ -456,42 +456,3 @@ func TestInstallDebugLogging4(t *testing.T) {
assert.Nil(t, err)
assert.Equal(t, "debug", installCmdOptions.LogLevel)
}
-
-func TestInstallStorage(t *testing.T) {
- installCmdOptions, rootCmd, _ := initializeInstallCmdOptions(t)
- _, err := test.ExecuteCommand(rootCmd, cmdInstall,
- "--storage-class-name", "scn",
- "--storage-access-mode", "sam",
- "--storage-capacity", "10Gi",
- )
- assert.Nil(t, err)
- assert.Equal(t, true, installCmdOptions.Storage)
- assert.Equal(t, true, installCmdOptions.storageOptions.Enabled)
- assert.Equal(t, "scn", installCmdOptions.storageOptions.ClassName)
- assert.Equal(t, "sam", installCmdOptions.storageOptions.AccessMode)
- assert.Equal(t, "10Gi", installCmdOptions.storageOptions.Capacity)
-}
-
-func TestInstallStorageFalse(t *testing.T) {
- installCmdOptions, rootCmd, _ := initializeInstallCmdOptions(t)
- _, err := test.ExecuteCommand(rootCmd, cmdInstall,
- "--storage=false",
- )
- assert.Nil(t, err)
- assert.Equal(t, false, installCmdOptions.Storage)
- assert.Equal(t, false, installCmdOptions.storageOptions.Enabled)
- assert.Equal(t, "", installCmdOptions.storageOptions.ClassName)
- assert.Equal(t, "", installCmdOptions.storageOptions.AccessMode)
- assert.Equal(t, "", installCmdOptions.storageOptions.Capacity)
-}
-
-func TestInstallStorageDefault(t *testing.T) {
- installCmdOptions, rootCmd, _ := initializeInstallCmdOptions(t)
- _, err := test.ExecuteCommand(rootCmd, cmdInstall)
- assert.Nil(t, err)
- assert.Equal(t, true, installCmdOptions.Storage)
- assert.Equal(t, true, installCmdOptions.storageOptions.Enabled)
- assert.Equal(t, "", installCmdOptions.storageOptions.ClassName)
- assert.Equal(t, "ReadWriteOnce", installCmdOptions.storageOptions.AccessMode)
- assert.Equal(t, "20Gi", installCmdOptions.storageOptions.Capacity)
-}
diff --git a/pkg/controller/build/build_pod.go b/pkg/controller/build/build_pod.go
index 7c6e2cfed..3a77b56f4 100644
--- a/pkg/controller/build/build_pod.go
+++ b/pkg/controller/build/build_pod.go
@@ -256,19 +256,6 @@ func addBuildTaskToPod(build *v1.Build, taskName string, pod *corev1.Pod) {
},
)
}
- if !hasVolume(pod, defaults.DefaultPVC) {
- pod.Spec.Volumes = append(pod.Spec.Volumes,
- // Maven repo volume
- corev1.Volume{
- Name: defaults.DefaultPVC,
- VolumeSource: corev1.VolumeSource{
- PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{
- ClaimName: defaults.DefaultPVC,
- },
- },
- },
- )
- }
var envVars = proxyFromEnvironment()
envVars = append(envVars, corev1.EnvVar{
@@ -556,12 +543,6 @@ func addContainerToPod(build *v1.Build, container corev1.Container, pod *corev1.
MountPath: filepath.Join(builderDir, build.Name),
})
}
- if hasVolume(pod, defaults.DefaultPVC) {
- container.VolumeMounts = append(container.VolumeMounts, corev1.VolumeMount{
- Name: defaults.DefaultPVC,
- MountPath: defaults.LocalRepository,
- })
- }
pod.Spec.InitContainers = append(pod.Spec.InitContainers, container)
}
diff --git a/pkg/controller/integrationkit/build.go b/pkg/controller/integrationkit/build.go
index 24cf949a7..ca04e749e 100644
--- a/pkg/controller/integrationkit/build.go
+++ b/pkg/controller/integrationkit/build.go
@@ -121,16 +121,9 @@ func (action *buildAction) handleBuildSubmitted(ctx context.Context, kit *v1.Int
// nolint: contextcheck
if buildConfig.Strategy == v1.BuildStrategyPod {
- // Pod strategy requires a PVC to exist. If it does not exist, we warn the user and fallback to Routine build strategy
- if pvc, err := kubernetes.LookupPersistentVolumeClaim(env.Ctx, env.Client, operatorNamespace, defaults.DefaultPVC); pvc != nil || err != nil {
- err = platform.CreateBuilderServiceAccount(env.Ctx, env.Client, env.Platform)
- if err != nil {
- return nil, fmt.Errorf("error while creating Camel K Builder service account: %w", err)
- }
- } else {
- // Fallback to Routine strategy
- buildConfig.Strategy = v1.BuildStrategyRoutine
- Log.Info(`Warning: the operator was installed with an ephemeral storage, builder "pod" strategy is not supported: using "routine" build strategy as a fallback. We recommend to configure a PersistentVolumeClaim in order to be able to use "pod" builder strategy. Please consider that certain features such as Quarkus native require a "pod" builder strategy (hence a PVC) to work properly.`)
+ err = platform.CreateBuilderServiceAccount(env.Ctx, env.Client, env.Platform)
+ if err != nil {
+ return nil, fmt.Errorf("error while creating Camel K Builder service account: %w", err)
}
}
buildConfig.ToolImage = env.CamelCatalog.Image
diff --git a/pkg/install/operator.go b/pkg/install/operator.go
index 89d09fb69..4f3d1081f 100644
--- a/pkg/install/operator.go
+++ b/pkg/install/operator.go
@@ -40,7 +40,6 @@ import (
v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
"github.com/apache/camel-k/v2/pkg/client"
"github.com/apache/camel-k/v2/pkg/resources"
- "github.com/apache/camel-k/v2/pkg/util/defaults"
"github.com/apache/camel-k/v2/pkg/util/envvar"
"github.com/apache/camel-k/v2/pkg/util/knative"
"github.com/apache/camel-k/v2/pkg/util/kubernetes"
@@ -62,7 +61,6 @@ type OperatorConfiguration struct {
NodeSelectors []string
ResourcesRequirements []string
EnvVars []string
- Storage OperatorStorageConfiguration
}
type OperatorHealthConfiguration struct {
@@ -96,43 +94,7 @@ func OperatorOrCollect(ctx context.Context, cmd *cobra.Command, c client.Client,
return err
}
- var camelKPVC *corev1.PersistentVolumeClaim
- if cfg.Storage.Enabled {
- camelKPVC, err = installPVC(ctx, cmd, c, cfg, collection)
- if err != nil {
- return err
- }
- }
-
customizer := func(o ctrl.Object) ctrl.Object {
- if camelKPVC != nil {
- if d, ok := o.(*appsv1.Deployment); ok {
- if d.Labels["camel.apache.org/component"] == "operator" {
- volume := corev1.Volume{
- Name: defaults.DefaultPVC,
- VolumeSource: corev1.VolumeSource{
- PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{
- ClaimName: camelKPVC.Name,
- },
- },
- }
- if d.Spec.Template.Spec.Volumes == nil {
- d.Spec.Template.Spec.Volumes = make([]corev1.Volume, 0, 1)
- }
- d.Spec.Template.Spec.Volumes = append(d.Spec.Template.Spec.Volumes, volume)
-
- vm := corev1.VolumeMount{
- MountPath: defaults.LocalRepository,
- Name: volume.Name,
- }
- if d.Spec.Template.Spec.Containers[0].VolumeMounts == nil {
- d.Spec.Template.Spec.Containers[0].VolumeMounts = make([]corev1.VolumeMount, 0, 1)
- }
- d.Spec.Template.Spec.Containers[0].VolumeMounts = append(d.Spec.Template.Spec.Containers[0].VolumeMounts, vm)
- }
- }
- }
-
if cfg.CustomImage != "" {
if d, ok := o.(*appsv1.Deployment); ok {
if d.Labels["camel.apache.org/component"] == "operator" {
@@ -394,49 +356,6 @@ func OperatorOrCollect(ctx context.Context, cmd *cobra.Command, c client.Client,
return nil
}
-func installPVC(ctx context.Context, cmd *cobra.Command, c client.Client, cfg OperatorConfiguration, collection *kubernetes.Collection) (*corev1.PersistentVolumeClaim, error) {
- // Verify if a PVC already exists
- camelKPVC, err := kubernetes.LookupPersistentVolumeClaim(ctx, c, cfg.Namespace, defaults.DefaultPVC)
- if err != nil {
- return nil, err
- }
- if camelKPVC != nil {
- fmt.Fprintf(cmd.ErrOrStderr(), "A persistent volume claim for \"%s\" already exist, reusing it\n", defaults.DefaultPVC)
- return camelKPVC, nil
- }
-
- // Use a dynamic volume based on storage classes
- storageClassName, err := getStorageClassName(ctx, c, cfg.Storage.ClassName)
- if err != nil {
- return nil, err
- }
- if storageClassName != "" {
- fmt.Fprintf(cmd.ErrOrStderr(), "Using storage class \"%s\" to create \"%s\" volume for the operator\n", storageClassName, defaults.DefaultPVC)
- camelKPVC = kubernetes.NewPersistentVolumeClaim(
- cfg.Namespace,
- defaults.DefaultPVC,
- storageClassName,
- cfg.Storage.Capacity,
- corev1.PersistentVolumeAccessMode(cfg.Storage.AccessMode),
- )
- err = ObjectOrCollect(ctx, c, cfg.Namespace, collection, false, camelKPVC)
- return camelKPVC, err
- }
- fmt.Fprintf(cmd.ErrOrStderr(), "Could not find a default storage class in the cluster. The operator will be installed with an ephemeral storage. Bear in mind certain build strategies such as \"pod\" may not work as expected.\n")
- return nil, nil
-}
-
-func getStorageClassName(ctx context.Context, c client.Client, cfgStorageClassName string) (string, error) {
- if cfgStorageClassName != "" {
- return cfgStorageClassName, nil
- }
- defaultStorageClass, err := kubernetes.LookupDefaultStorageClass(ctx, c)
- if err != nil {
- return "", err
- }
- return defaultStorageClass.Name, nil
-}
-
func installNamespacedRoleBinding(ctx context.Context, c client.Client, collection *kubernetes.Collection, namespace string, path string) error {
yaml, err := resources.ResourceAsString(path)
if err != nil {
diff --git a/pkg/resources/resources.go b/pkg/resources/resources.go
index d6daa4592..a6fa58714 100644
--- a/pkg/resources/resources.go
+++ b/pkg/resources/resources.go
@@ -174,6 +174,18 @@ var assets = func() http.FileSystem {
name: "manager",
modTime: time.Time{},
},
+ "/manager/bundle": &vfsgen۰DirInfo{
+ name: "bundle",
+ modTime: time.Time{},
+ },
+ "/manager/bundle/manifests": &vfsgen۰DirInfo{
+ name: "manifests",
+ modTime: time.Time{},
+ },
+ "/manager/bundle/metadata": &vfsgen۰DirInfo{
+ name: "metadata",
+ modTime: time.Time{},
+ },
"/manager/operator-deployment.yaml": &vfsgen۰CompressedFileInfo{
name: "operator-deployment.yaml",
modTime: time.Time{},
@@ -181,13 +193,6 @@ var assets = func() http.FileSystem {
compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xc4\x56\x4d\x8f\xe2\x46\x10\xbd\xfb\x57\x3c\xe1\xcb\xae\x34\x18\x66\x4f\x2b\xe7\xe4\x0c\x4c\xd6\xca\xc6\x20\xcc\x66\xb4\xa7\xa8\x69\x17\x76\x8b\x76\xb7\xd3\xdd\x86\x25\xbf\x3e\x6a\x83\x19\x60\x3e\x92\x89\x46\x8a\x4f\xd8\x55\xf5\xea\xd5\x7b\xd5\x36\x21\x86\xef\x77\x05\x21\xbe\x0a\x4e\xca\x52\x01\xa7\xe1\x2a\x42\xd2\x30\x5e\x11\x72\xbd\x76\x3b\x66\x08\xf7\xba\x55\x05\x73\x42\x2b\x7c\x48\xf2\xfb\x8f\x68\x55\x41\x06\x5a\x [...]
},
- "/manager/operator-pvc.yaml": &vfsgen۰CompressedFileInfo{
- name: "operator-pvc.yaml",
- modTime: time.Time{},
- uncompressedSize: 1156,
-
- compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xac\x53\xc1\x8e\xdb\x36\x10\xbd\xf3\x2b\x1e\xac\x4b\x02\xac\xbd\x69\x8e\xee\xc9\x75\xec\x56\x68\x2a\x17\x96\x93\x45\x8e\x63\x72\x2c\x0d\x96\x22\x55\x92\x5a\xc5\x7f\x5f\x50\x96\x93\x0d\x72\x0d\x6f\xe3\x19\xbf\x79\x6f\xde\x53\x81\xe5\xaf\x7b\xaa\xc0\x47\xd1\xec\x22\x1b\x24\x8f\xd4\x32\x36\x3d\xe9\x96\x51\xfb\x4b\x1a\x29\x30\xf6\x7e\x70\x86\x92\x78\x87\x37\x9b\x7a\xff\x16\x83\x33\x1c\xe0\x1d\xc3\x07\x74\x3e\xb0\x2a\xa0\x [...]
- },
"/manager/operator-service-account.yaml": &vfsgen۰CompressedFileInfo{
name: "operator-service-account.yaml",
modTime: time.Time{},
@@ -209,13 +214,6 @@ var assets = func() http.FileSystem {
compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xac\x53\xcd\x6e\xa3\x3c\x14\xdd\xfb\x29\x8e\xc2\xa6\x95\x92\x50\x7d\xcb\x7c\x2b\xa6\x25\x1a\xd4\x0c\x91\x0a\x9d\xaa\xab\xca\x81\x0b\x5c\x0d\xd8\x1e\xdb\x94\xe6\xed\x47\x26\xc9\xb4\xd5\x6c\xeb\x9d\xe1\xfa\xfc\xf8\x1c\x47\x58\x7d\xdd\x12\x11\x76\x5c\x91\x72\x54\xc3\x6b\xf8\x8e\x90\x18\x59\x75\x84\x42\x37\x7e\x92\x96\xb0\xd5\xa3\xaa\xa5\x67\xad\x70\x95\x14\xdb\x6b\x8c\xaa\x26\x0b\xad\x08\xda\x62\xd0\x96\x44\x84\x4a\x2b\x [...]
},
- "/manager/patch-install-default-pvc.yaml": &vfsgen۰CompressedFileInfo{
- name: "patch-install-default-pvc.yaml",
- modTime: time.Time{},
- uncompressedSize: 1206,
-
- compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xac\x53\x4d\x4f\xeb\x38\x14\xdd\xfb\x57\x1c\x35\x1b\x90\xda\x06\xb1\xec\xac\x3a\xa5\xd5\x44\xc3\xa4\x23\x52\x40\x2c\xdd\xe4\x36\xb9\x22\xfe\x78\xb6\xd3\xd0\x7f\xff\xe4\xa4\x7d\x80\xd8\xb0\xc0\x3b\xcb\xd7\xe7\xc3\xe7\x38\xc1\xec\xe7\x96\x48\x70\xcf\x25\x69\x4f\x15\x82\x41\x68\x08\x4b\x2b\xcb\x86\x50\x98\x43\xe8\xa5\x23\x6c\x4c\xa7\x2b\x19\xd8\x68\x5c\x2d\x8b\xcd\x35\x3a\x5d\x91\x83\xd1\x04\xe3\xa0\x8c\x23\x91\xa0\x34\x [...]
- },
"/manager/patch-log-level.yaml": &vfsgen۰CompressedFileInfo{
name: "patch-log-level.yaml",
modTime: time.Time{},
@@ -686,12 +684,11 @@ var assets = func() http.FileSystem {
fs["/crd/bases/camel.apache.org_pipes.yaml"].(os.FileInfo),
}
fs["/manager"].(*vfsgen۰DirInfo).entries = []os.FileInfo{
+ fs["/manager/bundle"].(os.FileInfo),
fs["/manager/operator-deployment.yaml"].(os.FileInfo),
- fs["/manager/operator-pvc.yaml"].(os.FileInfo),
fs["/manager/operator-service-account.yaml"].(os.FileInfo),
fs["/manager/patch-image-pull-policy-always.yaml"].(os.FileInfo),
fs["/manager/patch-install-default-kamelets.yaml"].(os.FileInfo),
- fs["/manager/patch-install-default-pvc.yaml"].(os.FileInfo),
fs["/manager/patch-log-level.yaml"].(os.FileInfo),
fs["/manager/patch-node-selector.yaml"].(os.FileInfo),
fs["/manager/patch-ports.yaml"].(os.FileInfo),
@@ -699,6 +696,10 @@ var assets = func() http.FileSystem {
fs["/manager/patch-toleration.yaml"].(os.FileInfo),
fs["/manager/patch-watch-namespace-global.yaml"].(os.FileInfo),
}
+ fs["/manager/bundle"].(*vfsgen۰DirInfo).entries = []os.FileInfo{
+ fs["/manager/bundle/manifests"].(os.FileInfo),
+ fs["/manager/bundle/metadata"].(os.FileInfo),
+ }
fs["/prometheus"].(*vfsgen۰DirInfo).entries = []os.FileInfo{
fs["/prometheus/operator-pod-monitor.yaml"].(os.FileInfo),
fs["/prometheus/operator-prometheus-rule.yaml"].(os.FileInfo),
diff --git a/pkg/util/defaults/defaults.go b/pkg/util/defaults/defaults.go
index 0341b7afa..3afb9b8d5 100644
--- a/pkg/util/defaults/defaults.go
+++ b/pkg/util/defaults/defaults.go
@@ -40,9 +40,6 @@ const (
// LocalRepository --
LocalRepository = "/etc/maven/m2"
- // DefaultPVC --
- DefaultPVC = "camel-k-pvc"
-
// ImageName --
ImageName = "docker.io/apache/camel-k"
diff --git a/script/Makefile b/script/Makefile
index 25745eab1..d72b2fc3d 100644
--- a/script/Makefile
+++ b/script/Makefile
@@ -32,7 +32,6 @@ OPERATOR_SDK_VERSION := v1.28.0
KUSTOMIZE_VERSION := v4.5.4
OPM_VERSION := v1.24.0
BASE_IMAGE := eclipse-temurin:11
-DEFAULT_PVC := camel-k-pvc
LOCAL_REPOSITORY := /etc/maven/m2
IMAGE_NAME ?= docker.io/apache/camel-k
# Default value, change to your architecture accordingly
@@ -194,9 +193,6 @@ codegen:
@echo " // LocalRepository -- " >> $(VERSIONFILE)
@echo " LocalRepository = \"$(LOCAL_REPOSITORY)\"" >> $(VERSIONFILE)
@echo "" >> $(VERSIONFILE)
- @echo " // DefaultPVC -- " >> $(VERSIONFILE)
- @echo " DefaultPVC = \"$(DEFAULT_PVC)\"" >> $(VERSIONFILE)
- @echo "" >> $(VERSIONFILE)
@echo " // ImageName -- " >> $(VERSIONFILE)
@echo " ImageName = \"$(CUSTOM_IMAGE)\"" >> $(VERSIONFILE)
@echo "" >> $(VERSIONFILE)
@@ -651,7 +647,7 @@ bundle: set-version kustomize operator-sdk pre-bundle $(BUNDLE_CAMEL_APIS)
@# Sets the operator image to the preferred image:tag
@cd config/manifests && $(KUSTOMIZE) edit set image $(IMAGE_NAME)=$(CUSTOM_IMAGE):$(CUSTOM_VERSION)
@# Build kustomize manifests
- @INSTALL_DEFAULT_PVC=false $(KUSTOMIZE) build config/manifests | \
+ @$(KUSTOMIZE) build config/manifests | \
$(OPERATOR_SDK) generate bundle \
-q --overwrite --version $(OPERATOR_VERSION) \
--kustomize-dir config/manifests $(BUNDLE_METADATA_OPTS)