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

mikexue pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/eventmesh.git


The following commit(s) were added to refs/heads/master by this push:
     new 21731e873 [ISSUE #4728] Deploy eventmesh-operator on k8s cluster. 
(#4727)
21731e873 is described below

commit 21731e8731a67162589819fe385ce905be69480d
Author: Alonexc <[email protected]>
AuthorDate: Thu Jan 11 16:34:57 2024 +0800

    [ISSUE #4728] Deploy eventmesh-operator on k8s cluster. (#4727)
    
    * deployment operator, commands simplified.
    
    * update
    
    * update resources
---
 eventmesh-operator/Dockerfile                      |  1 +
 eventmesh-operator/Makefile                        | 17 +++--
 eventmesh-operator/config/rbac/role.yaml           | 32 ++++++++--
 eventmesh-operator/config/rbac/role_binding.yaml   | 15 ++---
 .../config/rbac/service_account.yaml               | 11 +---
 .../config/samples/eventmesh_operator.yaml         | 74 ++++++++++++++++++++++
 .../eventmesh_runtime/runtime_controller.go        |  9 +--
 7 files changed, 125 insertions(+), 34 deletions(-)

diff --git a/eventmesh-operator/Dockerfile b/eventmesh-operator/Dockerfile
index 63b222de5..14a2e63f0 100644
--- a/eventmesh-operator/Dockerfile
+++ b/eventmesh-operator/Dockerfile
@@ -32,6 +32,7 @@ RUN go mod download
 COPY main.go main.go
 COPY api/ api/
 COPY controllers/ controllers/
+COPY share/ share/
 
 # Build
 # the GOARCH has not a default value to allow the binary be built according to 
the host where the command
diff --git a/eventmesh-operator/Makefile b/eventmesh-operator/Makefile
index 93bf87dec..285b47a8c 100644
--- a/eventmesh-operator/Makefile
+++ b/eventmesh-operator/Makefile
@@ -108,7 +108,7 @@ help: ## Display this help.
 
 .PHONY: manifests
 manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and 
CustomResourceDefinition objects.
-       $(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./..." 
output:crd:artifacts:config=config/crd/bases
+       $(CONTROLLER_GEN) rbac:roleName=eventmesh-operator crd webhook 
paths="./..." output:crd:artifacts:config=config/crd/bases
 
 .PHONY: generate
 generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, 
and DeepCopyObject method implementations.
@@ -193,13 +193,18 @@ delete:
        kubectl delete --ignore-not-found=$(ignore-not-found) -f 
config/samples/eventmesh_v1_connectors_rocketmq.yaml
 
 .PHONY: deploy
-deploy: manifests kustomize ## Deploy controller to the K8s cluster specified 
in ~/.kube/config.
-       cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
-       $(KUSTOMIZE) build config/default | kubectl apply -f -
+deploy: manifests install ## Deploy controller to the K8s cluster specified in 
~/.kube/config.
+       kubectl create -f config/rbac/service_account.yaml
+       kubectl create -f config/rbac/role.yaml
+       kubectl create -f config/rbac/role_binding.yaml
+       kubectl create -f config/samples/eventmesh_operator.yaml
 
 .PHONY: undeploy
-undeploy: ## Undeploy controller from the K8s cluster specified in 
~/.kube/config. Call with ignore-not-found=true to ignore resource not found 
errors during deletion.
-       $(KUSTOMIZE) build config/default | kubectl delete 
--ignore-not-found=$(ignore-not-found) -f -
+undeploy: uninstall ## Undeploy controller from the K8s cluster specified in 
~/.kube/config. Call with ignore-not-found=true to ignore resource not found 
errors during deletion.
+       kubectl delete --ignore-not-found=$(ignore-not-found) -f 
config/rbac/service_account.yaml
+       kubectl delete --ignore-not-found=$(ignore-not-found) -f 
config/rbac/role.yaml
+       kubectl delete --ignore-not-found=$(ignore-not-found) -f 
config/rbac/role_binding.yaml
+       kubectl delete --ignore-not-found=$(ignore-not-found) -f 
config/samples/eventmesh_operator.yaml
 
 ##@ Build Dependencies
 
diff --git a/eventmesh-operator/config/rbac/role.yaml 
b/eventmesh-operator/config/rbac/role.yaml
index bb64ad8f8..2391c5a67 100644
--- a/eventmesh-operator/config/rbac/role.yaml
+++ b/eventmesh-operator/config/rbac/role.yaml
@@ -3,7 +3,7 @@ apiVersion: rbac.authorization.k8s.io/v1
 kind: ClusterRole
 metadata:
   creationTimestamp: null
-  name: manager-role
+  name: eventmesh-operator
 rules:
 - apiGroups:
   - ""
@@ -48,6 +48,30 @@ rules:
   - patch
   - update
   - watch
+- apiGroups:
+  - ""
+  resources:
+  - services
+  verbs:
+  - create
+  - delete
+  - get
+  - list
+  - patch
+  - update
+  - watch
+- apiGroups:
+  - apps
+  resources:
+  - deployments
+  verbs:
+  - create
+  - delete
+  - get
+  - list
+  - patch
+  - update
+  - watch
 - apiGroups:
   - apps
   resources:
@@ -101,7 +125,7 @@ rules:
 - apiGroups:
   - eventmesh-operator.eventmesh
   resources:
-  - runtime
+  - runtimes
   verbs:
   - create
   - delete
@@ -113,13 +137,13 @@ rules:
 - apiGroups:
   - eventmesh-operator.eventmesh
   resources:
-  - runtime/finalizers
+  - runtimes/finalizers
   verbs:
   - update
 - apiGroups:
   - eventmesh-operator.eventmesh
   resources:
-  - runtime/status
+  - runtimes/status
   verbs:
   - get
   - patch
diff --git a/eventmesh-operator/config/rbac/role_binding.yaml 
b/eventmesh-operator/config/rbac/role_binding.yaml
index be5f9c345..7c1c09523 100644
--- a/eventmesh-operator/config/rbac/role_binding.yaml
+++ b/eventmesh-operator/config/rbac/role_binding.yaml
@@ -18,19 +18,12 @@
 apiVersion: rbac.authorization.k8s.io/v1
 kind: ClusterRoleBinding
 metadata:
-  labels:
-    app.kubernetes.io/name: clusterrolebinding
-    app.kubernetes.io/instance: manager-rolebinding
-    app.kubernetes.io/component: rbac
-    app.kubernetes.io/created-by: eventmesh-operator
-    app.kubernetes.io/part-of: eventmesh-operator
-    app.kubernetes.io/managed-by: kustomize
-  name: manager-rolebinding
+  name: eventmesh-operator
 roleRef:
   apiGroup: rbac.authorization.k8s.io
   kind: ClusterRole
-  name: manager-role
+  name: eventmesh-operator
 subjects:
 - kind: ServiceAccount
-  name: controller-manager
-  namespace: system
+  name: eventmesh-operator
+  namespace: default
diff --git a/eventmesh-operator/config/rbac/service_account.yaml 
b/eventmesh-operator/config/rbac/service_account.yaml
index 403eeec82..7279388ad 100644
--- a/eventmesh-operator/config/rbac/service_account.yaml
+++ b/eventmesh-operator/config/rbac/service_account.yaml
@@ -18,12 +18,5 @@
 apiVersion: v1
 kind: ServiceAccount
 metadata:
-  labels:
-    app.kubernetes.io/name: serviceaccount
-    app.kubernetes.io/instance: controller-manager
-    app.kubernetes.io/component: rbac
-    app.kubernetes.io/created-by: eventmesh-operator
-    app.kubernetes.io/part-of: eventmesh-operator
-    app.kubernetes.io/managed-by: kustomize
-  name: controller-manager
-  namespace: system
+  name: eventmesh-operator
+  namespace: default
diff --git a/eventmesh-operator/config/samples/eventmesh_operator.yaml 
b/eventmesh-operator/config/samples/eventmesh_operator.yaml
new file mode 100644
index 000000000..29164e904
--- /dev/null
+++ b/eventmesh-operator/config/samples/eventmesh_operator.yaml
@@ -0,0 +1,74 @@
+#
+# 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: apps/v1
+kind: Deployment
+metadata:
+  name: eventmesh-operator
+spec:
+  replicas: 1
+  selector:
+    matchLabels:
+      name: eventmesh-operator
+  template:
+    metadata:
+      labels:
+        name: eventmesh-operator
+    spec:
+      serviceAccountName: eventmesh-operator
+      terminationGracePeriodSeconds: 10
+      containers:
+        - name: eventmesh-operator
+          # image
+          image: alonexc/eventmesh-operator:latest
+          command:
+            - /manager
+          args:
+            - --leader-elect
+          imagePullPolicy: IfNotPresent
+          securityContext:
+            allowPrivilegeEscalation: false
+          livenessProbe:
+            httpGet:
+              path: /healthz
+              port: 8081
+            initialDelaySeconds: 15
+            periodSeconds: 20
+          readinessProbe:
+            httpGet:
+              path: /readyz
+              port: 8081
+            initialDelaySeconds: 5
+            periodSeconds: 10
+          resources:
+            limits:
+              cpu: 200m
+              memory: 2048Mi
+            requests:
+              cpu: 100m
+              memory: 1024Mi
+          env:
+            - name: WATCH_NAMESPACE
+              valueFrom:
+                fieldRef:
+                  fieldPath: metadata.namespace
+            - name: POD_NAME
+              valueFrom:
+                fieldRef:
+                  fieldPath: metadata.name
+            - name: OPERATOR_NAME
+              value: "eventmesh-operator"
diff --git 
a/eventmesh-operator/controllers/eventmesh_runtime/runtime_controller.go 
b/eventmesh-operator/controllers/eventmesh_runtime/runtime_controller.go
index 70aafefbf..731ef8c55 100644
--- a/eventmesh-operator/controllers/eventmesh_runtime/runtime_controller.go
+++ b/eventmesh-operator/controllers/eventmesh_runtime/runtime_controller.go
@@ -90,12 +90,13 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error 
{
        return nil
 }
 
-//+kubebuilder:rbac:groups=eventmesh-operator.eventmesh,resources=runtime,verbs=get;list;watch;create;update;patch;delete
-//+kubebuilder:rbac:groups=eventmesh-operator.eventmesh,resources=runtime/status,verbs=get;update;patch
-//+kubebuilder:rbac:groups=eventmesh-operator.eventmesh,resources=runtime/finalizers,verbs=update
+//+kubebuilder:rbac:groups=eventmesh-operator.eventmesh,resources=runtimes,verbs=get;list;watch;create;update;patch;delete
+//+kubebuilder:rbac:groups=eventmesh-operator.eventmesh,resources=runtimes/status,verbs=get;update;patch
+//+kubebuilder:rbac:groups=eventmesh-operator.eventmesh,resources=runtimes/finalizers,verbs=update
 
//+kubebuilder:rbac:groups="",resources=pods,verbs=get;list;watch;create;update;patch;delete
-//+kubebuilder:rbac:groups="",resources=pods/exec,verbs=get;list;watch;create;update;patch;delete
 
//+kubebuilder:rbac:groups="apps",resources=statefulsets,verbs=get;list;watch;create;update;patch;delete
+//+kubebuilder:rbac:groups="apps",resources=deployments,verbs=get;list;watch;create;update;patch;delete
+//+kubebuilder:rbac:groups="",resources=services,verbs=get;list;watch;create;update;patch;delete
 
 // Reconcile is part of the main kubernetes reconciliation loop which aims to
 // move the current state of the cluster closer to the desired state.


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to