Using Helm to Deploy Blockchain to Kubernetes

Using Helm to Deploy Blockchain to Kubernetes

 

Background

Webjet is an online travel agency responsible for managing thousands of travel bookings daily in Australia and New Zealand. Over the last year, Microsoft and Webjet have collaborated to help Webjet solve inefficiencies in the processing and management of hotel bookings by leveraging blockchain technology. You can learn more about our partnership from the press release. For more technical details watch this talk from Build 2017.

As Webjet continued to grow their blockchain deployment, they began to hit several issues with their Infrastructure-as-a-Service (IaaS) architecture. We recently worked with Webjet to help migrate their deployment to Kubernetes. In this code story, we’ll share the lessons learned from migrating from IaaS to Kubernetes, explain how we used Helm to deploy a private Ethereumnetwork to Kubernetes, and show how you can use Helm to deploy your own private Ethereum network.

The Road to Kubernetes

Due to Virtual Machine Scale Sets’ (VMSS) feature of autoscaling based on a variety of metrics, Webjet chose to host their private Ethereum networks on a series of VMSS with each one running Docker containers orchestrated by Docker Compose. A generalized version of Webjet’s Azure ARM deployment is available on GitHub. However, in Webjet’s path to moving this to production, some deficiencies in their IaaS-based architecture became apparent.

Difficult to scale

Docker Compose supports running multiple replicas for a container; however, in order to load balance across replicas, management of container-host port mappings is required.

At the node-level, as VMSS’ autoscale feature scales out the entire node, VMSS work optimally against homogeneous workloads. With several different services running on the machine, scaling up/down a VMSS would affect all running services on that machine.  Alternatively, the architecture could be separated into several Docker Compose files and thereby several VMSS, but this would require a significant amount of pre-planning to ensure a proper balance of hardware needs and costs.

Error-prone upgrades

Upgrading services meant SSH-ing into the VMs, running docker-compose stop, downloading the new Docker Compose manifest, and then subsequently running docker-compose up. Configuration management tools such as SaltStack could be used to automate this process, but the process itself is very custom and has a high potential for error.

For the above reasons, the Webjet team decided to leverage Kubernetes through AKS to help automate deployment, scaling, and orchestration of the application. With Kubernetes, Webjet is able to scale up/down certain applications and take advantage of Kubernetes’ native support for rolling upgrades.

Architecture

After migrating their existing Docker Compose manifests to Kubernetes, we landed on the following architecture:

The diagram above shows the architecture of the private Ethereum network when mapped to Kubernetes constructs. The blue represents Kubernetes Services, the red represents Kubernetes Deployments, whereas the green and yellow are Kubernetes Secrets and ConfigMapsrespectively.

Every time Webjet needed to deploy a new Ethereum network, a series of configuration updates needed to be made to the YAML definitions. These changes included the Ethereum genesis file, application secrets, and Geth private keys. Webjet initially accomplished this task using shell scripts that would search and replace configuration values and then execute the deployment using  kubectl create.  During a hackfest with Webjet, we worked together to instead use Helm to manage the templatization of the YAML definitions.

Helm

Helm is a package manager for Kubernetes. The project was initially created by Deis and has since been donated to the Cloud Native Computing Foundation (CNCF). Sidenote, the lovely folks of Deis are now part of Microsoft. Typically, an application is composed of a combination of services, deployments, secrets, etc. Instead of managing these Kubernetes resources individually, Helm offers a higher-level construct (known as charts) to manage your entire application. With Helm, you can create, upgrade, and rollback entire applications, and easily share applications/charts with peers and the greater community.

Creating a Chart

Working with Webjet, we created a Helm chart to deploy a private Ethereum network. To create a Helm chart, install the Helm CLI, and run helm create  to scaffold a new chart. To migrate your existing YAML manifests, copy the manifests to the Helm folder structure and add the following labels outlined here: Chart Standard Labels. These labels are not required to deploy charts but are recommended for consistency. The next step is to templatize configurations and settings that can be overridden. For more details, see the Chart Best Practices Guide.

With Helm, each chart is an individually-manageable unit. Webjet separated their architecture into multiple Helm charts such that they could be individually upgradeable. For instance, we had separate charts for the Ethereum network (Miners, EthStats, Bootnode), another for the Blockchain Watcher, one for deploying their Storage (SQL), etc. Artifacts that were shared across multiple Helm charts (e.g., Secrets, ConfigMaps) were marked as dependencies in the Chart’s requirement.yaml.

Deploying a Chart

