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

kezhenxu94 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler-operator.git

commit 78e60ecef9f7d2a789aae9a634012af499c5ccd6
Author: nobolity <[email protected]>
AuthorDate: Sun Jun 12 13:01:37 2022 +0800

    feat(master && worker): add feature webhook
---
 PROJECT                               |  4 +++
 README.md                             |  6 ++--
 api/v1alpha1/dsmaster_types.go        |  1 +
 api/v1alpha1/zz_generated.deepcopy.go |  2 +-
 config/default/kustomization.yaml     | 62 +++++++++++++++++------------------
 config/ds/postgreSQL/postgres-pv.yaml |  2 +-
 config/manager/kustomization.yaml     |  4 +--
 go.mod                                |  2 +-
 main.go                               |  4 +++
 9 files changed, 48 insertions(+), 39 deletions(-)

diff --git a/PROJECT b/PROJECT
index 14f9538..12b3a71 100644
--- a/PROJECT
+++ b/PROJECT
@@ -13,6 +13,10 @@ resources:
   kind: DSMaster
   path: dolphinscheduler-operator/api/v1alpha1
   version: v1alpha1
+  webhooks:
+    defaulting: true
+    validation: true
+    webhookVersion: v1
 - api:
     crdVersion: v1
     namespaced: true
diff --git a/README.md b/README.md
index 5580e49..97ee518 100644
--- a/README.md
+++ b/README.md
@@ -30,7 +30,7 @@
 
 2. **install  postgres (not required)**
 
-    if had no postgressql ,you can turn into config/ds/ and run *"kubectl 
apply -f postgreSQL/"* 
+    if had no postgressql ,you can turn into config/ds/ and run *"kubectl 
apply -f postgreSQL/"* ,but you need to replace your local document to 
hostPath.path in postgres-pv.yaml first
 
     connect to postgressql and run the sql script in  
dolphinscheduler/dolphinscheduler-dao/resources/sql
 
@@ -48,7 +48,7 @@
    
     if you had pv and pvc ,you can config it in config/sameples 
     
-    or you can create it with config/ds/ds-pv.yaml and 
config/configmap/ds-pvc.yaml
+    or you can create it with config/ds/ds-pv.yaml and 
config/configmap/ds-pvc.yaml .notice to replace your local document address in 
hostPath.path in ds-pv.yaml
     
     and you can mount the lib in dolphinscheduler /opt/soft  in 
config/samples/ds_v1alpha1_dsworker.yaml with paramter named lib_pvc_name  
     
@@ -62,7 +62,7 @@
  
  * in current project  run *"make build&&make manifests && make install && 
make run"* 
 
- * cd to config/ds/samples
+ * cd to config/samples
 
  * first run *"kubectl apply -f ds_v1alpha1_dsalert.yaml "*
 
