You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by lb...@apache.org on 2019/06/07 13:11:09 UTC

[camel-k] branch master updated (9e7a630 -> 8728513)

This is an automated email from the ASF dual-hosted git repository.

lburgazzoli pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git.


    from 9e7a630  chore(regen): regenerate defaults
     new f312d55  Fix #703: automatically configure global build strategy
     new ebf1d62  Fix #703: fix warming cache and affinity to work in global mode
     new 318c206  Fix #703: fix add reduced permissions to pod builder
     new cd71e8e  Fix #703: add initial SNAPSHOT CSV
     new 134d844  Fix #703: add CRDs to manifest
     new b2d2abd  Fix #703: fix olm
     new 8728513  Fix #703: add license headers

The 7 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 deploy/builder-role-binding.yaml                   |  13 +
 deploy/builder-role-kubernetes.yaml                |  34 ++
 deploy/builder-role-openshift.yaml                 |  78 +++++
 deploy/builder-service-account.yaml                |   6 +
 deploy/olm-catalog/camel-k.package.yaml            |   2 +-
 .../camel-k.v0.3.3.clusterserviceversion.yaml      |   0
 ...el-k.v0.3.4-SNAPSHOT.clusterserviceversion.yaml | 380 +++++++++++++++++++++
 .../camel-k/0.3.4-SNAPSHOT}/crd-build.yaml         |  17 -
 .../camel-k/0.3.4-SNAPSHOT/crd-camel-catalog.yaml  |  25 ++
 .../0.3.4-SNAPSHOT/crd-integration-context.yaml    |  32 ++
 .../0.3.4-SNAPSHOT/crd-integration-platform.yaml   |  24 ++
 .../camel-k/0.3.4-SNAPSHOT/crd-integration.yaml    |  28 ++
 deploy/olm-catalog/csv-config.yaml                 |   2 +-
 deploy/operator-role-kubernetes.yaml               |  15 +
 ...-role-openshift.yaml => operator-role-olm.yaml} |  72 +++-
 deploy/operator-role-openshift.yaml                |  15 +
 deploy/resources.go                                | 363 ++++++++++++++++++++
 pkg/builder/kaniko/publisher.go                    |  36 +-
 pkg/cmd/install.go                                 |  12 +-
 pkg/controller/build/schedule_pod.go               |  54 ++-
 pkg/controller/integrationplatform/initialize.go   |  32 +-
 pkg/install/builder.go                             |  58 ++++
 pkg/platform/operator.go                           |  41 ++-
 script/Makefile                                    |  10 +-
 script/{package_examples.sh => build_olm.sh}       |   9 +-
 .../{publish_base_images.sh => unsnapshot_olm.sh}  |  23 +-
 26 files changed, 1287 insertions(+), 94 deletions(-)
 create mode 100644 deploy/builder-role-binding.yaml
 create mode 100644 deploy/builder-role-kubernetes.yaml
 create mode 100644 deploy/builder-role-openshift.yaml
 create mode 100644 deploy/builder-service-account.yaml
 rename deploy/olm-catalog/{ => camel-k/0.3.3}/camel-k.v0.3.3.clusterserviceversion.yaml (100%)
 create mode 100644 deploy/olm-catalog/camel-k/0.3.4-SNAPSHOT/camel-k.v0.3.4-SNAPSHOT.clusterserviceversion.yaml
 copy deploy/{ => olm-catalog/camel-k/0.3.4-SNAPSHOT}/crd-build.yaml (51%)
 create mode 100644 deploy/olm-catalog/camel-k/0.3.4-SNAPSHOT/crd-camel-catalog.yaml
 create mode 100644 deploy/olm-catalog/camel-k/0.3.4-SNAPSHOT/crd-integration-context.yaml
 create mode 100644 deploy/olm-catalog/camel-k/0.3.4-SNAPSHOT/crd-integration-platform.yaml
 create mode 100644 deploy/olm-catalog/camel-k/0.3.4-SNAPSHOT/crd-integration.yaml
 copy deploy/{operator-role-openshift.yaml => operator-role-olm.yaml} (64%)
 create mode 100644 pkg/install/builder.go
 copy script/{package_examples.sh => build_olm.sh} (75%)
 copy script/{publish_base_images.sh => unsnapshot_olm.sh} (66%)


[camel-k] 04/07: Fix #703: add initial SNAPSHOT CSV

Posted by lb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

lburgazzoli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit cd71e8e2701dd9acda22021186ab6db65fef6c6f
Author: nferraro <ni...@gmail.com>
AuthorDate: Thu Jun 6 12:18:40 2019 +0200

    Fix #703: add initial SNAPSHOT CSV
---
 deploy/olm-catalog/camel-k.package.yaml            |   2 +-
 .../camel-k.v0.3.3.clusterserviceversion.yaml      |   0
 ...el-k.v0.3.4-SNAPSHOT.clusterserviceversion.yaml | 390 +++++++++++++++++++++
 deploy/olm-catalog/csv-config.yaml                 |   2 +-
 deploy/operator-role-olm.yaml                      | 182 ++++++++++
 deploy/resources.go                                | 186 ++++++++++
 script/Makefile                                    |  10 +-
 script/unsnapshot_olm.sh                           |  22 ++
 8 files changed, 790 insertions(+), 4 deletions(-)

diff --git a/deploy/olm-catalog/camel-k.package.yaml b/deploy/olm-catalog/camel-k.package.yaml
index 79967b8..e061dab 100644
--- a/deploy/olm-catalog/camel-k.package.yaml
+++ b/deploy/olm-catalog/camel-k.package.yaml
@@ -18,4 +18,4 @@
 packageName: camel-k
 channels:
 - name: alpha
