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 f04b2e132a1a931d2e8e8d8e65b27ce181e2bf5a
Author: Pasquale Congiusti <pasquale.congiu...@gmail.com>
AuthorDate: Wed Dec 4 21:17:18 2024 +0100

    feat(install): remove KEP 1755
    
    It complicates the installation procedure and it's not a Kubernetes GA 
feature.
---
 .../ROOT/pages/installation/installation.adoc      |  2 +-
 pkg/install/cluster.go                             |  7 --
 pkg/install/operator.go                            |  8 --
 pkg/platform/defaults.go                           | 10 ---
 pkg/resources/config/rbac/kustomization.yaml       |  6 --
 .../rbac/operator-cluster-role-local-registry.yaml | 28 -------
 .../rbac/operator-role-binding-local-registry.yaml | 31 -------
 pkg/trait/platform.go                              |  5 --
 pkg/util/registry/kep_1755.go                      | 98 ----------------------
 9 files changed, 1 insertion(+), 194 deletions(-)

diff --git a/docs/modules/ROOT/pages/installation/installation.adoc 
b/docs/modules/ROOT/pages/installation/installation.adoc
index 476f7ed96..d335d26e3 100644
--- a/docs/modules/ROOT/pages/installation/installation.adoc
+++ b/docs/modules/ROOT/pages/installation/installation.adoc
@@ -63,7 +63,7 @@ The operator is now up and running. However, there is a 
second step you need to
 
 The majority of configuration required to tune the operator are stored in an 
`IntegrationPlatform` custom resource. This is mainly required to provide 
configuration for the container registry, build time configuration or common 
profile you want to apply to all your `Integrations`.
 
-Camel K requires a container registry which is used to store the images built 
for your applications. Certain clusters may use their internal container 
registry (ie, Openshift, Minikube or 
https://github.com/kubernetes/enhancements/tree/master/keps/sig-cluster-lifecycle/generic/1755-communicating-a-local-registry[KEP-1755
 compatible] clusters).
+Camel K requires a container registry which is used to store the images built 
for your applications. Certain clusters may use their internal container 
registry (eg, Openshift, Minikube).
 
 **IMPORTANT:** You need to create an `IntegrationPlatform` with the following 
configuration in the namespace where the operator is running:
 
diff --git a/pkg/install/cluster.go b/pkg/install/cluster.go
index 9e56a2873..616392bec 100644
--- a/pkg/install/cluster.go
+++ b/pkg/install/cluster.go
@@ -93,13 +93,6 @@ func installClusterRoles(
                }
        }
 
-       // ClusterRole: camel-k-operator-local-registry
-       ok, err = isClusterRoleInstalled(ctx, c, 
"camel-k-operator-local-registry")
-       if err == nil && !ok {
-               // ignore errors
-               _ = installResource(ctx, c, collection, 
"/config/rbac/operator-cluster-role-local-registry.yaml")
-       }
-
        // === For OpenShift ===
        // ClusterRole: camel-k-operator-console-openshift
        isOpenShift, err := isOpenShift(c, clusterType)