diff --git a/api/v1alpha1/dsmaster_types.go b/api/v1alpha1/dsmaster_types.go
index dfb743d..2cfa749 100644
--- a/api/v1alpha1/dsmaster_types.go
+++ b/api/v1alpha1/dsmaster_types.go
@@ -53,6 +53,7 @@ type DSMasterSpec struct {
 
        //ZookeeperConnect  is the address string of zookeeper ,and it will be 
written to ENV
        ZookeeperConnect string `json:"zookeeper_connect,omitempty"`
+
        // Pod defines the policy to create pod for the dm-master pod.
        // Updating Pod does not take effect on any existing dm-master pods.
        Pod *PodPolicy `json:"pod,omitempty"`
diff --git a/api/v1alpha1/zz_generated.deepcopy.go 
b/api/v1alpha1/zz_generated.deepcopy.go
index 99a89dc..54c2786 100644
--- a/api/v1alpha1/zz_generated.deepcopy.go
+++ b/api/v1alpha1/zz_generated.deepcopy.go
@@ -23,7 +23,7 @@ package v1alpha1
 
 import (
        "k8s.io/api/core/v1"
-       runtime "k8s.io/apimachinery/pkg/runtime"
+       "k8s.io/apimachinery/pkg/runtime"
 )
 
 // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, 
writing into out. in must be non-nil.
diff --git a/config/default/kustomization.yaml 
b/config/default/kustomization.yaml
index 88ee4c0..8e9864f 100644
--- a/config/default/kustomization.yaml
+++ b/config/default/kustomization.yaml
@@ -18,16 +18,16 @@ bases:
 - ../manager
 # [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] 
prefix including the one in
 # crd/kustomization.yaml
-#- ../webhook
+- ../webhook
 # [CERTMANAGER] To enable cert-manager, uncomment all sections with 
'CERTMANAGER'. 'WEBHOOK' components are required.
-#- ../certmanager
+- ../certmanager
 # [PROMETHEUS] To enable prometheus monitor, uncomment all sections with 
'PROMETHEUS'.
 #- ../prometheus
 
 patchesStrategicMerge:
 # Protect the /metrics endpoint by putting it behind auth.
 # If you want your controller-manager to expose the /metrics
-# endpoint w/o any authn/z, please comment the following line.
+# endpoint w/o any /z, please comment the following line.
 - manager_auth_proxy_patch.yaml
 
 # Mount the controller config file for loading manager configurations
@@ -36,39 +36,39 @@ patchesStrategicMerge:
 
 # [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] 
prefix including the one in
 # crd/kustomization.yaml
-#- manager_webhook_patch.yaml
+- manager_webhook_patch.yaml
 
 # [CERTMANAGER] To enable cert-manager, uncomment all sections with 
'CERTMANAGER'.
 # Uncomment 'CERTMANAGER' sections in crd/kustomization.yaml to enable the CA 
injection in the admission webhooks.
 # 'CERTMANAGER' needs to be enabled to use ca injection
-#- webhookcainjection_patch.yaml
+- webhookcainjection_patch.yaml
 
 # the following config is for teaching kustomize how to do var substitution
 vars:
 # [CERTMANAGER] To enable cert-manager, uncomment all sections with 
'CERTMANAGER' prefix.
-#- name: CERTIFICATE_NAMESPACE # namespace of the certificate CR
-#  objref:
-#    kind: Certificate
-#    group: cert-manager.io
-#    version: v1
-#    name: serving-cert # this name should match the one in certificate.yaml
-#  fieldref:
-#    fieldpath: metadata.namespace
-#- name: CERTIFICATE_NAME
-#  objref:
-#    kind: Certificate
-#    group: cert-manager.io
-#    version: v1
-#    name: serving-cert # this name should match the one in certificate.yaml
-#- name: SERVICE_NAMESPACE # namespace of the service
-#  objref:
-#    kind: Service
-#    version: v1
-#    name: webhook-service
-#  fieldref:
-#    fieldpath: metadata.namespace
-#- name: SERVICE_NAME
-#  objref:
-#    kind: Service
-#    version: v1
-#    name: webhook-service
+- name: CERTIFICATE_NAMESPACE # namespace of the certificate CR
+  objref:
+    kind: Certificate
+    group: cert-manager.io
+    version: v1
+    name: serving-cert # this name should match the one in certificate.yaml
+  fieldref:
+    fieldpath: metadata.namespace
+- name: CERTIFICATE_NAME
+  objref:
+    kind: Certificate
+    group: cert-manager.io
+    version: v1
+    name: serving-cert # this name should match the one in certificate.yaml
+- name: SERVICE_NAMESPACE # namespace of the service
+  objref:
+    kind: Service
+    version: v1
+    name: webhook-service
+  fieldref:
+    fieldpath: metadata.namespace
+- name: SERVICE_NAME
+  objref:
+    kind: Service
+    version: v1
+    name: webhook-service
diff --git a/config/ds/postgreSQL/postgres-pv.yaml 
b/config/ds/postgreSQL/postgres-pv.yaml
index 9e5867b..d655427 100644
--- a/config/ds/postgreSQL/postgres-pv.yaml
+++ b/config/ds/postgreSQL/postgres-pv.yaml
@@ -12,5 +12,5 @@ spec:
     storage: 2Gi
   accessModes:
     - ReadWriteMany
-  hostPath:
+  hostPath:  #change to your document
     path: "/Volumes/ds/pg/data"
diff --git a/config/manager/kustomization.yaml 
b/config/manager/kustomization.yaml
index 5e793dd..c2c4746 100644
--- a/config/manager/kustomization.yaml
+++ b/config/manager/kustomization.yaml
@@ -12,5 +12,5 @@ apiVersion: kustomize.config.k8s.io/v1beta1
 kind: Kustomization
 images:
 - name: controller
-  newName: controller
-  newTag: latest
+  newName: nobolity/ds-operator
+  newTag: v1alpha1
diff --git a/go.mod b/go.mod
index 9665511..c3d5a4a 100644
--- a/go.mod
+++ b/go.mod
@@ -3,7 +3,6 @@ module dolphinscheduler-operator
 go 1.17
 
 require (
-       github.com/go-logr/logr v1.2.0
        github.com/onsi/ginkgo v1.16.5
        github.com/onsi/gomega v1.17.0
        k8s.io/api v0.23.0
@@ -26,6 +25,7 @@ require (
        github.com/evanphx/json-patch v4.12.0+incompatible // indirect
        github.com/form3tech-oss/jwt-go v3.2.3+incompatible // indirect
        github.com/fsnotify/fsnotify v1.5.1 // indirect
+       github.com/go-logr/logr v1.2.0 // indirect
        github.com/go-logr/zapr v1.2.0 // indirect
        github.com/gogo/protobuf v1.3.2 // indirect
        github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // 
indirect
diff --git a/main.go b/main.go
index 56cc422..1661e0c 100644
--- a/main.go
+++ b/main.go
@@ -106,6 +106,10 @@ func main() {
                setupLog.Error(err, "unable to create controller", 
"controller", "DSApi")
                os.Exit(1)
        }
+       if err = (&dsv1alpha1.DSMaster{}).SetupWebhookWithManager(mgr); err != 
nil {
+               setupLog.Error(err, "unable to create webhook", "webhook", 
"DSMaster")
+               os.Exit(1)
+       }
        //+kubebuilder:scaffold:builder
 
        if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil {

Reply via email to