-  currentCSV: camel-k-operator.v0.3.3
+  currentCSV: camel-k-operator.v0.3.4-SNAPSHOT
diff --git a/deploy/olm-catalog/camel-k.v0.3.3.clusterserviceversion.yaml b/deploy/olm-catalog/camel-k/0.3.3/camel-k.v0.3.3.clusterserviceversion.yaml
similarity index 100%
rename from deploy/olm-catalog/camel-k.v0.3.3.clusterserviceversion.yaml
rename to deploy/olm-catalog/camel-k/0.3.3/camel-k.v0.3.3.clusterserviceversion.yaml
diff --git a/deploy/olm-catalog/camel-k/0.3.4-SNAPSHOT/camel-k.v0.3.4-SNAPSHOT.clusterserviceversion.yaml b/deploy/olm-catalog/camel-k/0.3.4-SNAPSHOT/camel-k.v0.3.4-SNAPSHOT.clusterserviceversion.yaml
new file mode 100644
index 0000000..9718838
--- /dev/null
+++ b/deploy/olm-catalog/camel-k/0.3.4-SNAPSHOT/camel-k.v0.3.4-SNAPSHOT.clusterserviceversion.yaml
@@ -0,0 +1,390 @@
+apiVersion: operators.coreos.com/v1alpha1
+kind: ClusterServiceVersion
+metadata:
+  annotations:
+    alm-examples: |-
+      [{
+        "apiVersion": "camel.apache.org/v1alpha1",
+        "kind": "IntegrationPlatform",
+        "metadata": {
+          "name": "example"
+        },
+        "spec": {
+          "build": {
+            "buildStrategy": "pod"
+          },
+          "resources": {
+            "contexts": [
+              "jvm"
+            ]
+          }
+        }
+      },
+      {
+        "apiVersion": "camel.apache.org/v1alpha1",
+        "kind": "Integration",
+        "metadata": {
+          "name": "example"
+        },
+        "spec": {
+          "source": {
+            "content": "// Add example Java code to create Integration",
+            "name": "Example.java"
+          }
+        }
+      },
+      {
+        "apiVersion": "camel.apache.org/v1alpha1",
+        "kind": "IntegrationContext",
+        "metadata": {
+          "name": "example"
+        }
+      },
+      {
+        "apiVersion": "camel.apache.org/v1alpha1",
+        "kind": "CamelCatalog",
+        "metadata": {
+          "name": "example"
+        }
+      },
+      {
+        "apiVersion": "camel.apache.org/v1alpha1",
+        "kind": "Build",
+        "metadata": {
+          "name": "example"
+        }
+      }]
+    capabilities: Basic Install
+    categories: Integration & Delivery
+    certified: "false"
+    containerImage: docker.io/apache/camel-k:0.3.4-SNAPSHOT
+    createdAt: "2019-05-06T16:45:00Z"
+    description: Apache Camel K is a lightweight integration platform, born on Kubernetes,
+      with serverless superpowers.
+    repository: https://github.com/apache/camel-k
+    support: Camel
+  name: camel-k-operator.v0.3.4-SNAPSHOT
+  namespace: placeholder
+spec:
+  apiservicedefinitions: {}
+  customresourcedefinitions:
+    owned:
+    - description: A Camel K build
+      displayName: Build
+      kind: Build
+      name: builds.camel.apache.org
+      version: v1alpha1
+    - description: A Camel catalog
+      displayName: Camel Catalog
+      kind: CamelCatalog
+      name: camelcatalogs.camel.apache.org
+      version: v1alpha1
+    - description: A Camel K integration
+      displayName: Integration
+      kind: Integration
+      name: integrations.camel.apache.org
+      version: v1alpha1
+    - description: A Camel K integration context
+      displayName: Integration Context
+      kind: IntegrationContext
+      name: integrationcontexts.camel.apache.org
+      version: v1alpha1
+    - description: A Camel K integration platform
+      displayName: Integration Platform
+      kind: IntegrationPlatform
+      name: integrationplatforms.camel.apache.org
+      version: v1alpha1
+  description: |
+    Apache Camel K
+    ==============
+
+    Apache Camel K is a lightweight integration platform, born on Kubernetes, with serverless superpowers.
+
+    ## Installation
+
+    To start using Camel K, install the operator and then create the following `IntegrationPlatform`:
+    ```
+    apiVersion: camel.apache.org/v1alpha1
+    kind: IntegrationPlatform
+    metadata:
+      name: camel-k
+      labels:
+        app: "camel-k"
+    ```
+
+    ## Running an Integration
+
+    After the initial setup, you can run a Camel integration on the cluster by creating an example `Integration`:
+    ```
+    apiVersion: camel.apache.org/v1alpha1
+    kind: Integration
+    metadata:
+      name: example
+    spec:
+      sources:
+      - content: |
+        import org.apache.camel.builder.RouteBuilder;
+
+        public class Example extends RouteBuilder {
+            @Override
+            public void configure() throws Exception {
+                from("timer:tick")
+                    .setBody(constant("Hello World!"))
+                .to("log:info?skipBodyLineSeparator=false");
+            }
+        }
+      name: Example.java
+    ```
+  displayName: Camel K Operator
+  icon:
+  - base64data: PHN2ZyB2aWV3Qm94PSIwIDAgMTMwLjIxIDEzMC4wMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZGVmcz48bGluZWFyR3JhZGllbnQgaWQ9ImEiIHgxPSIzMzMuNDgiIHgyPSI0NzciIHkxPSI3MDIuNiIgeTI9IjU2My43MyIgZ3JhZGllbnRUcmFuc2Zvcm09InRyYW5zbGF0ZSg5NC4wMzggMjc2LjA2KSBzY2FsZSguOTkyMDYpIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSI+PHN0b3Agc3RvcC1jb2xvcj0iI0Y2OTkyMyIgb2Zmc2V0PSIwIi8+PHN0b3Agc3RvcC1jb2xvcj0iI0Y3OUEyMyIgb2Zmc2V0PSIuMTEiLz48c3RvcCBzdG9wLWNvbG9yPSIjRTk3ODI2IiBvZmZzZXQ9Ii45NDUiLz48L2xp [...]
+    mediatype: image/svg+xml
+  install:
+    spec:
+      deployments:
+      - name: camel-k-operator
+        spec:
+          replicas: 1
+          selector:
+            matchLabels:
+              name: camel-k-operator
+          strategy:
+            type: Recreate
+          template:
+            metadata:
+              labels:
+                camel.apache.org/component: operator
+                name: camel-k-operator
+            spec:
+              containers:
+              - command:
+                - camel-k
+                env:
+                - name: WATCH_NAMESPACE
+                  valueFrom:
+                    fieldRef:
+                      fieldPath: metadata.namespace
+                - name: OPERATOR_NAME
+                  value: camel-k
+                - name: POD_NAME
+                  valueFrom:
+                    fieldRef:
+                      fieldPath: metadata.name
+                - name: NAMESPACE
+                  valueFrom:
+                    fieldRef:
+                      fieldPath: metadata.namespace
+                image: docker.io/apache/camel-k:0.3.4-SNAPSHOT
+                imagePullPolicy: IfNotPresent
+                name: camel-k-operator
+                resources: {}
+              serviceAccountName: camel-k-operator
+      permissions:
+      - rules:
+        - apiGroups:
+          - camel.apache.org
+          resources:
+          - '*'
+          verbs:
+          - '*'
+        - apiGroups:
+          - ""
+          resources:
+          - pods
+          - services
+          - endpoints
+          - persistentvolumeclaims
+          - configmaps
+          - secrets
+          - serviceaccounts
+          verbs:
+          - create
+          - delete
+          - deletecollection
+          - get
+          - list
+          - patch
+          - update
+          - watch
+        - apiGroups:
+          - rbac.authorization.k8s.io
+          resources:
+          - roles
+          - rolebindings
+          verbs:
+          - create
+          - delete
+          - deletecollection
+          - get
+          - list
+          - patch
+          - update
+          - watch
+        - apiGroups:
+          - ""
+          resources:
+          - events
+          verbs:
+          - get
+          - list
+          - watch
+        - apiGroups:
+          - apps
+          resources:
+          - deployments
+          - replicasets
+          - statefulsets
+          verbs:
+          - create
+          - delete
+          - deletecollection
+          - get
+          - list
+          - patch
+          - update
+          - watch
+        - apiGroups:
+          - apps
+          resources:
+          - daemonsets
+          verbs:
+          - get
+          - list
+          - watch
+        - apiGroups:
+          - extensions
+          resources:
+          - ingresses
+          verbs:
+          - create
+          - delete
+          - deletecollection
+          - get
+          - list
+          - patch
+          - update
+          - watch
+        - apiGroups:
+          - ""
+          - build.openshift.io
+          resources:
+          - buildconfigs
+          - buildconfigs/webhooks
+          - builds
+          verbs:
+          - create
+          - delete
+          - deletecollection
+          - get
+          - list
+          - patch
+          - update
+          - watch
+        - apiGroups:
+          - ""
+          - image.openshift.io
+          resources:
+          - imagestreamimages
+          - imagestreammappings
+          - imagestreams
+          - imagestreams/secrets
+          - imagestreamtags
+          verbs:
+          - create
+          - delete
+          - deletecollection
+          - get
+          - list
+          - patch
+          - update
+          - watch
+        - apiGroups:
+          - ""
+          - build.openshift.io
+          resources:
+          - buildconfigs/instantiate
+          - buildconfigs/instantiatebinary
+          - builds/clone
+          verbs:
+          - create
+        - apiGroups:
+          - ""
+          - route.openshift.io
+          resources:
+          - routes
+          verbs:
+          - create
+          - delete
+          - deletecollection
+          - get
+          - list
+          - patch
+          - update
+          - watch
+        - apiGroups:
+          - ""
+          - route.openshift.io
+          resources:
+          - routes/custom-host
+          verbs:
+          - create
+        - apiGroups:
+          - serving.knative.dev
+          resources:
+          - '*'
+          verbs:
+          - create
+          - delete
+          - deletecollection
+          - get
+          - list
+          - patch
+          - update
+          - watch
+        - apiGroups:
+          - eventing.knative.dev
+          resources:
+          - '*'
+          verbs:
+          - create
+          - delete
+          - deletecollection
+          - get
+          - list
+          - patch
+          - update
+          - watch
+        serviceAccountName: camel-k-operator
+    strategy: deployment
+  installModes:
+  - supported: true
+    type: OwnNamespace
+  - supported: true
+    type: SingleNamespace
+  - supported: false
+    type: MultiNamespace
+  - supported: true
+    type: AllNamespaces
+  keywords:
+  - apache
+  - kamel
+  - kubernetes
+  - serverless
+  - microservices
+  labels:
+    name: camel-k-operator
+  links:
+  - name: Camel K source code repository
+    url: https://github.com/apache/camel-k
+  maintainers:
+  - email: users@camel.apache.org
+    name: The Apache Software Foundation
+  maturity: alpha
+  minKubeVersion: 1.11.0
+  provider:
+    name: The Apache Software Foundation
+  replaces: camel-k.v0.3.3
+  selector:
+    matchLabels:
+      name: camel-k-operator
+  version: 0.3.4-SNAPSHOT
diff --git a/deploy/olm-catalog/csv-config.yaml b/deploy/olm-catalog/csv-config.yaml
index 76cca94..6a2abb7 100644
--- a/deploy/olm-catalog/csv-config.yaml
+++ b/deploy/olm-catalog/csv-config.yaml
@@ -22,4 +22,4 @@ crd-cr-paths:
   - deploy/crd-integration.yaml
   - deploy/crd-integration-context.yaml
   - deploy/crd-integration-platform.yaml
