<?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>DEV Community: Lykon Engineering</title>
    <description>The latest articles on DEV Community by Lykon Engineering (@lykon).</description>
    <link>https://dev.to/lykon</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%2Forganization%2Fprofile_image%2F820%2Fc9569636-59a3-4f38-83b2-07335e59ad53.png</url>
      <title>DEV Community: Lykon Engineering</title>
      <link>https://dev.to/lykon</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/lykon"/>
    <language>en</language>
    <item>
      <title>How to upgrade to istio 1.2.4 using Helmfile</title>
      <dc:creator>Italo Vietro</dc:creator>
      <pubDate>Mon, 26 Aug 2019 07:43:10 +0000</pubDate>
      <link>https://dev.to/lykon/how-to-upgrade-to-istio-1-2-4-using-helmfile-3139</link>
      <guid>https://dev.to/lykon/how-to-upgrade-to-istio-1-2-4-using-helmfile-3139</guid>
      <description>&lt;p&gt;We’ve faced an interesting challenge with our istio installation. We were running the istio version 1.1.7 for a while and wanted to upgrade to the most recent stable version. This is an easy task if you follow the upgrade instructions in the &lt;a href="https://istio.io/docs/setup/kubernetes/upgrade/steps/"&gt;istio website&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;We use &lt;a href="https://github.com/roboll/helmfile"&gt;helmfile&lt;/a&gt; to manage the multiple standard applications in our cluster. In this helmfile is our istio installation. Unfortunately, I wasn’t able to find a straightforward way of running &lt;code&gt;helmfile sync&lt;/code&gt; and having the istio installation upgraded.&lt;/p&gt;

&lt;p&gt;I’d like to share with you our step-by-step on how we upgraded our istio version.&lt;/p&gt;

&lt;h2&gt;
  
  
  Helmfile
&lt;/h2&gt;

&lt;p&gt;Prior to the migration, we had a helmfile that declared our istio installation like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;helmDefaults&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;kubeContext&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;my_cluster&lt;/span&gt;
  &lt;span class="na"&gt;atomic&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="no"&gt;true&lt;/span&gt;

&lt;span class="na"&gt;repositories&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;incubator&lt;/span&gt;
  &lt;span class="na"&gt;url&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;https://kubernetes-charts-incubator.storage.googleapis.com/&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;istio&lt;/span&gt;
  &lt;span class="na"&gt;url&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;https://storage.googleapis.com/istio-release/releases/1.1.7/charts/&lt;/span&gt;

&lt;span class="na"&gt;releases&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;istio-init&lt;/span&gt;
    &lt;span class="na"&gt;namespace&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;istio-system&lt;/span&gt;
    &lt;span class="na"&gt;chart&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;istio/istio-init&lt;/span&gt;

  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;istio&lt;/span&gt;
    &lt;span class="na"&gt;namespace&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;istio-system&lt;/span&gt;
    &lt;span class="na"&gt;chart&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;istio/istio&lt;/span&gt;
    &lt;span class="na"&gt;version&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;~1.1.7&lt;/span&gt;
    &lt;span class="na"&gt;values&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;./istio/values.yaml&lt;/span&gt;&lt;span class="pi"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Before jumping into the migration itself I recommend reading the &lt;a href="https://istio.io/docs/setup/kubernetes/upgrade/steps/"&gt;istio upgrade notes&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Step 1 - Check your Custom Resource Definition (CRD)
&lt;/h2&gt;

&lt;p&gt;If you have set up in your file the &lt;code&gt;istio-init&lt;/code&gt; chart, like we did, then you might bump into the famous error of not being able to install the new charts because of existing CRD.&lt;/p&gt;

&lt;p&gt;For us the simplest way was to drop some of them and let the istio chart recreate them.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note that it’s recommended that you backup your current custom resource data, before proceeding with the upgrade.&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;kubectl get crds | &lt;span class="nb"&gt;grep&lt;/span&gt; ‘istio.io&lt;span class="se"&gt;\|&lt;/span&gt;certmanager.k8s.io’ | &lt;span class="nb"&gt;cut&lt;/span&gt; &lt;span class="nt"&gt;-f1-1&lt;/span&gt; &lt;span class="nt"&gt;-d&lt;/span&gt; “.” | &lt;span class="se"&gt;\&lt;/span&gt;
    xargs &lt;span class="nt"&gt;-n1&lt;/span&gt; &lt;span class="nt"&gt;-I&lt;/span&gt;&lt;span class="o"&gt;{}&lt;/span&gt; sh &lt;span class="nt"&gt;-c&lt;/span&gt; “kubectl get —all-namespaces &lt;span class="nt"&gt;-oyaml&lt;/span&gt; &lt;span class="o"&gt;{}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; —“ &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$HOME&lt;/span&gt;/ISTIO_1_0_RESTORE_CRD_DATA.yaml
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now let’s change our helmfile to pull the new istio version:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;repositories&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;incubator&lt;/span&gt;
  &lt;span class="na"&gt;url&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;https://kubernetes-charts-incubator.storage.googleapis.com/&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;istio&lt;/span&gt;
  &lt;span class="na"&gt;url&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;https://storage.googleapis.com/istio-release/releases/1.2.4/charts/&lt;/span&gt;

