Skip to content

Commit

Permalink
Config admin CLI (apache#6681)
Browse files Browse the repository at this point in the history
Signed-off-by: xiaolong.ran <rxl@apache.org>


### Motivation

Sometimes, users want to use a customized admin CLI tool. Currently, in the k8s runtime, hardcode is used in `getdownloadcommands()`. This change will support users to configure the CLI tool they want. The default value is: `/bin/pulsar-admin`.

### Modifications

- Support config admin CLI
  • Loading branch information
wolfstudy authored and huangdx0726 committed Aug 24, 2020
1 parent 3f8f034 commit 312e155
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ pulsar-broker/tmp.*
pulsar-broker/src/test/resources/log4j2.yaml
pulsar-functions/worker/test-tenant/
pulsar-broker/src/test/resources/pulsar-functions-api-examples.jar
pulsar-functions/runtime/src/test/resources/
pulsar-functions/worker/src/test/resources/
*.log
*.nar

Expand Down
3 changes: 3 additions & 0 deletions conf/functions_worker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ functionRuntimeFactoryConfigs:
# ram: 1073741824
# disk: 10737418240

## Config admin CLI
#configAdminCLI:

############################################
# security settings for worker service
############################################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ public class KubernetesRuntime implements Runtime {
private final String pulsarDockerImageName;
private final String imagePullPolicy;
private final String pulsarRootDir;
private final String configAdminCLI;
private final String userCodePkgUrl;
private final String originalCodeFileName;
private final String pulsarAdminUrl;
Expand Down Expand Up @@ -160,6 +161,7 @@ public class KubernetesRuntime implements Runtime {
String instanceFile,
String extraDependenciesDir,
String logDirectory,
String configAdminCLI,
String userCodePkgUrl,
String originalCodeFileName,
String pulsarServiceUrl,
Expand All @@ -184,6 +186,7 @@ public class KubernetesRuntime implements Runtime {
this.pulsarDockerImageName = pulsarDockerImageName;
this.imagePullPolicy = imagePullPolicy;
this.pulsarRootDir = pulsarRootDir;
this.configAdminCLI = configAdminCLI;
this.userCodePkgUrl = userCodePkgUrl;
this.originalCodeFileName = pulsarRootDir + "/" + originalCodeFileName;
this.pulsarAdminUrl = pulsarAdminUrl;
Expand Down Expand Up @@ -804,7 +807,7 @@ private List<String> getDownloadCommand(String tenant, String namespace, String
&& isNotBlank(authConfig.getClientAuthenticationParameters())
&& instanceConfig.getFunctionAuthenticationSpec() != null) {
return Arrays.asList(
pulsarRootDir + "/bin/pulsar-admin",
pulsarRootDir + configAdminCLI,
"--auth-plugin",
authConfig.getClientAuthenticationPlugin(),
"--auth-params",
Expand All @@ -825,7 +828,7 @@ && isNotBlank(authConfig.getClientAuthenticationParameters())
}

return Arrays.asList(
pulsarRootDir + "/bin/pulsar-admin",
pulsarRootDir + configAdminCLI,
"--admin-url",
pulsarAdminUrl,
"functions",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public class KubernetesRuntimeFactory implements RuntimeFactory {
private String pulsarDockerImageName;
private String imagePullPolicy;
private String pulsarRootDir;
private String configAdminCLI;
private String pulsarAdminUrl;
private String pulsarServiceUrl;
private String pythonDependencyRepository;
Expand Down Expand Up @@ -151,6 +152,11 @@ public void initialize(WorkerConfig workerConfig, AuthenticationConfig authentic
} else {
this.pulsarRootDir = "/pulsar";
}
if (!isEmpty(factoryConfig.getConfigAdminCLI())) {
this.configAdminCLI = factoryConfig.getConfigAdminCLI();
} else {
this.configAdminCLI = "/bin/pulsar-admin";
}

this.submittingInsidePod = factoryConfig.getSubmittingInsidePod();
this.installUserCodeDependencies = factoryConfig.getInstallUserCodeDependencies();
Expand Down Expand Up @@ -270,6 +276,7 @@ public KubernetesRuntime createContainer(InstanceConfig instanceConfig, String c
instanceFile,
extraDependenciesDir,
logDirectory,
configAdminCLI,
codePkgUrl,
originalCodeFileName,
pulsarServiceUrl,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ public class KubernetesRuntimeFactoryConfig {
+ " customized image in `pulsarDockerImageName`, you need to set this setting accordingly"
)
protected String pulsarRootDir;
@FieldContext(
doc = "The config admin CLI allows users to customize the configuration of the admin cli tool, such as:"
+ " `/bin/pulsar-admin and /bin/pulsarctl`. By default it is `/bin/pulsar-admin`. If you want to use `pulsarctl` "
+ " you need to set this setting accordingly"
)
protected String configAdminCLI;
@FieldContext(
doc = "This setting only takes effects if `k8Uri` is set to null. If your function worker is"
+ " also running as a k8s pod, set this to `true` is let function worker to submit functions to"
Expand Down

0 comments on commit 312e155

Please sign in to comment.