-role-path: deploy/operator-role-kubernetes.yaml
+role-path: deploy/operator-role-olm.yaml
diff --git a/deploy/operator-role-olm.yaml b/deploy/operator-role-olm.yaml
new file mode 100644
index 0000000..ca1ee2f
--- /dev/null
+++ b/deploy/operator-role-olm.yaml
@@ -0,0 +1,182 @@
+kind: Role
+apiVersion: rbac.authorization.k8s.io/v1beta1
+metadata:
+  name: camel-k-operator
+  labels:
+    app: "camel-k"
+rules:
+- apiGroups:
+  - camel.apache.org
+  resources:
+  - "*"
+  verbs:
+  - "*"
+- apiGroups:
+  - ""
+  resources:
+  - pods
+  - services
+  - endpoints
+  - persistentvolumeclaims
+  - configmaps
+  - secrets
+  - serviceaccounts
+  verbs:
+  - create
+  - delete
+  - deletecollection
+  - get
+  - list
+  - patch
+  - update
+  - watch
+- apiGroups:
+  - rbac.authorization.k8s.io
+  resources:
+  - roles
+  - rolebindings
+  verbs:
+  - create
+  - delete
+  - deletecollection
+  - get
+  - list
+  - patch
+  - update
+  - watch
+- apiGroups:
+  - ""
+  resources:
+  - events
+  verbs:
+  - get
+  - list
+  - watch
+- apiGroups:
+  - apps
+  resources:
+  - deployments
+  - replicasets
+  - statefulsets
+  verbs:
+  - create
+  - delete
+  - deletecollection
+  - get
+  - list
+  - patch
+  - update
+  - watch
+- apiGroups:
+  - apps
+  attributeRestrictions: null
+  resources:
+  - daemonsets
+  verbs:
+  - get
+  - list
+  - watch
+- apiGroups:
+  - extensions
+  resources:
+  - ingresses
+  verbs:
+  - create
+  - delete
+  - deletecollection
+  - get
+  - list
+  - patch
+  - update
+  - watch
+- apiGroups:
+  - ""
+  - "build.openshift.io"
+  resources:
+  - buildconfigs
+  - buildconfigs/webhooks
+  - builds
+  verbs:
+  - create
+  - delete
+  - deletecollection
+  - get
+  - list
+  - patch
+  - update
+  - watch
+- apiGroups:
+  - ""
+  - "image.openshift.io"
+  resources:
+  - imagestreamimages
+  - imagestreammappings
+  - imagestreams
+  - imagestreams/secrets
+  - imagestreamtags
+  verbs:
+  - create
+  - delete
+  - deletecollection
+  - get
+  - list
+  - patch
+  - update
+  - watch
+- apiGroups:
+  - ""
+  - build.openshift.io
+  attributeRestrictions: null
+  resources:
+  - buildconfigs/instantiate
+  - buildconfigs/instantiatebinary
+  - builds/clone
+  verbs:
+  - create
+- apiGroups:
+  - ""
+  - "route.openshift.io"
+  resources:
+  - routes
+  verbs:
+  - create
+  - delete
+  - deletecollection
+  - get
+  - list
+  - patch
+  - update
+  - watch
+- apiGroups:
+  - ""
+  - route.openshift.io
+  resources:
+  - routes/custom-host
+  verbs:
+  - create
+- apiGroups:
+  - serving.knative.dev
+  resources:
+  - "*"
+  verbs:
+  - create
+  - delete
+  - deletecollection
+  - get
+  - list
+  - patch
+  - update
+  - watch
+- apiGroups:
+  - eventing.knative.dev
+  resources:
+  - "*"
+  verbs:
+  - create
+  - delete
+  - deletecollection
+  - get
+  - list
+  - patch
+  - update
+  - watch
diff --git a/deploy/resources.go b/deploy/resources.go
index 1c85319..c328be0 100644
--- a/deploy/resources.go
+++ b/deploy/resources.go
@@ -11033,6 +11033,192 @@ rules:
   - watch
 
 `
+	Resources["operator-role-olm.yaml"] =
+		`
+kind: Role
+apiVersion: rbac.authorization.k8s.io/v1beta1
+metadata:
+  name: camel-k-operator
+  labels:
+    app: "camel-k"
+rules:
+- apiGroups:
+  - camel.apache.org
+  resources:
+  - "*"
+  verbs:
+  - "*"
+- apiGroups:
+  - ""
+  resources:
+  - pods
+  - services
+  - endpoints
+  - persistentvolumeclaims
+  - configmaps
+  - secrets
+  - serviceaccounts
+  verbs:
+  - create
+  - delete
+  - deletecollection
+  - get
+  - list
+  - patch
+  - update
+  - watch
+- apiGroups:
+  - rbac.authorization.k8s.io
+  resources:
+  - roles
+  - rolebindings
+  verbs:
+  - create
+  - delete
+  - deletecollection
+  - get
+  - list
+  - patch
+  - update
+  - watch
+- apiGroups:
+  - ""
+  resources:
+  - events
+  verbs:
+  - get
+  - list
+  - watch
+- apiGroups:
+  - apps
+  resources:
+  - deployments
+  - replicasets
+  - statefulsets
+  verbs:
+  - create
+  - delete
+  - deletecollection
+  - get
+  - list
+  - patch
+  - update
+  - watch
+- apiGroups:
+  - apps
+  attributeRestrictions: null
+  resources:
+  - daemonsets
+  verbs:
+  - get
+  - list
+  - watch
+- apiGroups:
+  - extensions
+  resources:
+  - ingresses
+  verbs:
+  - create
+  - delete
+  - deletecollection
+  - get
+  - list
+  - patch
+  - update
+  - watch
+- apiGroups:
+  - ""
+  - "build.openshift.io"
+  resources:
+  - buildconfigs
+  - buildconfigs/webhooks
+  - builds
+  verbs:
+  - create
+  - delete
+  - deletecollection
+  - get
+  - list
+  - patch
+  - update
+  - watch
+- apiGroups:
+  - ""
+  - "image.openshift.io"
+  resources:
+  - imagestreamimages
+  - imagestreammappings
+  - imagestreams
+  - imagestreams/secrets
+  - imagestreamtags
+  verbs:
+  - create
+  - delete
+  - deletecollection
+  - get
+  - list
+  - patch
+  - update
+  - watch
+- apiGroups:
+  - ""
+  - build.openshift.io
+  attributeRestrictions: null
+  resources:
+  - buildconfigs/instantiate
+  - buildconfigs/instantiatebinary
+  - builds/clone
+  verbs:
+  - create
+- apiGroups:
+  - ""
+  - "route.openshift.io"
+  resources:
+  - routes
+  verbs:
+  - create
+  - delete
+  - deletecollection
+  - get
+  - list
+  - patch
+  - update
+  - watch
+- apiGroups:
+  - ""
+  - route.openshift.io
+  resources:
+  - routes/custom-host
+  verbs:
+  - create
+- apiGroups:
+  - serving.knative.dev
+  resources:
+  - "*"
+  verbs:
+  - create
+  - delete
+  - deletecollection
+  - get
+  - list
+  - patch
+  - update
+  - watch
+- apiGroups:
+  - eventing.knative.dev
+  resources:
+  - "*"
+  verbs:
+  - create
+  - delete
+  - deletecollection
+  - get
+  - list
+  - patch
+  - update
+  - watch
+
+`
 	Resources["operator-role-openshift.yaml"] =
 		`
 kind: Role
diff --git a/script/Makefile b/script/Makefile
index 70ff17e..030b4bb 100644
--- a/script/Makefile
+++ b/script/Makefile
@@ -114,6 +114,9 @@ build-resources:
 	./script/embed_resources.sh deploy
 	go run cmd/util/json-schema-gen/jsonschemagen.go --out=./assets/json-schema
 