diff --git a/pkg/install/operator.go b/pkg/install/operator.go
index 082cd9cc0..9728ce737 100644
--- a/pkg/install/operator.go
+++ b/pkg/install/operator.go
@@ -45,7 +45,6 @@ import (
        "github.com/apache/camel-k/v2/pkg/util/minikube"
        "github.com/apache/camel-k/v2/pkg/util/openshift"
        "github.com/apache/camel-k/v2/pkg/util/patch"
-       image "github.com/apache/camel-k/v2/pkg/util/registry"
 )
 
 type OperatorConfiguration struct {
@@ -634,13 +633,6 @@ func NewPlatform(
                        if err != nil {
                                return nil, err
                        }
-                       if address == nil {
-                               // try KEP-1755
-                               address, err = image.GetRegistryAddress(ctx, c)
-                               if err != nil {
-                                       return nil, err
-                               }
-                       }
 
                        if address == nil || *address == "" {
                                return nil, errors.New("cannot find a registry 
where to push images")
diff --git a/pkg/platform/defaults.go b/pkg/platform/defaults.go
index 8006d8cfe..930a926ce 100644
--- a/pkg/platform/defaults.go
+++ b/pkg/platform/defaults.go
@@ -35,7 +35,6 @@ import (
        "github.com/apache/camel-k/v2/pkg/util/defaults"
        "github.com/apache/camel-k/v2/pkg/util/log"
        "github.com/apache/camel-k/v2/pkg/util/openshift"
-       image "github.com/apache/camel-k/v2/pkg/util/registry"
 )
 
 const (
@@ -127,15 +126,6 @@ func configureRegistry(ctx context.Context, c 
client.Client, p *v1.IntegrationPl
                        return err
                }
        }
-       if p.Status.Build.Registry.Address == "" {
-               // try KEP-1755
-               address, err := image.GetRegistryAddress(ctx, c)
-               if err != nil && verbose {
-                       log.Error(err, "Cannot find a registry where to push 
images via KEP-1755")
-               } else if err == nil && address != nil {
-                       p.Status.Build.Registry.Address = *address
-               }
-       }
 
        log.Debugf("Final Registry Address: %s", 
p.Status.Build.Registry.Address)
        return nil
diff --git a/pkg/resources/config/rbac/kustomization.yaml 
b/pkg/resources/config/rbac/kustomization.yaml
index 43700a966..153db714f 100644
--- a/pkg/resources/config/rbac/kustomization.yaml
+++ b/pkg/resources/config/rbac/kustomization.yaml
@@ -27,12 +27,6 @@ resources:
 - operator-cluster-role-binding-custom-resource-definitions.yaml
 - operator-cluster-role-addressable-resolver.yaml
 - operator-cluster-role-binding-addressable-resolver.yaml
-- operator-cluster-role-local-registry.yaml
-- operator-role-binding-local-registry.yaml
-- builder-role.yaml
-- builder-role-openshift.yaml
-- builder-role-binding.yaml
-- builder-role-binding-openshift.yaml
 
 transformers:
 - |-
diff --git 
a/pkg/resources/config/rbac/operator-cluster-role-local-registry.yaml 
b/pkg/resources/config/rbac/operator-cluster-role-local-registry.yaml
deleted file mode 100644
index cb90a5fb4..000000000
--- a/pkg/resources/config/rbac/operator-cluster-role-local-registry.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.
-# ---------------------------------------------------------------------------
-
-kind: ClusterRole
-apiVersion: rbac.authorization.k8s.io/v1
-metadata:
-  name: camel-k-operator-local-registry
-  labels:
-    app: "camel-k"
-rules:
-  - apiGroups: [""]
-    resources: ["configmaps"]
-    resourceNames: ["local-registry-hosting"]
-    verbs: ["get"]
diff --git 
a/pkg/resources/config/rbac/operator-role-binding-local-registry.yaml 
b/pkg/resources/config/rbac/operator-role-binding-local-registry.yaml
deleted file mode 100644
index 8bff035de..000000000
--- a/pkg/resources/config/rbac/operator-role-binding-local-registry.yaml
+++ /dev/null
@@ -1,31 +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.
-# ---------------------------------------------------------------------------
-
-kind: RoleBinding
-apiVersion: rbac.authorization.k8s.io/v1
-metadata:
-  name: camel-k-operator-local-registry
-  namespace: kube-public
-  labels:
-    app: "camel-k"
-subjects:
-- kind: ServiceAccount
-  name: camel-k-operator
-roleRef:
-  kind: ClusterRole
-  name: camel-k-operator-local-registry
-  apiGroup: rbac.authorization.k8s.io
diff --git a/pkg/trait/platform.go b/pkg/trait/platform.go
index d129e4bca..15cb0d361 100644
--- a/pkg/trait/platform.go
+++ b/pkg/trait/platform.go
@@ -28,7 +28,6 @@ import (
        "github.com/apache/camel-k/v2/pkg/util/boolean"
        "github.com/apache/camel-k/v2/pkg/util/defaults"
        "github.com/apache/camel-k/v2/pkg/util/openshift"
-       image "github.com/apache/camel-k/v2/pkg/util/registry"
 )
 
 const (
@@ -66,10 +65,6 @@ func (t *platformTrait) Configure(e *Environment) (bool, 
*TraitCondition, error)
                        return false, nil, err
                } else if ocp {
                        t.createDefault = ptr.To(true)
-               } else if addr, err := image.GetRegistryAddress(e.Ctx, 
t.Client); err != nil {
-                       return false, nil, err
-               } else if addr != nil {
-                       t.createDefault = ptr.To(true)
                }
        }
 
diff --git a/pkg/util/registry/kep_1755.go b/pkg/util/registry/kep_1755.go
deleted file mode 100644
index f7783e8a3..000000000
--- a/pkg/util/registry/kep_1755.go
+++ /dev/null
@@ -1,98 +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.
-*/
-
-package registry
-
-import (
-       "context"
-
-       "github.com/apache/camel-k/v2/pkg/client"
-       "github.com/apache/camel-k/v2/pkg/util/log"
-       "gopkg.in/yaml.v2"
-       k8serrors "k8s.io/apimachinery/pkg/api/errors"
-       metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
-)
-
-// GetRegistryAddress KEP-1755
-// 
https://github.com/kubernetes/enhancements/tree/master/keps/sig-cluster-lifecycle/generic/1755-communicating-a-local-registry
-func GetRegistryAddress(ctx context.Context, c client.Client) (*string, error) 
{
-       config, err := c.CoreV1().ConfigMaps("kube-public").Get(ctx, 
"local-registry-hosting", metav1.GetOptions{})
-       if err != nil {
-               if k8serrors.IsForbidden(err) {
-                       log.Debug("Cannot access registry configuration 
local-registry-hosting ConfigMap", "error", err)
-                       return nil, nil
-               } else if k8serrors.IsNotFound(err) {
-                       log.Debug("Cannot find registry configuration 
local-registry-hosting ConfigMap", "error", err)
-                       return nil, nil
-               }
-               return nil, err
-       }
-       if data, ok := config.Data["localRegistryHosting.v1"]; ok {
-               result := LocalRegistryHostingV1{}
-               if err := yaml.Unmarshal([]byte(data), &result); err != nil {
-                       return nil, err
-               }
-               return &result.HostFromClusterNetwork, nil
-       }
-       return nil, nil
-}
-
-// Copied from 
https://github.com/kubernetes/enhancements/tree/master/keps/sig-cluster-lifecycle/generic/1755-communicating-a-local-registry
-// LocalRegistryHostingV1 describes a local registry that developer tools can
-// connect to. A local registry allows clients to load images into the local
-// cluster by pushing to this registry.
-type LocalRegistryHostingV1 struct {
-       // Host documents the host (hostname and port) of the registry, as seen 
from
-       // outside the cluster.
-       //
-       // This is the registry host that tools outside the cluster should push 
images
-       // to.
-       Host string `yaml:"host,omitempty"`
-
-       // HostFromClusterNetwork documents the host (hostname and port) of the
-       // registry, as seen from networking inside the container pods.
-       //
-       // This is the registry host that tools running on pods inside the 
cluster
-       // should push images to. If not set, then tools inside the cluster 
should
-       // assume the local registry is not available to them.
-       HostFromClusterNetwork string `yaml:"hostFromClusterNetwork,omitempty"`
-
-       // HostFromContainerRuntime documents the host (hostname and port) of 
the
-       // registry, as seen from the cluster's container runtime.
-       //
-       // When tools apply Kubernetes objects to the cluster, this host should 
be
-       // used for image name fields. If not set, users of this field should 
use the
-       // value of Host instead.
-       //
-       // Note that it doesn't make sense semantically to define this field, 
but not
-       // define Host or HostFromClusterNetwork. That would imply a way to pull
-       // images without a way to push images.
-       HostFromContainerRuntime string 
`yaml:"hostFromContainerRuntime,omitempty"`
-
-       // Help contains a URL pointing to documentation for users on how to set
-       // up and configure a local registry.
-       //
-       // Tools can use this to nudge users to enable the registry. When 
possible,
-       // the writer should use as permanent a URL as possible to prevent drift
-       // (e.g., a version control SHA).
-       //
-       // When image pushes to a registry host specified in one of the other 
fields
-       // fail, the tool should display this help URL to the user. The help URL
-       // should contain instructions on how to diagnose broken or 
misconfigured
-       // registries.
-       Help string `yaml:"help,omitempty"`
-}

Reply via email to