public Deployment initPodTemplateFromFrontEnd(
      PodTemplate podTemplate,
      String image,
      String pullPolicy,
      int cpuLimit,
      String groupName,
      String resourceId,
      String startUpArgs,
      long memory,
      List<LocalObjectReference> imagePullSecretsList) {
    podTemplate
        .getTemplate()
        .getMetadata()
        .setLabels(
            new HashMap<String, String>() {
              {
                put("app", NAME_PREFIX + resourceId);
                put("AmoroOptimizerGroup", groupName);
                put("AmoroResourceId", resourceId);
              }
            });

    Container container = new Container();
    container.setName("optimizer");
    container.setImage(image);
    container.setImagePullPolicy(pullPolicy);
    container.setCommand(new ArrayList<>(Arrays.asList("sh", "-c", startUpArgs)));

    ResourceRequirements resourceRequirements = new ResourceRequirements();
    resourceRequirements.setLimits(
        ImmutableMap.of(
            "memory", new Quantity(memory + "Mi"),
            "cpu", new Quantity(cpuLimit + "")));
    resourceRequirements.setRequests(
        ImmutableMap.of(
            "memory", new Quantity(memory + "Mi"),
            "cpu", new Quantity(cpuLimit + "")));
    container.setResources(resourceRequirements);

    podTemplate.getTemplate().getSpec().getContainers().set(0, container);

    if (!imagePullSecretsList.isEmpty()) {
      podTemplate.getTemplate().getSpec().setImagePullSecrets(imagePullSecretsList);
    }

    DeploymentSpec deploymentSpec = new DeploymentSpec();
    deploymentSpec.setTemplate(podTemplate.getTemplate());

    LabelSelector labelSelector = new LabelSelector();
    labelSelector.setMatchLabels(
        new HashMap<String, String>() {
          {
            put("app", NAME_PREFIX + resourceId);
          }
        });

    deploymentSpec.setSelector(labelSelector);
    deploymentSpec.setReplicas(1);

    Deployment deployment = new Deployment();
    deployment.setSpec(deploymentSpec);
    ObjectMeta deploymentMetadata = new ObjectMeta();
    deploymentMetadata.setName(NAME_PREFIX + resourceId);
    deployment.setMetadata(deploymentMetadata);

    return deployment;
  }
Kubernetes Optimizer Container with Standalone Optimizer
amoro-ams/src/main/java/org/apache/amoro/server/manager/KubernetesOptimizerContainer.java