+build-olm:
+	operator-sdk olm-catalog gen-csv --csv-version $(VERSION) --csv-config deploy/olm-catalog/csv-config.yaml --update-crds
+
 build-compile-integration-tests:
 	go test -c -tags=integration ./test/*.go
 
@@ -179,11 +182,14 @@ package-examples:
 package-artifacts:
 	./script/package_maven_artifacts.sh $(RUNTIME_VERSION)
 
-release: clean codegen set-version build-resources build images images-push cross-compile package-examples git-tag
+unsnapshot-olm:
+	./script/unsnapshot_olm.sh
+
+release: clean codegen set-version build-resources unsnapshot-olm build images images-push cross-compile package-examples git-tag
 
 install-minishift:
 	./script/install_minishift.sh
 install-minikube:
 	./script/install_minikube.sh
 
-.PHONY: build build-operator build-kamel build-resources build-builder dep codegen images images-dec images-push test check test-integration clean release cross-compile package-examples set-version git-tag
+.PHONY: build build-operator build-kamel build-resources build-builder build-olm unsnapshot-olm dep codegen images images-dec images-push test check test-integration clean release cross-compile package-examples set-version git-tag
diff --git a/script/unsnapshot_olm.sh b/script/unsnapshot_olm.sh
new file mode 100755
index 0000000..4af2774
--- /dev/null
+++ b/script/unsnapshot_olm.sh
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+# Prefer unsnapshotting to regenerating, because changes done to snapshot file may get lost
+
+location=$(dirname $0)
+olm_catalog=${location}/../deploy/olm-catalog
+
+
+for d in $(find ${olm_catalog} -type d -name "*-SNAPSHOT*");
+do
+  mv ${d} ${d//-SNAPSHOT/}
+done
+
+for f in $(find ${olm_catalog} -type f -name "*-SNAPSHOT*");
+do
+  mv ${f} ${f//-SNAPSHOT/}
+done
+
+for f in $(find ${olm_catalog} -type f);
+do
+  sed -i 's/-SNAPSHOT//g' $f
+done


[camel-k] 03/07: Fix #703: fix add reduced permissions to pod builder

Posted by lb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

lburgazzoli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit 318c20667ddd464cb52831b8a14655d1c6a00d0a
Author: nferraro <ni...@gmail.com>
AuthorDate: Wed Jun 5 17:19:48 2019 +0200

    Fix #703: fix add reduced permissions to pod builder
---
 deploy/builder-role-binding.yaml              |  13 ++
 deploy/builder-role-kubernetes.yaml           |  34 +++++
 deploy/builder-role-openshift.yaml            |  78 ++++++++++++
 deploy/builder-service-account.yaml           |   6 +
 deploy/operator-role-kubernetes.yaml          |  12 ++
 deploy/operator-role-openshift.yaml           |  12 ++
 deploy/resources.go                           | 171 ++++++++++++++++++++++++++
 pkg/controller/build/schedule_pod.go          |   6 +-
 pkg/install/{serviceaccount.go => builder.go} |  33 ++---
 9 files changed, 341 insertions(+), 24 deletions(-)

diff --git a/deploy/builder-role-binding.yaml b/deploy/builder-role-binding.yaml
new file mode 100644
index 0000000..0217c79
--- /dev/null
+++ b/deploy/builder-role-binding.yaml
@@ -0,0 +1,13 @@
+kind: RoleBinding
+apiVersion: rbac.authorization.k8s.io/v1beta1
+metadata:
+  name: camel-k-builder
+  labels:
+    app: "camel-k"
+subjects:
+- kind: ServiceAccount
+  name: camel-k-builder
+roleRef:
+  kind: Role
+  name: camel-k-builder
+  apiGroup: rbac.authorization.k8s.io
diff --git a/deploy/builder-role-kubernetes.yaml b/deploy/builder-role-kubernetes.yaml
new file mode 100644
index 0000000..e3ee33e
--- /dev/null
+++ b/deploy/builder-role-kubernetes.yaml
@@ -0,0 +1,34 @@
+kind: Role
+apiVersion: rbac.authorization.k8s.io/v1beta1
+metadata:
+  name: camel-k-builder
+  labels:
+    app: "camel-k"
+rules:
+- apiGroups:
+  - camel.apache.org
+  resources:
+  - "*"
+  verbs:
+  - "*"
+- apiGroups:
+  - ""
+  resources:
+  - pods
+  verbs:
+  - create
+  - delete
+  - deletecollection
+  - get
+  - list
+  - patch
+  - update
+  - watch
+- apiGroups:
+  - ""
+  resources:
+  - events
+  verbs:
+  - get
+  - list
+  - watch
diff --git a/deploy/builder-role-openshift.yaml b/deploy/builder-role-openshift.yaml
new file mode 100644
index 0000000..ad92516
--- /dev/null
+++ b/deploy/builder-role-openshift.yaml
@@ -0,0 +1,78 @@
+kind: Role
+apiVersion: rbac.authorization.k8s.io/v1beta1
+metadata:
+  name: camel-k-builder
+  labels:
+    app: "camel-k"
+rules:
+- apiGroups:
+  - camel.apache.org
+  resources:
+  - "*"
+  verbs:
+  - "*"
+- apiGroups:
+  - ""
+  resources:
+  - pods
+  verbs:
+  - create
+  - delete
+  - deletecollection
+  - get
+  - list
+  - patch
+  - update
+  - watch
+- apiGroups:
+  - ""
+  resources:
+  - events
+  verbs:
+  - get
+  - list
+  - watch
+- apiGroups:
+  - ""
+  - "build.openshift.io"
+  resources:
+  - buildconfigs
+  - buildconfigs/webhooks
+  - builds
+  verbs:
+  - create
+  - delete
+  - deletecollection
+  - get
+  - list
+  - patch
+  - update
+  - watch
+- apiGroups:
+  - ""
+  - "image.openshift.io"
+  resources:
+  - imagestreamimages
+  - imagestreammappings
+  - imagestreams
+  - imagestreams/secrets
+  - imagestreamtags
+  verbs:
+  - create
+  - delete
+  - deletecollection
+  - get
+  - list
+  - patch
+  - update
+  - watch
+- apiGroups:
+  - ""
+  - build.openshift.io
+  attributeRestrictions: null
+  resources:
+  - buildconfigs/instantiate
+  - buildconfigs/instantiatebinary
+  - builds/clone
+  verbs:
+  - create
diff --git a/deploy/builder-service-account.yaml b/deploy/builder-service-account.yaml
new file mode 100644
index 0000000..7499e4f
--- /dev/null
+++ b/deploy/builder-service-account.yaml
@@ -0,0 +1,6 @@
+apiVersion: v1
+kind: ServiceAccount
+metadata:
+  name: camel-k-builder
+  labels:
+    app: "camel-k"
diff --git a/deploy/operator-role-kubernetes.yaml b/deploy/operator-role-kubernetes.yaml
index 5b44671..3ec172a 100644
--- a/deploy/operator-role-kubernetes.yaml
+++ b/deploy/operator-role-kubernetes.yaml
@@ -38,6 +38,18 @@ rules:
   - configmaps
   - secrets
   - serviceaccounts
+  verbs:
+  - create
+  - delete
+  - deletecollection
+  - get
+  - list
+  - patch
+  - update
+  - watch
+- apiGroups:
+  - rbac.authorization.k8s.io
+  resources:
   - roles
   - rolebindings
   verbs:
diff --git a/deploy/operator-role-openshift.yaml b/deploy/operator-role-openshift.yaml
index ea12152..6921e65 100644
--- a/deploy/operator-role-openshift.yaml
+++ b/deploy/operator-role-openshift.yaml
@@ -38,6 +38,18 @@ rules:
   - configmaps
   - secrets
   - serviceaccounts
+  verbs:
+  - create
+  - delete
+  - deletecollection
+  - get
+  - list
+  - patch
+  - update
+  - watch
+- apiGroups:
+  - rbac.authorization.k8s.io
+  resources:
   - roles
   - rolebindings
   verbs:
diff --git a/deploy/resources.go b/deploy/resources.go
index cc87284..1c85319 100644
--- a/deploy/resources.go
+++ b/deploy/resources.go
@@ -24,6 +24,153 @@ var Resources map[string]string
 func init() {
 	Resources = make(map[string]string)
 
+	Resources["builder-role-binding.yaml"] =
+		`
+kind: RoleBinding
+apiVersion: rbac.authorization.k8s.io/v1beta1
+metadata:
+  name: camel-k-builder
+  labels:
+    app: "camel-k"
+subjects:
+- kind: ServiceAccount
+  name: camel-k-builder
+roleRef:
+  kind: Role
+  name: camel-k-builder
+  apiGroup: rbac.authorization.k8s.io
+
+`
+	Resources["builder-role-kubernetes.yaml"] =
+		`
+kind: Role
+apiVersion: rbac.authorization.k8s.io/v1beta1
+metadata:
+  name: camel-k-builder
+  labels:
+    app: "camel-k"
+rules:
+- apiGroups:
+  - camel.apache.org
+  resources:
+  - "*"
+  verbs:
+  - "*"
+- apiGroups:
+  - ""
+  resources:
+  - pods
+  verbs:
+  - create
+  - delete
+  - deletecollection
+  - get
+  - list
+  - patch
+  - update
+  - watch
+- apiGroups:
+  - ""
+  resources:
+  - events
+  verbs:
+  - get
+  - list
+  - watch
+
+`
+	Resources["builder-role-openshift.yaml"] =
+		`
+kind: Role
+apiVersion: rbac.authorization.k8s.io/v1beta1
+metadata:
+  name: camel-k-builder
+  labels:
+    app: "camel-k"
+rules:
+- apiGroups:
+  - camel.apache.org
+  resources:
+  - "*"
+  verbs:
+  - "*"
+- apiGroups:
+  - ""
+  resources:
+  - pods
+  verbs:
+  - create
+  - delete
+  - deletecollection
+  - get
+  - list
+  - patch
+  - update
+  - watch
+- apiGroups:
+  - ""
+  resources:
+  - events
+  verbs:
+  - get
+  - list
+  - watch
+- apiGroups:
+  - ""
+  - "build.openshift.io"
+  resources:
+  - buildconfigs
+  - buildconfigs/webhooks
+  - builds
+  verbs:
+  - create
+  - delete
+  - deletecollection
+  - get
+  - list
+  - patch
+  - update
+  - watch
+- apiGroups:
+  - ""
+  - "image.openshift.io"
+  resources:
+  - imagestreamimages
+  - imagestreammappings
+  - imagestreams
+  - imagestreams/secrets
+  - imagestreamtags
+  verbs:
+  - create
+  - delete
+  - deletecollection
+  - get
+  - list
+  - patch
+  - update
+  - watch
+- apiGroups:
+  - ""
+  - build.openshift.io
+  attributeRestrictions: null
+  resources:
+  - buildconfigs/instantiate
+  - buildconfigs/instantiatebinary
+  - builds/clone
+  verbs:
+  - create
+
+`
+	Resources["builder-service-account.yaml"] =
+		`
+apiVersion: v1
+kind: ServiceAccount
+metadata:
+  name: camel-k-builder
+  labels:
+    app: "camel-k"
+
+`
 	Resources["camel-catalog-2.23.0.yaml"] =
 		`
 apiVersion: camel.apache.org/v1alpha1
@@ -10816,6 +10963,18 @@ rules:
   - configmaps
   - secrets
   - serviceaccounts
+  verbs:
+  - create
+  - delete
+  - deletecollection
+  - get
+  - list
+  - patch
+  - update
+  - watch
+- apiGroups:
+  - rbac.authorization.k8s.io
+  resources:
   - roles
   - rolebindings
   verbs:
@@ -10899,6 +11058,18 @@ rules:
   - configmaps
   - secrets
   - serviceaccounts
+  verbs:
+  - create
+  - delete
+  - deletecollection
+  - get
+  - list
+  - patch
+  - update
+  - watch
+- apiGroups:
+  - rbac.authorization.k8s.io
+  resources:
   - roles
   - rolebindings
   verbs:
diff --git a/pkg/controller/build/schedule_pod.go b/pkg/controller/build/schedule_pod.go
index ee84c54..801d84c 100644
--- a/pkg/controller/build/schedule_pod.go
+++ b/pkg/controller/build/schedule_pod.go
@@ -131,14 +131,14 @@ func (action *schedulePodAction) Handle(ctx context.Context, build *v1alpha1.Bui
 func (action *schedulePodAction) ensureServiceAccount(ctx context.Context, buildPod *corev1.Pod) error {
 	sa := corev1.ServiceAccount{}
 	saKey := k8sclient.ObjectKey{
-		Name:      "camel-k-operator",
+		Name:      "camel-k-builder",
 		Namespace: buildPod.Namespace,
 	}
 
 	err := action.client.Get(ctx, saKey, &sa)
 	if err != nil && k8serrors.IsNotFound(err) {
 		// Create a proper service account
-		return install.ServiceAccountRoles(ctx, action.client, buildPod.Namespace)
+		return install.BuilderServiceAccountRoles(ctx, action.client, buildPod.Namespace)
 	}
 	return err
 }
@@ -161,7 +161,7 @@ func newBuildPod(build *v1alpha1.Build, operatorImage string) *corev1.Pod {
 			},
 		},
 		Spec: corev1.PodSpec{
-			ServiceAccountName: "camel-k-operator",
+			ServiceAccountName: "camel-k-builder",
 			Containers: []corev1.Container{
 				{
 					Name:            "builder",
diff --git a/pkg/install/serviceaccount.go b/pkg/install/builder.go
similarity index 55%
rename from pkg/install/serviceaccount.go
rename to pkg/install/builder.go
index 7a9cf9f..27a1488 100644
--- a/pkg/install/serviceaccount.go
+++ b/pkg/install/builder.go
@@ -20,48 +20,39 @@ package install
 import (
 	"context"
 	"github.com/apache/camel-k/pkg/client"
-	"github.com/apache/camel-k/pkg/util/knative"
 	"github.com/apache/camel-k/pkg/util/openshift"
 )
 
-// ServiceAccountRoles installs the service account and related roles in the given namespace
-func ServiceAccountRoles(ctx context.Context, c client.Client, namespace string) error {
+// BuilderServiceAccountRoles installs the builder service account and related roles in the given namespace
+func BuilderServiceAccountRoles(ctx context.Context, c client.Client, namespace string) error {
 	isOpenshift, err := openshift.IsOpenShift(c)
 	if err != nil {
 		return err
 	}
 	if isOpenshift {
-		if err := installServiceAccountRolesOpenshift(ctx, c, namespace); err != nil {
+		if err := installBuilderServiceAccountRolesOpenshift(ctx, c, namespace); err != nil {
 			return err
 		}
 	} else {
-		if err := installServiceAccountRolesKubernetes(ctx, c, namespace); err != nil {
+		if err := installBuilderServiceAccountRolesKubernetes(ctx, c, namespace); err != nil {
 			return err
 		}
 	}
-	// Install Knative resources if required
-	isKnative, err := knative.IsInstalled(ctx, c)
-	if err != nil {
-		return err
-	}
-	if isKnative {
-		return installKnative(ctx, c, namespace, nil)
-	}
 	return nil
 }
 
-func installServiceAccountRolesOpenshift(ctx context.Context, c client.Client, namespace string) error {
+func installBuilderServiceAccountRolesOpenshift(ctx context.Context, c client.Client, namespace string) error {
 	return ResourcesOrCollect(ctx, c, namespace, nil, IdentityResourceCustomizer,
-		"operator-service-account.yaml",
-		"operator-role-openshift.yaml",
-		"operator-role-binding.yaml",
+		"builder-service-account.yaml",
+		"builder-role-openshift.yaml",
+		"builder-role-binding.yaml",
 	)
 }
 
-func installServiceAccountRolesKubernetes(ctx context.Context, c client.Client, namespace string) error {
+func installBuilderServiceAccountRolesKubernetes(ctx context.Context, c client.Client, namespace string) error {
 	return ResourcesOrCollect(ctx, c, namespace, nil, IdentityResourceCustomizer,
-		"operator-service-account.yaml",
-		"operator-role-kubernetes.yaml",
-		"operator-role-binding.yaml",
+		"builder-service-account.yaml",
+		"builder-role-kubernetes.yaml",
+		"builder-role-binding.yaml",
 	)
 }


[camel-k] 02/07: Fix #703: fix warming cache and affinity to work in global mode

Posted by lb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

lburgazzoli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit ebf1d62673ae24f96729b4a5e30dc4687420b4f8
Author: nferraro <ni...@gmail.com>
AuthorDate: Wed Jun 5 13:03:29 2019 +0200

    Fix #703: fix warming cache and affinity to work in global mode
---
 deploy/operator-role-kubernetes.yaml             |  3 ++
 deploy/operator-role-openshift.yaml              |  3 ++
 deploy/resources.go                              |  6 ++++
 pkg/builder/kaniko/publisher.go                  | 36 ++++++++++++++++--------
 pkg/controller/build/schedule_pod.go             | 31 ++++++++++++--------
 pkg/controller/integrationplatform/initialize.go | 20 +++++++++----
 pkg/platform/operator.go                         | 31 ++++++++++++++------
 7 files changed, 93 insertions(+), 37 deletions(-)

diff --git a/deploy/operator-role-kubernetes.yaml b/deploy/operator-role-kubernetes.yaml
index 30bdf03..5b44671 100644
--- a/deploy/operator-role-kubernetes.yaml
+++ b/deploy/operator-role-kubernetes.yaml
@@ -37,6 +37,9 @@ rules:
   - persistentvolumeclaims
   - configmaps
   - secrets
+  - serviceaccounts
+  - roles
+  - rolebindings
   verbs:
   - create
   - delete
diff --git a/deploy/operator-role-openshift.yaml b/deploy/operator-role-openshift.yaml
index 695ddce..ea12152 100644
--- a/deploy/operator-role-openshift.yaml
+++ b/deploy/operator-role-openshift.yaml
@@ -37,6 +37,9 @@ rules:
   - persistentvolumeclaims
   - configmaps
   - secrets
+  - serviceaccounts
+  - roles
+  - rolebindings
   verbs:
   - create
   - delete
diff --git a/deploy/resources.go b/deploy/resources.go
index 53af8b2..cc87284 100644
--- a/deploy/resources.go
+++ b/deploy/resources.go
@@ -10815,6 +10815,9 @@ rules:
   - persistentvolumeclaims
   - configmaps
   - secrets
+  - serviceaccounts
+  - roles
+  - rolebindings
   verbs:
   - create
   - delete
@@ -10895,6 +10898,9 @@ rules:
   - persistentvolumeclaims
   - configmaps
   - secrets
+  - serviceaccounts
+  - roles
+  - rolebindings
   verbs:
   - create
   - delete
diff --git a/pkg/builder/kaniko/publisher.go b/pkg/builder/kaniko/publisher.go
index f11c19b..6de226e 100644
--- a/pkg/builder/kaniko/publisher.go
+++ b/pkg/builder/kaniko/publisher.go
@@ -24,6 +24,7 @@ import (
 	"time"
 
 	"github.com/apache/camel-k/pkg/builder"
+	"github.com/apache/camel-k/pkg/platform"
 	"github.com/apache/camel-k/pkg/util/kubernetes"
 	"github.com/apache/camel-k/pkg/util/tar"
 
@@ -131,19 +132,32 @@ func publisher(ctx *builder.Context) error {
 			},
 			RestartPolicy: corev1.RestartPolicyNever,
 			Volumes:       volumes,
-			// Co-locate with builder pod for sharing the volume
-			Affinity: &corev1.Affinity{
-				PodAffinity: &corev1.PodAffinity{
-					RequiredDuringSchedulingIgnoredDuringExecution: []corev1.PodAffinityTerm{
-						{
-							LabelSelector: &metav1.LabelSelector{
-								MatchLabels: map[string]string{
-									"camel.apache.org/component": "operator",
-								},
-							},
-							TopologyKey: "kubernetes.io/hostname",
+		},
+	}
+
+
+	var labelKey string
+	var labelValue string
+	if ctx.Namespace == platform.GetOperatorNamespace() {
+		// Check if the operator is running in the same namespace
+		labelKey = "camel.apache.org/component"
+		labelValue = "operator"
+	} else {
+		labelKey = "camel.apache.org/build"
+		labelValue = ctx.Build.Meta.Name
+	}
+
+	// Co-locate with builder pod for sharing the volume
+	pod.Spec.Affinity = &corev1.Affinity{
+		PodAffinity: &corev1.PodAffinity{
+			RequiredDuringSchedulingIgnoredDuringExecution: []corev1.PodAffinityTerm{
+				{
+					LabelSelector: &metav1.LabelSelector{
+						MatchLabels: map[string]string{
+							labelKey: labelValue,
 						},
 					},
+					TopologyKey: "kubernetes.io/hostname",
 				},
 			},
 		},
diff --git a/pkg/controller/build/schedule_pod.go b/pkg/controller/build/schedule_pod.go
index 60a9278..ee84c54 100644
--- a/pkg/controller/build/schedule_pod.go
+++ b/pkg/controller/build/schedule_pod.go
@@ -156,6 +156,9 @@ func newBuildPod(build *v1alpha1.Build, operatorImage string) *corev1.Pod {
 		ObjectMeta: metav1.ObjectMeta{
 			Namespace: build.Namespace,
 			Name:      buildPodName(build.Spec.Meta),
+			Labels: map[string]string{
+				"camel.apache.org/build": build.Name,
+			},
 		},
 		Spec: corev1.PodSpec{
 			ServiceAccountName: "camel-k-operator",
@@ -193,22 +196,26 @@ func newBuildPod(build *v1alpha1.Build, operatorImage string) *corev1.Pod {
 				MountPath: build.Spec.BuildDir,
 			},
 		}
-		// Co-locate with the builder pod for sharing the host path volume as the current
-		// persistent volume claim uses the default storage class which is likely relying
-		// on the host path provisioner.
-		pod.Spec.Affinity = &corev1.Affinity{
-			PodAffinity: &corev1.PodAffinity{
-				RequiredDuringSchedulingIgnoredDuringExecution: []corev1.PodAffinityTerm{
-					{
-						LabelSelector: &metav1.LabelSelector{
-							MatchLabels: map[string]string{
-								"camel.apache.org/component": "operator",
+
+		// Use affinity only when the operator is present in the namespaced
+		if build.Namespace == platform.GetOperatorNamespace() {
+			// Co-locate with the builder pod for sharing the host path volume as the current
+			// persistent volume claim uses the default storage class which is likely relying
+			// on the host path provisioner.
+			pod.Spec.Affinity = &corev1.Affinity{
+				PodAffinity: &corev1.PodAffinity{
+					RequiredDuringSchedulingIgnoredDuringExecution: []corev1.PodAffinityTerm{
+						{
+							LabelSelector: &metav1.LabelSelector{
+								MatchLabels: map[string]string{
+									"camel.apache.org/component": "operator",
+								},
 							},
+							TopologyKey: "kubernetes.io/hostname",
 						},
-						TopologyKey: "kubernetes.io/hostname",
 					},
 				},
-			},
+			}
 		}
 	}
 
diff --git a/pkg/controller/integrationplatform/initialize.go b/pkg/controller/integrationplatform/initialize.go
index d8cea6e..6976165 100644
--- a/pkg/controller/integrationplatform/initialize.go
+++ b/pkg/controller/integrationplatform/initialize.go
@@ -153,13 +153,21 @@ func (action *initializeAction) Handle(ctx context.Context, ip *v1alpha1.Integra
 			return err
 		}
 
-		// Create the Kaniko warmer pod that caches the base image into the Camel K builder volume
-		action.L.Info("Create Kaniko cache warmer pod")
-		err = createKanikoCacheWarmerPod(ctx, action.client, target)
-		if err != nil {
-			return err
+		// Check if the operator is running in the same namespace before starting the cache warmer
+		if target.Namespace == platform.GetOperatorNamespace() {
+			// Create the Kaniko warmer pod that caches the base image into the Camel K builder volume
+			action.L.Info("Create Kaniko cache warmer pod")
+			err = createKanikoCacheWarmerPod(ctx, action.client, target)
+			if err != nil {
+				return err
+			}
+
+			target.Status.Phase = v1alpha1.IntegrationPlatformPhaseWarming
+		} else {
+			// Skip the warmer pod creation
+			target.Status.Phase = v1alpha1.IntegrationPlatformPhaseCreating
 		}
-		target.Status.Phase = v1alpha1.IntegrationPlatformPhaseWarming
+
 	} else {
 		target.Status.Phase = v1alpha1.IntegrationPlatformPhaseCreating
 	}
diff --git a/pkg/platform/operator.go b/pkg/platform/operator.go
index 2ffd051..82ed950 100644
--- a/pkg/platform/operator.go
+++ b/pkg/platform/operator.go
@@ -24,6 +24,7 @@ import (
 	"strings"
 
 	v1 "k8s.io/api/core/v1"
+	k8serrors "k8s.io/apimachinery/pkg/api/errors"
 	"sigs.k8s.io/controller-runtime/pkg/client"
 )
 
@@ -33,13 +34,9 @@ const operatorPodNameEnvVariable = "POD_NAME"
 
 // GetCurrentOperatorImage returns the image currently used by the running operator if present (when running out of cluster, it may be absent).
 func GetCurrentOperatorImage(ctx context.Context, c client.Client) (string, error) {
-	var podNamespace string
-	var podName string
-	var envSet bool
-	if podNamespace, envSet = os.LookupEnv(operatorNamespaceEnvVariable); !envSet || podNamespace == "" {
-		return "", nil
-	}
-	if podName, envSet = os.LookupEnv(operatorPodNameEnvVariable); !envSet || podName == "" {
+	podNamespace := GetOperatorNamespace()
+	podName := GetOperatorPodName()
+	if podNamespace == "" || podName == "" {
 		return "", nil
 	}
 
@@ -49,7 +46,9 @@ func GetCurrentOperatorImage(ctx context.Context, c client.Client) (string, erro
 	}
 	pod := v1.Pod{}
 
-	if err := c.Get(ctx, podKey, &pod); err != nil {
+	if err := c.Get(ctx, podKey, &pod); err != nil && k8serrors.IsNotFound(err) {
+		return "", nil
+	} else if err != nil {
 		return "", err
 	}
 	if len(pod.Spec.Containers) == 0 {
@@ -65,3 +64,19 @@ func IsCurrentOperatorGlobal() bool {
 	}
 	return false
 }
+
+// GetOperatorNamespace returns the namespace where the current operator is located (if set)
+func GetOperatorNamespace() string {
+	if podNamespace, envSet := os.LookupEnv(operatorNamespaceEnvVariable); envSet {
+		return podNamespace
+	}
+	return ""
+}
+
+// GetOperatorPodName returns the pod that is running the current operator (if any)
+func GetOperatorPodName() string {
+	if podName, envSet := os.LookupEnv(operatorPodNameEnvVariable); envSet {
+		return podName
+	}
+	return ""
+}


[camel-k] 05/07: Fix #703: add CRDs to manifest

Posted by lb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

lburgazzoli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit 134d8448e106772c35f26204ee4d2b6096c3ea52
Author: nferraro <ni...@gmail.com>
AuthorDate: Thu Jun 6 12:26:44 2019 +0200

    Fix #703: add CRDs to manifest
---
 .../camel-k/0.3.4-SNAPSHOT/crd-build.yaml          | 37 ++++++++++++++++++++++
 .../camel-k/0.3.4-SNAPSHOT/crd-camel-catalog.yaml  | 25 +++++++++++++++
 .../0.3.4-SNAPSHOT/crd-integration-context.yaml    | 32 +++++++++++++++++++
 .../0.3.4-SNAPSHOT/crd-integration-platform.yaml   | 24 ++++++++++++++
 .../camel-k/0.3.4-SNAPSHOT/crd-integration.yaml    | 28 ++++++++++++++++
 script/Makefile                                    |  2 +-
 script/build_olm.sh                                | 18 +++++++++++
 7 files changed, 165 insertions(+), 1 deletion(-)

diff --git a/deploy/olm-catalog/camel-k/0.3.4-SNAPSHOT/crd-build.yaml b/deploy/olm-catalog/camel-k/0.3.4-SNAPSHOT/crd-build.yaml
new file mode 100644
index 0000000..9459516
--- /dev/null
+++ b/deploy/olm-catalog/camel-k/0.3.4-SNAPSHOT/crd-build.yaml
@@ -0,0 +1,37 @@
+apiVersion: apiextensions.k8s.io/v1beta1
+kind: CustomResourceDefinition
+metadata:
+  name: builds.camel.apache.org
+  labels:
+    app: "camel-k"
+spec:
+  group: camel.apache.org
+  scope: Namespaced
+  version: v1alpha1
+  names:
+    kind: Build
+    listKind: BuildList
+    plural: builds
+    singular: build
+  subresources:
+    status: {}
+  additionalPrinterColumns:
+    - name: Phase
+      type: string
+      description: The build phase
+      JSONPath: .status.phase
+    - name: Age
+      type: date
+      description: The time at which the build was last (re-)started
+      JSONPath: .status.startedAt
+    - name: Duration
+      type: string
+      # Change when CRD uses OpenAPI spec v3
+      # https://github.com/OAI/OpenAPI-Specification/issues/845
+      # format: duration
+      description: The build last execution duration
+      JSONPath: .status.duration
+    - name: Attempts
+      type: integer
+      description: The number of execution attempts
+      JSONPath: .status.failure.recovery.attempt
diff --git a/deploy/olm-catalog/camel-k/0.3.4-SNAPSHOT/crd-camel-catalog.yaml b/deploy/olm-catalog/camel-k/0.3.4-SNAPSHOT/crd-camel-catalog.yaml
new file mode 100644
index 0000000..ee84510
--- /dev/null
+++ b/deploy/olm-catalog/camel-k/0.3.4-SNAPSHOT/crd-camel-catalog.yaml
@@ -0,0 +1,25 @@
+apiVersion: apiextensions.k8s.io/v1beta1
+kind: CustomResourceDefinition
+metadata:
+  name: camelcatalogs.camel.apache.org
+  labels:
+    app: "camel-k"
+spec:
+  group: camel.apache.org
+  names:
+    kind: CamelCatalog
+    listKind: CamelCatalogList
+    plural: camelcatalogs
+    singular: camelcatalog
+    shortNames:
+      - cc
+  scope: Namespaced
+  version: v1alpha1
+  subresources:
+    status: {}
+  additionalPrinterColumns:
+    - name: Version
+      type: string
+      description: The Catalog version
+      JSONPath: .spec.version
+
diff --git a/deploy/olm-catalog/camel-k/0.3.4-SNAPSHOT/crd-integration-context.yaml b/deploy/olm-catalog/camel-k/0.3.4-SNAPSHOT/crd-integration-context.yaml
new file mode 100644
index 0000000..a940628
--- /dev/null
+++ b/deploy/olm-catalog/camel-k/0.3.4-SNAPSHOT/crd-integration-context.yaml
@@ -0,0 +1,32 @@
+apiVersion: apiextensions.k8s.io/v1beta1
+kind: CustomResourceDefinition
+metadata:
+  name: integrationcontexts.camel.apache.org
+  labels:
+    app: "camel-k"
+spec:
+  group: camel.apache.org
+  scope: Namespaced
+  version: v1alpha1
+  subresources:
+    status: {}
+  names:
+    kind: IntegrationContext
+    listKind: IntegrationContextList
+    plural: integrationcontexts
+    singular: integrationcontext
+    shortNames:
+    - ictx
+  additionalPrinterColumns:
+    - name: Phase
+      type: string
+      description: The IntegrationContext phase
+      JSONPath: .status.phase
+    - name: Type
+      type: string
+      description: The IntegrationContext type
+      JSONPath: .metadata.labels.camel\.apache\.org\/context\.type
+    - name: Image
+      type: string
+      description: The IntegrationContext image
+      JSONPath: .status.image
diff --git a/deploy/olm-catalog/camel-k/0.3.4-SNAPSHOT/crd-integration-platform.yaml b/deploy/olm-catalog/camel-k/0.3.4-SNAPSHOT/crd-integration-platform.yaml
new file mode 100644
index 0000000..868831d
--- /dev/null
+++ b/deploy/olm-catalog/camel-k/0.3.4-SNAPSHOT/crd-integration-platform.yaml
@@ -0,0 +1,24 @@
+apiVersion: apiextensions.k8s.io/v1beta1
+kind: CustomResourceDefinition
+metadata:
+  name: integrationplatforms.camel.apache.org
+  labels:
+    app: "camel-k"
+spec:
+  group: camel.apache.org
+  scope: Namespaced
+  version: v1alpha1
+  subresources:
+    status: {}
+  names:
+    kind: IntegrationPlatform
+    listKind: IntegrationPlatformList
+    plural: integrationplatforms
+    singular: integrationplatform
+    shortNames:
+    - ip
+  additionalPrinterColumns:
+    - name: Phase
+      type: string
+      description: The IntegrationPlatform phase
+      JSONPath: .status.phase
diff --git a/deploy/olm-catalog/camel-k/0.3.4-SNAPSHOT/crd-integration.yaml b/deploy/olm-catalog/camel-k/0.3.4-SNAPSHOT/crd-integration.yaml
new file mode 100644
index 0000000..e6e2657
--- /dev/null
+++ b/deploy/olm-catalog/camel-k/0.3.4-SNAPSHOT/crd-integration.yaml
@@ -0,0 +1,28 @@
+apiVersion: apiextensions.k8s.io/v1beta1
+kind: CustomResourceDefinition
+metadata:
+  name: integrations.camel.apache.org
+  labels:
+    app: "camel-k"
+spec:
+  group: camel.apache.org
+  scope: Namespaced
+  version: v1alpha1
+  subresources:
+    status: {}
+  names:
+    kind: Integration
+    listKind: IntegrationList
+    plural: integrations
+    singular: integration
+    shortNames:
+    - it
+  additionalPrinterColumns:
+    - name: Phase
+      type: string
+      description: The Integration phase
+      JSONPath: .status.phase
+    - name: Context
+      type: string
+      description: The IntegrationContext to use
+      JSONPath: .status.context
diff --git a/script/Makefile b/script/Makefile
index 030b4bb..5c6b51c 100644
--- a/script/Makefile
+++ b/script/Makefile
@@ -115,7 +115,7 @@ build-resources:
 	go run cmd/util/json-schema-gen/jsonschemagen.go --out=./assets/json-schema
 
 build-olm:
-	operator-sdk olm-catalog gen-csv --csv-version $(VERSION) --csv-config deploy/olm-catalog/csv-config.yaml --update-crds
+	./script/build_olm.sh $(VERSION)
 
 build-compile-integration-tests:
 	go test -c -tags=integration ./test/*.go
diff --git a/script/build_olm.sh b/script/build_olm.sh
new file mode 100755
index 0000000..44719e9
--- /dev/null
+++ b/script/build_olm.sh
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+location=$(dirname $0)
+olm_catalog=${location}/../deploy/olm-catalog
+
+if [ "$#" -ne 1 ]; then
+    echo "usage: $0 version"
+    exit 1
+fi
+
+version=$1
+
+cd $location/..
+
+operator-sdk olm-catalog gen-csv --csv-version ${version} --csv-config deploy/olm-catalog/csv-config.yaml --update-crds
+
+rm $olm_catalog/camel-k/${version}/crd-*.yaml
+cp $location/../deploy/crd-*.yaml $olm_catalog/camel-k/${version}/


[camel-k] 06/07: Fix #703: fix olm

Posted by lb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

lburgazzoli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit b2d2abd0a14c8b8bc9b5416697829f5082c4d6f8
Author: nferraro <ni...@gmail.com>
AuthorDate: Thu Jun 6 14:26:41 2019 +0200

    Fix #703: fix olm
---
 .../camel-k.v0.3.4-SNAPSHOT.clusterserviceversion.yaml     | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/deploy/olm-catalog/camel-k/0.3.4-SNAPSHOT/camel-k.v0.3.4-SNAPSHOT.clusterserviceversion.yaml b/deploy/olm-catalog/camel-k/0.3.4-SNAPSHOT/camel-k.v0.3.4-SNAPSHOT.clusterserviceversion.yaml
index 9718838..a5af236 100644
--- a/deploy/olm-catalog/camel-k/0.3.4-SNAPSHOT/camel-k.v0.3.4-SNAPSHOT.clusterserviceversion.yaml
+++ b/deploy/olm-catalog/camel-k/0.3.4-SNAPSHOT/camel-k.v0.3.4-SNAPSHOT.clusterserviceversion.yaml
@@ -8,16 +8,6 @@ metadata:
         "kind": "IntegrationPlatform",
         "metadata": {
           "name": "example"
-        },
-        "spec": {
-          "build": {
-            "buildStrategy": "pod"
-          },
-          "resources": {
-            "contexts": [
-              "jvm"
-            ]
-          }
         }
       },
       {
@@ -163,7 +153,7 @@ spec:
                 - name: WATCH_NAMESPACE
                   valueFrom:
                     fieldRef:
-                      fieldPath: metadata.namespace
+                      fieldPath: metadata.annotations['olm.targetNamespaces']
                 - name: OPERATOR_NAME
                   value: camel-k
                 - name: POD_NAME
@@ -383,7 +373,7 @@ spec:
   minKubeVersion: 1.11.0
   provider:
     name: The Apache Software Foundation
-  replaces: camel-k.v0.3.3
+  replaces: camel-k-operator.v0.3.3
   selector:
     matchLabels:
       name: camel-k-operator


[camel-k] 07/07: Fix #703: add license headers

Posted by lb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

lburgazzoli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit 8728513111b1629ff37860bcfd2daa55975c4bd9
Author: nferraro <ni...@gmail.com>
AuthorDate: Thu Jun 6 14:30:01 2019 +0200

    Fix #703: add license headers
---
 script/build_olm.sh      | 15 +++++++++++++++
 script/unsnapshot_olm.sh | 15 +++++++++++++++
 2 files changed, 30 insertions(+)

diff --git a/script/build_olm.sh b/script/build_olm.sh
index 44719e9..adc7889 100755
--- a/script/build_olm.sh
+++ b/script/build_olm.sh
@@ -1,5 +1,20 @@
 #!/bin/sh
 
+# 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.
+
 location=$(dirname $0)
 olm_catalog=${location}/../deploy/olm-catalog
 
diff --git a/script/unsnapshot_olm.sh b/script/unsnapshot_olm.sh
index 4af2774..943d603 100755
--- a/script/unsnapshot_olm.sh
+++ b/script/unsnapshot_olm.sh
@@ -1,5 +1,20 @@
 #!/bin/sh
 
+# 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.
+
 # Prefer unsnapshotting to regenerating, because changes done to snapshot file may get lost
 
 location=$(dirname $0)


[camel-k] 01/07: Fix #703: automatically configure global build strategy

Posted by lb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

lburgazzoli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit f312d55bd9f1ffe9277efb381a0c043724adb852
Author: nferraro <ni...@gmail.com>
AuthorDate: Tue Jun 4 16:47:36 2019 +0200

    Fix #703: automatically configure global build strategy
---
 pkg/cmd/install.go                               | 12 +++--
 pkg/controller/build/schedule_pod.go             | 21 ++++++++
 pkg/controller/integrationplatform/initialize.go | 12 +++--
 pkg/install/serviceaccount.go                    | 67 ++++++++++++++++++++++++
 pkg/platform/operator.go                         | 10 ++++
 5 files changed, 116 insertions(+), 6 deletions(-)

diff --git a/pkg/cmd/install.go b/pkg/cmd/install.go
index ab91a9e..65d6b67 100644
--- a/pkg/cmd/install.go
+++ b/pkg/cmd/install.go
@@ -60,6 +60,7 @@ func newCmdInstall(rootCmdOptions *RootCmdOptions) *cobra.Command {
 
 	cmd.Flags().BoolVarP(&impl.wait, "wait", "w", false, "Waits for the platform to be running")
 	cmd.Flags().BoolVar(&impl.clusterSetupOnly, "cluster-setup", false, "Execute cluster-wide operations only (may require admin rights)")
+	cmd.Flags().BoolVar(&impl.skipOperatorSetup, "skip-operator-setup", false, "Do not install the operator in the namespace (in case there's a global one)")
 	cmd.Flags().BoolVar(&impl.skipClusterSetup, "skip-cluster-setup", false, "Skip the cluster-setup phase")
 	cmd.Flags().BoolVar(&impl.exampleSetup, "example", false, "Install example integration")
 
@@ -98,6 +99,7 @@ type installCmdOptions struct {
 	*RootCmdOptions
 	wait              bool
 	clusterSetupOnly  bool
+	skipOperatorSetup bool
 	skipClusterSetup  bool
 	exampleSetup      bool
 	outputFormat      string
@@ -149,9 +151,13 @@ func (o *installCmdOptions) install(_ *cobra.Command, _ []string) error {
 
 		namespace := o.Namespace
 
-		err = install.OperatorOrCollect(o.Context, c, namespace, o.operatorImage, collection)
-		if err != nil {
-			return err
+		if !o.skipOperatorSetup {
+			err = install.OperatorOrCollect(o.Context, c, namespace, o.operatorImage, collection)
+			if err != nil {
+				return err
+			}
+		} else {
+			fmt.Println("Camel K operator installation skipped")
 		}
 
 		platform, err := install.PlatformOrCollect(o.Context, c, namespace, o.registry, collection)
diff --git a/pkg/controller/build/schedule_pod.go b/pkg/controller/build/schedule_pod.go
index 212e0f6..60a9278 100644
--- a/pkg/controller/build/schedule_pod.go
+++ b/pkg/controller/build/schedule_pod.go
@@ -22,6 +22,7 @@ import (
 	"sync"
 
 	"github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
+	"github.com/apache/camel-k/pkg/install"
 	"github.com/apache/camel-k/pkg/platform"
 	"github.com/apache/camel-k/pkg/util/defaults"
 
@@ -105,6 +106,11 @@ func (action *schedulePodAction) Handle(ctx context.Context, build *v1alpha1.Bui
 		return err
 	}
 
+	// Ensure service account is present
+	if err := action.ensureServiceAccount(ctx, pod); err != nil {
+		return errors.Wrap(err, "cannot ensure service account is present")
+	}
+
 	err = action.client.Delete(ctx, pod)
 	if err != nil && !k8serrors.IsNotFound(err) {
 		return errors.Wrap(err, "cannot delete build pod")
@@ -122,6 +128,21 @@ func (action *schedulePodAction) Handle(ctx context.Context, build *v1alpha1.Bui
 	return action.client.Status().Update(ctx, target)
 }
 
+func (action *schedulePodAction) ensureServiceAccount(ctx context.Context, buildPod *corev1.Pod) error {
+	sa := corev1.ServiceAccount{}
+	saKey := k8sclient.ObjectKey{
+		Name:      "camel-k-operator",
+		Namespace: buildPod.Namespace,
+	}
+
+	err := action.client.Get(ctx, saKey, &sa)
+	if err != nil && k8serrors.IsNotFound(err) {
+		// Create a proper service account
+		return install.ServiceAccountRoles(ctx, action.client, buildPod.Namespace)
+	}
+	return err
+}
+
 func newBuildPod(build *v1alpha1.Build, operatorImage string) *corev1.Pod {
 	builderImage := operatorImage
 	if builderImage == "" {
diff --git a/pkg/controller/integrationplatform/initialize.go b/pkg/controller/integrationplatform/initialize.go
index f8c2f9b..d8cea6e 100644
--- a/pkg/controller/integrationplatform/initialize.go
+++ b/pkg/controller/integrationplatform/initialize.go
@@ -93,11 +93,17 @@ func (action *initializeAction) Handle(ctx context.Context, ip *v1alpha1.Integra
 	}
 
 	if target.Spec.Build.BuildStrategy == "" {
-		if target.Spec.Build.PublishStrategy == v1alpha1.IntegrationPlatformBuildPublishStrategyKaniko {
-			// The build output has to be shared with Kaniko via a persistent volume
+		// If the operator is global, a global build strategy should be used
+		if platform.IsCurrentOperatorGlobal() {
+			// The only global strategy we have for now
 			target.Spec.Build.BuildStrategy = v1alpha1.IntegrationPlatformBuildStrategyPod
 		} else {
-			target.Spec.Build.BuildStrategy = v1alpha1.IntegrationPlatformBuildStrategyRoutine
+			if target.Spec.Build.PublishStrategy == v1alpha1.IntegrationPlatformBuildPublishStrategyKaniko {
+				// The build output has to be shared with Kaniko via a persistent volume
+				target.Spec.Build.BuildStrategy = v1alpha1.IntegrationPlatformBuildStrategyPod
+			} else {
+				target.Spec.Build.BuildStrategy = v1alpha1.IntegrationPlatformBuildStrategyRoutine
+			}
 		}
 	}
 
diff --git a/pkg/install/serviceaccount.go b/pkg/install/serviceaccount.go
new file mode 100644
index 0000000..7a9cf9f
--- /dev/null
+++ b/pkg/install/serviceaccount.go
@@ -0,0 +1,67 @@
+/*
+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 install
+
+import (
+	"context"
+	"github.com/apache/camel-k/pkg/client"
+	"github.com/apache/camel-k/pkg/util/knative"
+	"github.com/apache/camel-k/pkg/util/openshift"
+)
+
+// ServiceAccountRoles installs the service account and related roles in the given namespace
+func ServiceAccountRoles(ctx context.Context, c client.Client, namespace string) error {
+	isOpenshift, err := openshift.IsOpenShift(c)
+	if err != nil {
+		return err
+	}
+	if isOpenshift {
+		if err := installServiceAccountRolesOpenshift(ctx, c, namespace); err != nil {
+			return err
+		}
+	} else {
+		if err := installServiceAccountRolesKubernetes(ctx, c, namespace); err != nil {
+			return err
+		}
+	}
+	// Install Knative resources if required
+	isKnative, err := knative.IsInstalled(ctx, c)
+	if err != nil {
+		return err
+	}
+	if isKnative {
+		return installKnative(ctx, c, namespace, nil)
+	}
+	return nil
+}
+
+func installServiceAccountRolesOpenshift(ctx context.Context, c client.Client, namespace string) error {
+	return ResourcesOrCollect(ctx, c, namespace, nil, IdentityResourceCustomizer,
+		"operator-service-account.yaml",
+		"operator-role-openshift.yaml",
+		"operator-role-binding.yaml",
+	)
+}
+
+func installServiceAccountRolesKubernetes(ctx context.Context, c client.Client, namespace string) error {
+	return ResourcesOrCollect(ctx, c, namespace, nil, IdentityResourceCustomizer,
+		"operator-service-account.yaml",
+		"operator-role-kubernetes.yaml",
+		"operator-role-binding.yaml",
+	)
+}
diff --git a/pkg/platform/operator.go b/pkg/platform/operator.go
index f180cd9..2ffd051 100644
--- a/pkg/platform/operator.go
+++ b/pkg/platform/operator.go
@@ -21,11 +21,13 @@ import (
 	"context"
 	"errors"
 	"os"
+	"strings"
 
 	v1 "k8s.io/api/core/v1"
 	"sigs.k8s.io/controller-runtime/pkg/client"
 )
 
+const operatorWatchNamespaceEnvVariable = "WATCH_NAMESPACE"
 const operatorNamespaceEnvVariable = "NAMESPACE"
 const operatorPodNameEnvVariable = "POD_NAME"
 
@@ -55,3 +57,11 @@ func GetCurrentOperatorImage(ctx context.Context, c client.Client) (string, erro
 	}
 	return pod.Spec.Containers[0].Image, nil
 }
+
+// IsCurrentOperatorGlobal returns true if the operator is configured to watch all namespaces
+func IsCurrentOperatorGlobal() bool {
+	if watchNamespace, envSet := os.LookupEnv(operatorWatchNamespaceEnvVariable); !envSet || strings.TrimSpace(watchNamespace) == "" {
+		return true
+	}
+	return false
+}