&lt;span class="na"&gt;releases&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;istio-init&lt;/span&gt;
    &lt;span class="na"&gt;namespace&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;istio-system&lt;/span&gt;
    &lt;span class="na"&gt;chart&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;istio/istio-init&lt;/span&gt;

  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;istio&lt;/span&gt;
    &lt;span class="na"&gt;namespace&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;istio-system&lt;/span&gt;
    &lt;span class="na"&gt;chart&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;istio/istio&lt;/span&gt;
    &lt;span class="na"&gt;version&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;~1.2.4&lt;/span&gt;
    &lt;span class="na"&gt;values&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;./istio/values.yaml&lt;/span&gt;&lt;span class="pi"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;We’ve written a simple script that will try to cleanup a few things like &lt;code&gt;ClusterRole&lt;/code&gt;, &lt;code&gt;ClusterRoleBinding&lt;/code&gt;, &lt;code&gt;Attributes&lt;/code&gt;, &lt;code&gt;Metrics&lt;/code&gt; definitions and &lt;code&gt;PodDisruptionBudget&lt;/code&gt;. Be&amp;nbsp;careful here,&amp;nbsp;please take some time to read the script and only delete what you can.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/sh&lt;/span&gt;

&lt;span class="c"&gt;# Download the most recent version of the charts&lt;/span&gt;
curl &lt;span class="nt"&gt;-L&lt;/span&gt; https://git.io/getLatestIstio | &lt;span class="nv"&gt;ISTIO_VERSION&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;1.2.4 sh -

&lt;span class="nb"&gt;cd &lt;/span&gt;istio-1.2.4

&lt;span class="c"&gt;# install the new version’s CRDs&lt;/span&gt;
helm upgrade &lt;span class="nt"&gt;--install&lt;/span&gt; &lt;span class="nt"&gt;--force&lt;/span&gt; istio-init &lt;span class="nb"&gt;install&lt;/span&gt;/kubernetes/helm/istio-init &lt;span class="nt"&gt;--namespace&lt;/span&gt; istio-system

&lt;span class="c"&gt;## Check if all jobs are done&lt;/span&gt;
kubectl get job &lt;span class="nt"&gt;--namespace&lt;/span&gt; istio-system | &lt;span class="nb"&gt;grep &lt;/span&gt;istio-init-crd

&lt;span class="c"&gt;# Here is where the cleanup will start&lt;/span&gt;
&lt;span class="c"&gt;# First we have to remove the current istio’s cluster roles&lt;/span&gt;
kubectl delete clusterrole istio-egressgateway-istio-system istio-ingressgateway-istio-system

&lt;span class="c"&gt;# Now the cluster role bindings&lt;/span&gt;
kubectl delete clusterrolebinding istio-egressgateway-istio-system istio-ingressgateway-istio-system istio-kiali-admin-role-binding-istio-system

&lt;span class="c"&gt;# Moving on, to remove the Kubernetes attributes&lt;/span&gt;
kubectl delete kubernetes attributes

&lt;span class="c"&gt;# Next, we delete all metric CDRs that istio had installed&lt;/span&gt;
kubectl delete metric requestcount requestduration requestsize responsesize tcpbytereceived tcpbytesent tcpconnectionsopened tcpconnectionsclosed

&lt;span class="c"&gt;# Finally we remove the PodDisruptionBudget&lt;/span&gt;
kubectl delete poddisruptionbudget istio-egressgateway istio-egressgateway istio-ingressgateway istio-pilot istio-policy istio-telemetry
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Note that the commands in this script can return something like:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Error from server (NotFound): metrics.config.istio.io "requestcount" not found&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This&amp;nbsp;means you don’t have the CRD installed, and when you run the istio upgrade, it will install it for you.&lt;/p&gt;

&lt;h2&gt;
  
  
  Updating istio
&lt;/h2&gt;

&lt;p&gt;Finally, run the helmfile sync command to upgrade your istio installation.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;helmfile &lt;span class="nt"&gt;-f&lt;/span&gt; helmfile.yaml &lt;span class="nb"&gt;sync&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;To confirm if everything worked run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;istioctl version

client version: 1.2.4
citadel version: 1.2.4
egressgateway version: 94746ccd404a8e056483dd02e4e478097b950da6-dirty
galley version: 1.2.4
ingressgateway version: 94746ccd404a8e056483dd02e4e478097b950da6-dirty
pilot version: 1.2.4
policy version: 1.2.4
sidecar-injector version: 1.2.4
telemetry version: 1.2.4
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Check your Kiali installation and new dashboard&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl &lt;span class="nt"&gt;-n&lt;/span&gt; istio-system port-forward &lt;span class="o"&gt;(&lt;/span&gt;kubectl &lt;span class="nt"&gt;-n&lt;/span&gt; istio-system get pod &lt;span class="nt"&gt;-l&lt;/span&gt; &lt;span class="nv"&gt;app&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;kiali &lt;span class="nt"&gt;-o&lt;/span&gt; &lt;span class="nv"&gt;jsonpath&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'{.items[0].metadata.name}'&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; 20001:20001
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Go to &lt;a href="http://localhost:20001/kiali/console"&gt;Kiali Console&lt;/a&gt; and see your new version.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;That is it, a simple istio upgrade. I’m sure there are better ways of doing this, but this one was the easiest and quickest that worked well for us.&lt;/p&gt;

&lt;p&gt;If you know better ways of doing this, please share it as it will be very helpful.&lt;/p&gt;

&lt;p&gt;Thanks 👋&lt;/p&gt;

</description>
      <category>istio</category>
      <category>kubernetes</category>
      <category>upgrade</category>
    </item>
  </channel>
</rss>
