@Override
  protected Map<String, String> doScaleOut(Resource resource) {
    Map<String, String> groupProperties = Maps.newHashMap();
    groupProperties.putAll(getContainerProperties());
    groupProperties.putAll(resource.getProperties());

    Map<String, Object> argsList = generatePodStartArgs(resource, groupProperties);
    String image = argsList.get(IMAGE).toString();
    String namespace = argsList.get(NAMESPACE).toString();
    String pullPolicy = argsList.get(PULL_POLICY).toString();
    List<LocalObjectReference> imagePullSecretsList =
        (List<LocalObjectReference>) argsList.get(PULL_SECRETS);
    int cpuLimit = (int) argsList.get("cpuLimit");
    long memory = (long) argsList.get(MEMORY_PROPERTY);
    String groupName = argsList.get("groupName").toString();
    String resourceId = argsList.get("resourceId").toString();
    String startUpArgs = argsList.get("startUpArgs").toString();

    String kubernetesName = NAME_PREFIX + resourceId;
    Deployment deployment;

    if (null != groupProperties.get(PODTEMPLATE)) {
      // configure the podTemplate read from config
      PodTemplate podTemplate = initPodTemplateFromLocal(groupProperties);

      deployment =
          initPodTemplateFromFrontEnd(
              podTemplate,
              image,
              pullPolicy,
              cpuLimit,
              groupName,
              resourceId,
              startUpArgs,
              memory,
              imagePullSecretsList);
    } else {
      deployment =
          initPodTemplateWithoutConfig(
              image,
              pullPolicy,
              cpuLimit,
              groupName,
              resourceId,
              startUpArgs,
              memory,
              imagePullSecretsList);
    }

    client.apps().deployments().inNamespace(namespace).resource(deployment).create();
    Map<String, String> startupProperties = Maps.newHashMap();
    startupProperties.put(NAMESPACE, namespace);
    startupProperties.put(KUBERNETES_NAME_PROPERTIES, kubernetesName);
    return startupProperties;
  }
Kubernetes Optimizer Container with Standalone Optimizer
amoro-ams/src/main/java/org/apache/amoro/server/manager/KubernetesOptimizerContainer.java