<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Kirill Kuznetsov</title>
    <description>The latest articles on Forem by Kirill Kuznetsov (@dragonsmith).</description>
    <link>https://forem.com/dragonsmith</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F74556%2F7540143a-4c85-489f-8251-5cdabb3fbafa.jpeg</url>
      <title>Forem: Kirill Kuznetsov</title>
      <link>https://forem.com/dragonsmith</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/dragonsmith"/>
    <language>en</language>
    <item>
      <title>Painless migration of existing Helm's Tiller setup to Kubernetes Secrets</title>
      <dc:creator>Kirill Kuznetsov</dc:creator>
      <pubDate>Wed, 04 Jul 2018 16:49:22 +0000</pubDate>
      <link>https://forem.com/evilmartians/painless-migration-of-existing-helms-tiller-setup-to-kubernetes-secrets-d1p</link>
      <guid>https://forem.com/evilmartians/painless-migration-of-existing-helms-tiller-setup-to-kubernetes-secrets-d1p</guid>
      <description>&lt;p&gt;Meet a command-line tool that solves a security problem with &lt;a href="https://github.com/kubernetes/helm"&gt;Helm&lt;/a&gt; installations by replacing unencrypted ConfigMaps for &lt;a href="https://github.com/kubernetes/helm/blob/master/docs/architecture.md#components"&gt;Tiller&lt;/a&gt; with industry-standard &lt;a href="https://kubernetes.io/docs/concepts/configuration/secret/"&gt;Kubernetes Secrets&lt;/a&gt;. &lt;/p&gt;

&lt;h2&gt;
  
  
  Helm and its security options
&lt;/h2&gt;

&lt;p&gt;If you are a Helm user, you perhaps stumbled upon an excellent &lt;a href="https://github.com/kubernetes/helm/blob/master/docs/securing_installation.md"&gt;"Securing Helm installation"&lt;/a&gt; write-up in the official repository. If you were not aware of this document, take time to read it, that's a good starting point. &lt;/p&gt;

&lt;p&gt;To summarize, there are &lt;a href="https://github.com/kubernetes/helm/blob/master/docs/securing_installation.md#understanding-the-security-context-of-your-cluster"&gt;four main points&lt;/a&gt; to consider when securing your installation:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Role-based access control, or RBAC&lt;/li&gt;
&lt;li&gt;Tiller's gRPC endpoint and its usage by Helm&lt;/li&gt;
&lt;li&gt;Tiller Release Information&lt;/li&gt;
&lt;li&gt;Helm charts&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Tiller Release Information is something that I want to talk about further.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is the problem with Tiller releases?
&lt;/h2&gt;

&lt;p&gt;Historically, for each "release," which is basically any configuration or version update of an application, Tiller creates a &lt;a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/"&gt;ConfigMap&lt;/a&gt; containing all operational data.&lt;/p&gt;

&lt;p&gt;It is mostly OK, except that applications often need sensitive data to operate (passwords, tokens) and ConfigMaps are not the best format to store them: they are persisted in a Kubernetes runtime DB (Etcd) as is, without any encryption. Any person who has access to Etcd or even its dump can easily peek inside. That should not be allowed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Kubernetes Secrets to the rescue
&lt;/h2&gt;

&lt;p&gt;The option to encrypt stored Kubernetes Secrets was introduced in Kubernetes &lt;code&gt;1.7&lt;/code&gt;. Tiller has support for Secrets as backend storage starting from version &lt;code&gt;2.7.0&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;If you are making a new Helm installation, use &lt;code&gt;helm init --override=...&lt;/code&gt; option described &lt;a href="https://github.com/kubernetes/helm/blob/master/docs/install.md#using---override"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;E.g.:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;helm init &lt;span class="nt"&gt;--override&lt;/span&gt; &lt;span class="s1"&gt;'spec.template.spec.containers[0].command'&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'{/tiller,--storage=secret}'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;For the sake of brevity, I am omitting other &lt;code&gt;helm init&lt;/code&gt; options that you might need&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  But what if you don't have the luxury to start from scratch?
&lt;/h2&gt;

&lt;p&gt;Secrets are great and easy to use for new installations, but if you ever wanted to migrate an existing cluster that manages a pack of your production releases from ConfigMaps to Secrets and avoid downtime—you were out of luck. Not anymore. &lt;/p&gt;

&lt;p&gt;I wrote a small tool that automates the otherwise daunting manual process. Meet &lt;a href="https://github.com/dragonsmith/tiller-releases-converter"&gt;tiller-releases-converter&lt;/a&gt;!&lt;/p&gt;

&lt;h2&gt;
  
  
  Using tiller-releases-converter
&lt;/h2&gt;

&lt;p&gt;After you &lt;a href="https://github.com/dragonsmith/tiller-releases-converter#installation"&gt;install the app&lt;/a&gt;, upgrading your Helm's Tiller setup to Secrets storage backend (with zero-downtime!) is a matter of executing three shell commands in the following order:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;tiller-releases-converter convert &lt;span class="c"&gt;# Will create a Secret for every ConfigMap release&lt;/span&gt;
tiller-releases-converter secure-tiller &lt;span class="c"&gt;# Will update tiller deployment with "--storate=secret"&lt;/span&gt;
tiller-releases-converter cleanup &lt;span class="c"&gt;# Deletes tiller's ConfigMaps&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There is a 4th command called &lt;code&gt;list&lt;/code&gt; - it just prints Tiller's current ConfigMaps:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;tiller-releases-converter list
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;I've found these Tiller's ConfigMap releases for you:

kube-state-metrics.v1
kube-state-metrics.v2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There are some global command line arguments for your convenience:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Flags:
      --context string      kube config context
  -h, --help                help for tiller-releases-converter
  -c, --kubeconfig string   config file (default is $HOME/.kube/config)
  -n, --namespace string    tiller namespace (default is kube-system)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Spread the word
&lt;/h2&gt;

&lt;p&gt;Thank you for reading! I hope &lt;a href="https://github.com/dragonsmith/tiller-releases-converter"&gt;tiller-releases-converter&lt;/a&gt; will save you some valuable time and put your mind at ease. If you run into any trouble or have a suggestion on how to improve the tool—feel free to open the issue! &lt;/p&gt;

&lt;p&gt;P.S.&lt;/p&gt;

&lt;p&gt;Keep in mind that the ConfigMaps to Secrets migration will no longer be an issue once the &lt;a href="https://github.com/helm/community/blob/master/helm-v3/000-helm-v3.md"&gt;Helm 3&lt;/a&gt; arrives: next major release of the tool will not include Tiller at all. The release date, however, is not yet announced. Follow official &lt;a href="https://github.com/kubernetes/helm/milestones"&gt;milestones&lt;/a&gt; to keep yourself in the loop!&lt;/p&gt;

&lt;p&gt;Read more developer articles by &lt;a href="https://evilmartians.com/"&gt;Evil Martians&lt;/a&gt; on &lt;a href="https://dev.to/evilmartians"&gt;dev.to&lt;/a&gt; and in &lt;a href="https://evilmartians.com/chronicles"&gt;Martian Chronicles&lt;/a&gt; &lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>helm</category>
      <category>security</category>
      <category>devops</category>
    </item>
  </channel>
</rss>
