首页 > 编程语言 > 详细

java代码实现helm部署

时间:2021-02-03 23:32:56      阅读:116      评论:0      收藏:0      [点我收藏+]

1 pom文件加入依赖

<dependency>
    <groupId>org.microbean</groupId>
    <artifactId>microbean-helm</artifactId>
    <version>2.8.2.1.1.0</version>
    <exclusions>
        <exclusion>
            <groupId>io.netty</groupId>
            <artifactId>netty-tcnative-boringssl-static</artifactId>
        </exclusion>
    </exclusions>
    <type>jar</type>
</dependency>

代码实现

final URI uri = URI.create("https://kubernetes-charts.storage.googleapis.com/wordpress-0.6.6.tgz");
final URL url = uri.toURL();
Chart.Builder chart = null;
try (final URLChartLoader chartLoader = new URLChartLoader()) {
  chart = chartLoader.load(url);
}

try (final DefaultKubernetesClient client = new DefaultKubernetesClient();
     final Tiller tiller = new Tiller(client);
     final ReleaseManager releaseManager = new ReleaseManager(tiller)) {

  final InstallReleaseRequest.Builder requestBuilder = InstallReleaseRequest.newBuilder();
  assert requestBuilder != null;
  requestBuilder.setTimeout(300L);
  requestBuilder.setName("test-charts"); // Set the Helm release name
  requestBuilder.setWait(true); // Wait for Pods to be ready


  final Map<String, Object> yaml = new LinkedHashMap<>();
  yaml.put("wordpressEmail", "sample@example.com");
  final String yamlString = new Yaml().dump(yaml);
  requestBuilder.getValuesBuilder().setRaw(yamlString);
  
  // Install the loaded chart with the user-supplied overrides.
  final Future<InstallReleaseResponse> releaseFuture = releaseManager.install(requestBuilder, chart);

运行时可能会报NoSuchMethodError,原因大部分是他的包太老了,自己导入新的grpc包使用即可

java代码实现helm部署

原文:https://www.cnblogs.com/wpyblog/p/14370058.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!