Helm is comprised of two components: a client CLI (helm) and a server (tiller). One of the niceties of deploying a Kubernetes cluster on Azure through either acs-engine or ACS/AKS, is that by default the cluster will be pre-provisioned with Tiller. For a cluster that has not yet been initialized, you can do so with helm init.

To install a chart, you can run helm install, which will search for and install a chart from the official Charts repository. The Ethereum chart we developed in concert with Webjet is available on GitHub, and once this pull request is merged, you’ll be able to install a private Ethereum network onto your Kubernetes cluster using:

 

1

helm install incubator/ethereum

Until the pull request is merged, I have made available the Chart archive:

 

1

2

3

4

helm install https://japoonhelmstrg.blob.core.windows.net/public/ethereum-0.1.0.tgz

   --set geth.account.publicKey=[PUBLIC_KEY]

   --set <span class="blob-code-inner annotated">geth.account.privateKey</span>=[PRIVATE_KEY]

   --set <span class="blob-code-inner annotated">geth.account.<span class="">secret</span></span>=[SECRET]

Note that geth.account.publicKey, geth.account.privateKey, and geth.account.secret are required configurations. To create a new Geth account, please refer to https://github.com/ethereum/go-ethereum/wiki/Managing-your-accounts.

helm install incubator/ethereum

You now have a private Ethereum network running inside your Kubernetes cluster.

To clarify, this chart deploys a private Ethereum network that is not connected to MainNet.

With Webjet, their charts were committed to a Git repository and all deployments were initiated with Helm by supplying a local filepath to the Chart. However, a private Helm Charts repositorycan be easily provisioned to host your private Charts.

Summary

This code story explains how Webjet migrated their deployment to Kubernetes and shows how Helm can be applied to simplify the deployment and management of applications hosted on Kubernetes. Using Kubernetes on Azure has greatly simplified Webjet’s deployment process. Our solution using Helm removed the need for Webjet to manage their own deployment scripts and makes it possible to leverage the many existing charts made available by the community.

Charts can be submitted to the Charts registry and shared with the community. The Ethereum chart shown in the article is open-sourced, and there is an open pull request to add it to the Charts registry. This Chart deploys a simplified private Ethereum network; in order to deploy a network in a more highly available manner, please refer to this chart. If you have any questions or feedback on this code story, please reach out in the comments below.

Resources

转载于:https://my.oschina.net/u/2306127/blog/1788638

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
辽B代驾管理系统对代驾订单管理、用户咨询管理、代驾订单评价管理、代驾订单投诉管理、字典管理、论坛管理、公告管理、新闻信息管理、司机管理、用户管理、管理员管理等进行集中化处理。经过前面自己查阅的网络知识,加上自己在学校课堂上学习的知识,决定开发系统选择小程序模式这种高效率的模式完成系统功能开发。这种模式让操作员基于浏览器的方式进行网站访问,采用的主流的Java语言这种面向对象的语言进行辽B代驾管理系统程序的开发,在数据库的选择上面,选择功能强大的Mysql数据库进行数据的存放操作。辽B代驾管理系统的开发让用户查看代驾订单信息变得容易,让管理员高效管理代驾订单信息。 辽B代驾管理系统具有管理员角色,用户角色,这几个操作权限。 辽B代驾管理系统针对管理员设置的功能有:添加并管理各种类型信息,管理用户账户信息,管理代驾订单信息,管理公告信息等内容。 辽B代驾管理系统针对用户设置的功能有:查看并修改个人信息,查看代驾订单信息,查看公告信息等内容。 辽B代驾管理系统针对管理员设置的功能有:添加并管理各种类型信息,管理用户账户信息,管理代驾订单信息,管理公告信息等内容。 辽B代驾管理系统针对用户设置的功能有:查看并修改个人信息,查看代驾订单信息,查看公告信息等内容。 系统登录功能是程序必不可少的功能,在登录页面必填的数据有两项,一项就是账号,另一项数据就是密码,当管理员正确填写并提交这二者数据之后,管理员就可以进入系统后台功能操作区。项目管理页面提供的功能操作有:查看代驾订单,删除代驾订单操作,新增代驾订单操作,修改代驾订单操作。公告信息管理页面提供的功能操作有:新增公告,修改公告,删除公告操作。公告类型管理页面显示所有公告类型,在此页面既可以让管理员添加新的公告信息类型,也能对已有的公告类型信息执行编辑更新,失效的公告类型信息也能让管理员快速删除。新闻管理页面,此页面提供给管理员的功能有:新增新闻,修改新闻,删除新闻。新闻类型管理页面,此页面提供给管理员的功能有:新增新闻类型,修改新闻类型,删除新闻类型。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值