{"id":353,"date":"2018-10-16T10:58:38","date_gmt":"2018-10-16T10:58:38","guid":{"rendered":"https:\/\/www.appservgrid.com\/paw93\/?p=353"},"modified":"2018-10-17T08:27:01","modified_gmt":"2018-10-17T08:27:01","slug":"using-helm-without-tiller-giant-swarm","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw93\/index.php\/2018\/10\/16\/using-helm-without-tiller-giant-swarm\/","title":{"rendered":"Using Helm without Tiller &#8211; Giant Swarm"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/blog.giantswarm.io\/assets\/2018\/05\/what-you-yaml-is-what-you-get.png\" alt=\"What You Yaml is What You Get\" \/><\/p>\n<p>When starting with Kubernetes, learning how to write manifests and bringing them to the apiserver is usually the first step. Most probably kubectl apply is the command for this.<\/p>\n<p>The nice thing here is that all the things you want to run on the cluster are described precisely and you can easily inspect what will be sent to the apiserver.<\/p>\n<p>After the joy of understanding how this works, it quickly becomes cumbersome to copy your manifests around and edit the same fields over different files to get a slightly adjusted deployment out.<\/p>\n<p>The obvious solution to this is templating, and Helm is the most well-known solution in the Kubernetes ecosystem to help out with this. Most how-tos directly advise you to install the clusterside Tiller component and unfortunately this comes with a bit of operational overhead and even more importantly you also need to take care to <a href=\"https:\/\/github.com\/kubernetes\/helm\/blob\/master\/docs\/securing_installation.md#best-practices-for-securing-helm-and-tiller\">secure access to Tiller<\/a>, since it is a component running in your cluster with full admin rights.<\/p>\n<p>If you want to see what actually will be sent to the cluster you can leave out Tiller and use Helm locally just for the templating and using kubectl apply in the end.<\/p>\n<p>There is no need for Tiller and there are roughly three steps to follow:<\/p>\n<ol>\n<li>Fetching the chart templates<\/li>\n<li>Rendering the template with configurable values<\/li>\n<li>Applying the result to the cluster<\/li>\n<\/ol>\n<p>This way you benefit from the large amount of maintained Charts the community is building, but have all the building blocks of an application in front of you. When keeping them in a git repo it is easy to compare changes from new releases with the current manifests you used to deploy on your cluster. This approach might nowadays be called <a href=\"https:\/\/thenewstack.io\/gitops-kubernetes-devops-iteration-focused-declarative-infrastructure\/\">GitOps<\/a>.<\/p>\n<p>A possible directory structure could look like this:<\/p>\n<p>kubernetes-deployment\/<br \/>\ncharts\/<br \/>\nvalues\/<br \/>\nmanifests\/<\/p>\n<p>For the following steps the <a href=\"https:\/\/github.com\/kubernetes\/helm\/blob\/master\/docs\/install.md#from-the-binary-releases\">helm client needs to be installed<\/a> locally.<\/p>\n<h2>Fetching the chart templates<\/h2>\n<p>To fetch the source code of the charts the url to the repository is needed, also the chart name and the wanted version:<\/p>\n<p>helm fetch<br \/>\n&#8211;repo https:\/\/kubernetes-charts.storage.googleapis.com<br \/>\n&#8211;untar<br \/>\n&#8211;untardir .\/charts<br \/>\n&#8211;version 5.5.3<br \/>\nprometheus<\/p>\n<p>After this the template files can be inspected under .\/charts\/prometheus.<\/p>\n<h2>Rendering the template with configurable values<\/h2>\n<p>The default values.yaml should be copied to a different location for editing so it is not overwritten when updating the chart source.<\/p>\n<p>cp .\/charts\/prometheus\/values.yaml<br \/>\n.\/values\/prometheus.yaml<\/p>\n<p>The copied prometheus.yaml can now be adjusted as needed. To render the manifests from the template source with the potentially edited values file:<\/p>\n<p>helm template<br \/>\n&#8211;values .\/values\/prometheus.yaml<br \/>\n&#8211;output-dir .\/manifests<br \/>\n.\/charts\/prometheus<\/p>\n<h2>Applying the result to the cluster<\/h2>\n<p>Now the resulting manifests can be thoroughly inspected and finally be applied to the cluster:<\/p>\n<p>kubectl apply &#8211;recursive &#8211;filename .\/manifests\/prometheus<\/p>\n<h2>Conclusion<\/h2>\n<p>With just the standard helm command we can closely check the whole chain from the charts content to the app coming up on our cluster. To make these steps even more easy I have put them in a simple plugin for helm and named it <a href=\"https:\/\/github.com\/giantswarm\/helm-nomagic\">nomagic<\/a>.<\/p>\n<h2>Caveats<\/h2>\n<p>There might be dragons. It might be, that an application needs different kinds of resources that depend on each other. For example applying a Deployment that references a ServiceAccount won\u2019t work until that is present. As a workaround the filename for the ServiceAccounts manifest unter manifests\/ could be prefixed with 1- since kubectl apply progresses over files in alphabetical order. This is not needed in setups with Tiller, so it is usually not considered in the upstream charts. Alternatively run kubectl apply twice to create all independent objects in the first run. The dependent ones will show up after the second run.<\/p>\n<p>And obviously you lose features that Tiller itself provides. According to the <a href=\"https:\/\/github.com\/kubernetes-helm\/community\/blob\/master\/helm-v3\/000-helm-v3.md\">Helm 3 Design Proposal<\/a> these will be provided in the long run by the Helm client itself and an optional <a href=\"https:\/\/github.com\/kubernetes-helm\/community\/blob\/master\/helm-v3\/008-controller.md\">Helm controller<\/a>. With the release of Helm 3 the nomagic plugin won\u2019t be needed, but it also might not function any more since plugins need to be <a href=\"https:\/\/github.com\/kubernetes-helm\/community\/blob\/master\/helm-v3\/005-plugins.md#lua-plugins\">implemented in Lua<\/a>. So grab it while it\u2019s useful!<\/p>\n<p>Please share your thoughts about this, other caveats or ideas to improve.<\/p>\n<p>And as always: If you\u2019re interested in how Giant Swarm can run your Kubernetes on-prem or in the cloud contact us today to get started.<\/p>\n<h2>Further Reading<\/h2>\n<ul>\n<li><a href=\"https:\/\/github.com\/kubernetes\/community\/blob\/master\/contributors\/design-proposals\/architecture\/declarative-application-management.md\">Declarative application management in Kubernetes<\/a><\/li>\n<li><a href=\"https:\/\/docs.google.com\/presentation\/d\/10dp4hKciccincnH6pAFf7t31s82iNvtt_mwhlUbeCDw\/edit#slide=id.p\">A Look at the parts of Helm<\/a><\/li>\n<\/ul>\n<p><a href=\"https:\/\/blog.giantswarm.io\/what-you-yaml-is-what-you-get\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>When starting with Kubernetes, learning how to write manifests and bringing them to the apiserver is usually the first step. Most probably kubectl apply is the command for this. The nice thing here is that all the things you want to run on the cluster are described precisely and you can easily inspect what will &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw93\/index.php\/2018\/10\/16\/using-helm-without-tiller-giant-swarm\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Using Helm without Tiller &#8211; Giant Swarm&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-353","post","type-post","status-publish","format-standard","hentry","category-kubernetes"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/posts\/353","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/comments?post=353"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/posts\/353\/revisions"}],"predecessor-version":[{"id":495,"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/posts\/353\/revisions\/495"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/media?parent=353"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/categories?post=353"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/tags?post=353"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}