Skip to content

Commit

Permalink
[hotfix] k8s helm support using the default Kubernetes client configu…
Browse files Browse the repository at this point in the history
…ration.
  • Loading branch information
czy006 committed Oct 14, 2024
1 parent 4e7fc9b commit 8a50d88
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import io.fabric8.kubernetes.api.model.apps.DeploymentBuilder;
import io.fabric8.kubernetes.api.model.apps.DeploymentSpec;
import io.fabric8.kubernetes.client.Config;
import io.fabric8.kubernetes.client.ConfigBuilder;
import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClientBuilder;
import org.apache.amoro.resource.Resource;
Expand All @@ -51,6 +52,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;

/** Kubernetes Optimizer Container with Standalone Optimizer */
Expand All @@ -77,8 +79,12 @@ public class KubernetesOptimizerContainer extends AbstractResourceContainer {
public void init(String name, Map<String, String> containerProperties) {
super.init(name, containerProperties);
// start k8s job using k8s client
String kubeConfigPath = checkAndGetProperty(containerProperties, KUBE_CONFIG_PATH);
Config config = Config.fromKubeconfig(getKubeConfigContent(kubeConfigPath));
Optional<String> kubeConfigPath =
Optional.ofNullable(containerProperties.get(KUBE_CONFIG_PATH));
Config config =
kubeConfigPath
.map(path -> Config.fromKubeconfig(getKubeConfigContent(path)))
.orElseGet(() -> new ConfigBuilder().build());
this.client = new KubernetesClientBuilder().withConfig(config).build();
}

Expand Down
3 changes: 2 additions & 1 deletion charts/amoro/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,8 @@ optimizer:
enabled: true
properties:
namespace: "default"
kube-config-path: "~/.kube/config"
# if service account rbac not have, need kube config set in optimizer deployment
#kube-config-path: "~/.kube/config"
image: "apache/amoro:latest"
pullPolicy: "IfNotPresent"
extra: []
Expand Down

0 comments on commit 8a50d88

Please sign in to comment.