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文件中
c.运行protobuf:compile taget文件夹能找到生成的java文件,然后考到src/main/java 如图:
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