The Automation Broker works in conjunction with the Kubernetes Service Catalog to make services and applications easily deployable. An end user selects a service to be provisioned, selects a "plan" that describes the level of service (small, large, paid, free, persistent, ephemeral, etc), and then provides any required parameters. In this scenario, Helm charts can be utilized in two possible ways.
- The Automation Broker's "helm registry adapter" can inspect a chart repository and make each discovered chart available as a service class. The chart's
values.yamlfile is made available as a single parameter for a single default plan. - The tool
helm2bundlecreates a Service Bundle image that includes a specific chart. The image can be modified like any service bundle, including changes to metadata such as those inapb.yml.
This post explores how to use Ansible Automation with the latter option to extend the behavior of a helm bundle.
Terms
service bundle - a container image that represents a service class's metadata and behavior.
helm bundle - a service bundle that contains a helm chart.
APB - aka Ansible Playbook bundle, a service bundle that uses Ansible Automation.
Automate Chart Input
Helm charts, which take input as a free-form yaml file, can take advantage of Ansible Automation by being included in a helm bundle that is based on the helm-ansible-base image.
For example, the stable/redis chart has a setting in its values.yml that always needs to be changed in order to run in OpenShift. These are the steps to set that automatically based on Ansible facts.
Make the helm bundle
$ helm fetch stable/redis
$ helm2bundle redis-1.1.12.tar.gz
Create overrides template
The helm-ansible-base image knows to look for a file called overrides.yml.j2. If found, it gets rendered using ansible facts and then passed into helm as a settings file. It should be a subset of the values that are settable for the chart, as described in the chart's values.yaml file.
Ours should look like this:
---{% set secenabled = false if (cluster == "openshift") else true %}
## Pod Security Context
securityContext:
enabled: {{ secenabled }}
Change the Dockerfile
Set the base image in the Dockerfile to helm-ansible-base, and add the overrides template file.
FROM ansibleplaybookbundle/helm-ansible-base
LABEL "com.redhat.apb.spec"=""
COPY redis-1.1.12.tgz /opt/chart.tgz
COPY overrides.yml.j2 /opt/overrides.yml.j2
ENTRYPOINT ["entrypoint.sh"]
Summary
If you build and use that Helm Bundle to provision Redis, it will create a new fact based on the value of an existing fact, and then use the new fact to render a helm settings file. Ansible made it easy for us to dynamically configure this setting. While this example is relatively trivial, the same technique can be employed to do much more sophisticated configuration.
In the next blog post, we will use a similar technique to add rich parameters to a helm bundle, so that the user input experience is easier than editing yaml.
執筆者紹介
チャンネル別に見る
自動化
テクノロジー、チームおよび環境に関する IT 自動化の最新情報
AI (人工知能)
お客様が AI ワークロードをどこでも自由に実行することを可能にするプラットフォームについてのアップデート
オープン・ハイブリッドクラウド
ハイブリッドクラウドで柔軟に未来を築く方法をご確認ください。
セキュリティ
環境やテクノロジー全体に及ぶリスクを軽減する方法に関する最新情報
エッジコンピューティング
エッジでの運用を単純化するプラットフォームのアップデート
インフラストラクチャ
世界有数のエンタープライズ向け Linux プラットフォームの最新情報
アプリケーション
アプリケーションの最も困難な課題に対する Red Hat ソリューションの詳細
仮想化
オンプレミスまたは複数クラウドでのワークロードに対応するエンタープライズ仮想化の将来についてご覧ください