Aitozi commented on code in PR #192:
URL: 
https://github.com/apache/flink-kubernetes-operator/pull/192#discussion_r864502156


##########
docs/content/docs/operations/validator.md:
##########
@@ -0,0 +1,74 @@
+---
+title: "Validator"
+weight: 5
+type: docs
+aliases:
+- /operations/validator.html
+---
+<!--
+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.
+-->
+
+# Custom `FlinkResourceValidator` implementation
+
+`FlinkResourceValidator`, a validator interface for resources of 
`FlinkDeployment` and `FlinkSessionJob`,  is pluggable component based on the 
[Plugins](https://nightlies.apache.org/flink/flink-docs-master/docs/deployment/filesystems/plugins)
 mechanism. During development, we can custom the implementation of 
`FlinkResourceValidator` and make sure to retain the service definition in 
`META-INF/services`. 
+To use a pluggable validator, copy the corresponding JAR file to a directory 
under plugins directory which is `/opt/flink/plugins` at default. The following 
steps demonstrate the custom validator implementation process and resources of 
`FlinkDeployment` and `FlinkSessionJob` are validated in custom way with the 
custom validator:
+
+1. Implement `FlinkResourceValidator` interface:
+    ```java
+   package org.apache.flink.kubernetes.operator.validation;
+   
+   import org.apache.flink.kubernetes.operator.crd.FlinkDeployment;
+   import org.apache.flink.kubernetes.operator.crd.FlinkSessionJob;
+   
+   import java.util.Optional;
+   
+   /** Custom validator implementation of {@link FlinkResourceValidator}. */
+   public class CustomValidator implements FlinkResourceValidator {
+   
+       @Override
+       public Optional<String> validateDeployment(FlinkDeployment deployment) {
+           return Optional.empty();
+       }
+   
+       @Override
+       public Optional<String> validateSessionJob(
+               FlinkSessionJob sessionJob, Optional<FlinkDeployment> session) {
+           return Optional.empty();
+       }
+   }
+    ```
+
+2. Create service definition file 
`org.apache.flink.kubernetes.operator.validation.FlinkResourceValidator` in 
`META-INF/services`.   With custom `FlinkResourceValidator` implementation, the 
service definition describes as follows:
+   ```text
+   org.apache.flink.kubernetes.operator.validation.CustomValidator
+   ```
+
+3. Use the Maven tool to package the project and upload the generated JAR to 
the `/opt/flink/plugins` directory of the mirror.

Review Comment:
   Can we directly add an example to tell user can `FROM` the 
`flink-kubernetes-operator` official image and `COPY` the plugin jars to the 
plugin dir. In this way, user can make their own operator image with custom 
validator plugin, Right?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to