<?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>The Ops Community ⚙️: Shimon Tolts</title>
    <description>The latest articles on The Ops Community ⚙️ by Shimon Tolts (@shimont).</description>
    <link>https://community.ops.io/shimont</link>
    <image>
      <url>https://community.ops.io/images/8ApKm1HqvfEj-pmVeH57OEo22wdUGVb1AmAZQyjJf6M/rs:fill:90:90/g:sm/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL3Vz/ZXIvcHJvZmlsZV9p/bWFnZS82MjQvNjNk/N2NkNjItNDllNC00/NzAzLThjYmItOTM2/ZjA3MDJlMWIwLmpw/Zw</url>
      <title>The Ops Community ⚙️: Shimon Tolts</title>
      <link>https://community.ops.io/shimont</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://community.ops.io/feed/shimont"/>
    <language>en</language>
    <item>
      <title>EKS 1.22 Upgrade Tutorial | Beware of Removed APIs!</title>
      <dc:creator>Shimon Tolts</dc:creator>
      <pubDate>Sat, 28 May 2022 13:29:04 +0000</pubDate>
      <link>https://community.ops.io/shimont/eks-122-upgrade-tutorial-beware-of-removed-apis-16cb</link>
      <guid>https://community.ops.io/shimont/eks-122-upgrade-tutorial-beware-of-removed-apis-16cb</guid>
      <description>&lt;h1&gt;
  
  
  👋 Welcome to my upgrade guide to EKS version 1.22.
&lt;/h1&gt;

&lt;p&gt;EKS has recently started supporting version 1.22 of Kubernetes. If you want to upgrade, you should know this: Version 1.22 has LOTS of REMOVED APIs. Previously they were deprecated, now they are outright REMOVED, so any workload trying to run using those removed versions will simply fail to run. This means that this upgrade is very dangerous for your production environment.&lt;/p&gt;

&lt;p&gt;In this tutorial we will learn how to upgrade correctly. We will:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Identify the removed APIs in the target cluster.&lt;/li&gt;
&lt;li&gt;Convert the removed APIs to new versions.&lt;/li&gt;
&lt;li&gt;Upgrade the EKS Control Plane to version 1.22.&lt;/li&gt;
&lt;li&gt;Upgrade Node Groups to AMI version 1.22.6.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/FVGEvbLX46M"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h1&gt;
  
  
  ⏳Identify the removed APIs in the target cluster
&lt;/h1&gt;

&lt;p&gt;So let’s scan  our cluster to see if we are currently running any of those removed APIs. You can find the full list of removed APIs at the bottom of this blog post.&lt;/p&gt;

&lt;p&gt;First, we will fetch all of the manifests for the following namespace hn-app and output it as YAML&lt;/p&gt;

&lt;p&gt;&lt;code&gt;kubectl get all -n hn-app -o yaml|grep apiVersion&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.ops.io/images/zWNoHiaHmCJcwB75nil5l1N6QqcwaXoWLC71Ptr2UNc/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzLzZ5ejNx/Nml1MnJqMHhnZGV6/NXRiLnBuZw" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ops.io/images/zWNoHiaHmCJcwB75nil5l1N6QqcwaXoWLC71Ptr2UNc/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzLzZ5ejNx/Nml1MnJqMHhnZGV6/NXRiLnBuZw" alt="kubectl get outpout" width="880" height="364"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, in order to find those removed APIs we have two options. One, manually cross-referencing the output with the list of removed APIs. Or two, using Datree to automatically identify those removed APIs.&lt;/p&gt;

&lt;p&gt;Datree is an open source project built by me and by a bunch of talented engineers in order to prevent misconfigurations in Kubernetes environments, and it has a Kubectl plugin that can come in handy in this case. The plugin connects to our kubectl configured cluster, pulls the currently running manifests, and checks to see if their version is compatible with the future version that we will upgrade our cluster to.&lt;/p&gt;

&lt;p&gt;In order to use the plugin we will first install it using Krew (the package manager for Kubectl plugins)&lt;/p&gt;

&lt;p&gt;&lt;code&gt;kubectl krew install datree&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now we will scan the hn-app workspace using the Datree with the target version 1.22.6&lt;/p&gt;

