helm java client_Kubernetes helm API 客户端文件生成和远程调用

1.什么是helm?

首先说说什么是helm,引用helm原话“The Kubernetes Package Manager”—— k8s的包管理器。

2.为何要用helm?or 用helm有什么好处?

用过k8s的人都知道,k8s的replicationcontroller、service、pod 这些的创建都需要一个配置的yaml文件,而如果你的环境比较繁琐时你会有很多yaml,如果你想修改某个值且这个值用的地方很多那么问题就来了,真心显得比较麻烦。如果你要更新部署呢?那么就更是麻烦了,而helm可以帮你解决这些麻烦。还有一个优点是helm 已经有很多开源应用的库。

For 想了解更多的同学们:这里有两个连接 一个是k8s的 一个是helm的网站。k8s:点击打开链接  helm github:点击打开链接

3. 使用maven gRPC插件生成helm (Till) 客户端sdk(实际是一堆Java 文件)

a、建立maven 项目配置maven gRPC 插件,配置如下:

xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

4.0.0

chinacloud.com.cn

grpc

jar

0.0.1-SNAPSHOT

grpc Maven Webapp

http://maven.apache.org

1.0.3

junit

junit

3.8.1

test

io.grpc

grpc-netty

${grpc.version}

io.grpc

grpc-protobuf

${grpc.version}

io.grpc

grpc-stub

${grpc.version}

grpc

kr.motd.maven

os-maven-plugin

1.4.1.Final

org.eclipse.m2e

lifecycle-mapping

1.0.0

org.apache.maven.plugins

maven-compiler-plugin

[2.5.1,)

compile

org.xolstice.maven.plugins

protobuf-maven-plugin

0.5.0

com.google.protobuf:protoc:3.0.2:exe:${os.detected.classifier}

grpc-java

io.grpc:protoc-gen-grpc-java:${grpc.version}:exe:${os.detected.classifier}

compile

compile-custom

b.在helm 官网 找到Tiller 的hapi proto文件用来生成java 代码,同时把这些文件放在src/main/proto文件中

81dc6b63117efeb4753f029944a95b64.png

c.运行protobuf:compile taget文件夹能找到生成的java文件,然后考到src/main/java 如图:

a5570325efe87fe1c9dc9b60ed3373b0.png

4.起飞,在main函数调用Tiller的service方法,前提helm以及k8s都已有环境。如下是起飞main方法:

public static void main(String[] args) throws InterruptedException {

//        ManagedChannel channel = ManagedChannelBuilder.forAddress("172.16.101.200", 44134).usePlaintext(true).build();

ManagedChannel channel = NettyChannelBuilder

.forAddress("172.16.80.151", 44134)

.negotiationType(NegotiationType.PLAINTEXT).build();

ReleaseServiceGrpc.ReleaseServiceBlockingStub blockingStub = ReleaseServiceGrpc

.newBlockingStub(channel).withCallCredentials(new CallCredentials(){

@Override

public void applyRequestMetadata(MethodDescriptor, ?> method, Attributes attrs,

Execut

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值