&lt;p&gt;&lt;code&gt;kubectl datree test -s 1.22.6 -- --namespace hn-app&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;And here are the results:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.ops.io/images/_-0rBBMZF9lvIlP2uOcus5KpvSq2bBNGeBRgPu9CN-Y/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzL3piZzBk/NWw0eGg1ZzR4bGtj/d3JlLnBuZw" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ops.io/images/_-0rBBMZF9lvIlP2uOcus5KpvSq2bBNGeBRgPu9CN-Y/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzL3piZzBk/NWw0eGg1ZzR4bGtj/d3JlLnBuZw" alt="Datree Kubectl plugin identifying removed APIs" width="880" height="691"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see, we have an issue with our Ingress controller as it is using the networking.k8s.io/v1beta1 version.&lt;/p&gt;

&lt;p&gt;And indeed, if we’ll check the manifest we’ll see the removed API in line #2:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Output
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
 annotations:
   alb.ingress.kubernetes.io/scheme: internet-facing
   alb.ingress.kubernetes.io/target-type: ip
   kubernetes.io/ingress.class: alb
 creationTimestamp: null
 labels:
   app: hn-ingress
 name: hn-ingress
 namespace: hn-app
spec:
 rules:
 - host: hn.datree.io
 - http:
     paths:
     - backend:
         serviceName: service-hn
         servicePort: 80
       path: /
       pathType: Prefix
status:
 loadBalancer: {}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If we try to use this API Version after we’ve upgraded the cluster to version 1.22 we will get the following error:&lt;br&gt;
&lt;code&gt;error: unable to recognize "hn-ingress-2.yaml": no matches for kind "Ingress" in version "networking.k8s.io/v1beta1"&lt;/code&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  🔁 Converting the removed API versions to new versions
&lt;/h1&gt;

&lt;p&gt;Now that we have identified the removed API version using Datree’s Kubectl plugin, we will use an official Kubernetes kubectl plugin called convert in order to migrate our API version&lt;/p&gt;

&lt;p&gt;&lt;code&gt;#installing kubectl convert&lt;br&gt;
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl-convert" &amp;amp;&amp;amp; sudo install -o root -g root -m 0755 kubectl-convert /usr/local/bin/kubectl-convert&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now let's convert the file to the new API networking.k8s.io/v1&lt;/p&gt;

&lt;p&gt;&lt;code&gt;kubectl convert -f hn-ingress-2.yaml --output-version networking.k8s.io/v1&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#Output
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
 annotations:
   alb.ingress.kubernetes.io/scheme: internet-facing
   alb.ingress.kubernetes.io/target-type: ip
   kubernetes.io/ingress.class: alb
 creationTimestamp: null
 labels:
   app: hn-ingress
 name: hn-ingress
 namespace: hn-app
spec:
 rules:
 - host: hn.datree.io
 - http:
     paths:
     - backend:
         service:
           name: service-hn
           port:
             number: 80
       path: /
       pathType: Prefix
status:
 loadBalancer: {}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we have the up-to-date and supported API versions! 🎉 We are safe to perform the upgrade 🔥&lt;/p&gt;

&lt;h1&gt;
  
  
  🤞 Upgrading the EKS cluster:
&lt;/h1&gt;

&lt;p&gt;In order to perform the upgrade process for the Control Plane and Node Groups, we will use the EKSCTL toolkit&lt;/p&gt;

&lt;h2&gt;
  
  
  Upgrading the Control Plane:
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;eksctl upgrade cluster -r us-east-1 -n k8s21to22d-k8sdemo4 --approve&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.ops.io/images/daPbNfHuXjccscdZfAuP3lsFCFCoQQ3G_P74tO0fWLU/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzL2hxYndj/YnAwOWVzeDF4YjIy/MW4zLnBuZw" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ops.io/images/daPbNfHuXjccscdZfAuP3lsFCFCoQQ3G_P74tO0fWLU/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzL2hxYndj/YnAwOWVzeDF4YjIy/MW4zLnBuZw" alt="Upgrading EKS Cluster to version 1.22 using EKSCTL" width="880" height="296"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Upgrading the node group:
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;eksctl upgrade nodegroup -r us-east-1 -c k8s21to22d-k8sdemo4 --name k8s21to22d-k8sdemo4-node_group&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.ops.io/images/Y0zM0SiKLuSGe3LJEVd3z5S9PfCXwOkO7N55dQwWgCk/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzL2Fqdnh6/b2EyZXhmeTBha2dt/ZHU1LnBuZw" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ops.io/images/Y0zM0SiKLuSGe3LJEVd3z5S9PfCXwOkO7N55dQwWgCk/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzL2Fqdnh6/b2EyZXhmeTBha2dt/ZHU1LnBuZw" alt="Upgrading EKS Node group to AMI version 1.22.6" width="880" height="206"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  ⛔️ Removed APIs:
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Beta versions of the ValidatingWebhookConfiguration and MutatingWebhookConfiguration API (the admissionregistration.k8s.io/v1beta1 API versions)
&lt;code&gt;error: unable to recognize "deployment.yaml": no matches for kind "ValidatingWebhookConfiguration" in version "apiregistration.k8s.io/v1beta1"&lt;/code&gt;
&lt;code&gt;error: unable to recognize "deployment.yaml": no matches for kind "MutatingWebhookConfiguration" in version "apiregistration.k8s.io/v1beta1"‍&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;The beta CustomResourceDefinition API (apiextensions.k8s.io/v1beta1) &lt;code&gt;error: unable to recognize "deployment.yaml": no matches for kind "CustomResourceDefinition" in version "apiregistration.k8s.io/v1beta1"‍&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;The beta APIService API (apiregistration.k8s.io/v1beta1)
&lt;code&gt;error: unable to recognize "deployment.yaml": no matches for kind "APIService" in version "apiregistration.k8s.io/v1beta1"‍&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;The beta TokenReview API (authentication.k8s.io/v1beta1)
&lt;code&gt;error: unable to recognize "deployment.yaml": no matches for kind "TokenReview" in version "networking.k8s.io/v1beta1"‍&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Beta API versions of SubjectAccessReview, LocalSubjectAccessReview, SelfSubjectAccessReview (API versions from authorization.k8s.io/v1beta1)
&lt;code&gt;error: unable to recognize "deployment.yaml": no matches for kind "SubjectAccessReview" in version "networking.k8s.io/v1beta1"&lt;/code&gt;
&lt;code&gt;error: unable to recognize "deployment.yaml": no matches for kind "LocalSubjectAccessReview" in version "networking.k8s.io/v1beta1&lt;/code&gt;
&lt;code&gt;error: unable to recognize "deployment.yaml": no matches for kind "SelfSubjectAccessReview" in version "networking.k8s.io/v1beta1"‍&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;The beta CertificateSigningRequest API (certificates.k8s.io/v1beta1)
&lt;code&gt;error: unable to recognize "deployment.yaml": no matches for kind "CertificateSigningRequest" in version "networking.k8s.io/v1beta1"‍&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;The beta Lease API (coordination.k8s.io/v1beta1)
&lt;code&gt;error: unable to recognize "deployment.yaml": no matches for kind "Lease" in version "coordination.k8s.io/v1beta1"‍&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;All beta Ingress APIs (the extensions/v1beta1 and networking.k8s.io/v1beta1 API versions)
&lt;code&gt;error: unable to recognize "deployment.yaml": no matches for kind "Ingress" in version "networking.k8s.io/v1beta1"&lt;/code&gt;
&lt;code&gt;error: unable to recognize "deployment.yaml": no matches for kind "Ingress" in version "extensions/v1beta1"&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Additional Resources:
&lt;/h1&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://sysdig.com/blog/kubernetes-1-22-whats-new/"&gt;https://sysdig.com/blog/kubernetes-1-22-whats-new/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://kubernetes.io/blog/2021/08/04/kubernetes-1-22-release-announcement/"&gt;https://kubernetes.io/blog/2021/08/04/kubernetes-1-22-release-announcement/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://kubernetes.io/blog/2021/07/14/upcoming-changes-in-kubernetes-1-22/"&gt;https://kubernetes.io/blog/2021/07/14/upcoming-changes-in-kubernetes-1-22/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://kubernetes.io/docs/reference/using-api/deprecation-guide/"&gt;https://kubernetes.io/docs/reference/using-api/deprecation-guide/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://youtu.be/FVGEvbLX46M"&gt;https://youtu.be/FVGEvbLX46M&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>devops</category>
      <category>kubernetes</category>
      <category>aws</category>
    </item>
  </channel>
</rss>
