<?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: Victor Gomez</title>
    <description>The latest articles on DEV Community by Victor Gomez (@vmgomez).</description>
    <link>https://dev.to/vmgomez</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%2F1541452%2F429a0472-4d48-4151-a93c-04acd056bd52.jpg</url>
      <title>DEV Community: Victor Gomez</title>
      <link>https://dev.to/vmgomez</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/vmgomez"/>
    <language>en</language>
    <item>
      <title>Mastering eksctl Commands: A Comprehensive Guide</title>
      <dc:creator>Victor Gomez</dc:creator>
      <pubDate>Tue, 04 Jun 2024 12:44:19 +0000</pubDate>
      <link>https://dev.to/vmgomez/mastering-eksctl-commands-a-comprehensive-guide-1h75</link>
      <guid>https://dev.to/vmgomez/mastering-eksctl-commands-a-comprehensive-guide-1h75</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fppdbirqqax5aap4hvjsh.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fppdbirqqax5aap4hvjsh.jpg" alt="Image description" width="800" height="448"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;eksctl is an incredibly powerful tool for managing Amazon EKS clusters, and it quickly became our goto solution for automating  Kubernetes deployments. With its extensive set of commands, we were able to streamline our workflow, reduce errors, and increase productivity.  But, as with any new tool, there was a learning curve.&lt;/p&gt;

&lt;p&gt;In this tutorial, I will share the essential eksctl commands that every  DevOps engineer should know. These commands are essential for managing  Kubernetes clusters, deploying applications, and troubleshooting issues. By mastering these commands, you can take your container orchestration  skills to the next level and become a certified eksctl expert.&lt;/p&gt;

&lt;p&gt;Before we dive into the specific commands, let me provide some context on why  they are important. Kubernetes is an opensource platform for automating  deployment, scaling, and management of containerized applications.  Amazon EKS is a managed Kubernetes service  that makes it easy to deploy and manage Kubernetes clusters in the  cloud. eksctl is a tool for managing Amazon EKS clusters, and it provides a set of commands for interacting with these clusters.&lt;/p&gt;

&lt;p&gt;Now, let’s get started with the essential eksctl commands:&lt;/p&gt;

&lt;p&gt;If you have more than one profile, you will need to specify the name of your profile using the --profile subparameter. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;eksctl create&lt;/strong&gt;: This command creates a new Amazon EKS cluster. It takes several parameters, such as the cluster name, the number of nodes, and the instance type.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;eksctl create name mycluster nodes instancetype m.large
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;​     But the easiest way to deploy is to define everything in a YAML file! You can run something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;eksctl create cluster &lt;span class="nt"&gt;-f&lt;/span&gt; k8s.yml &lt;span class="nt"&gt;--profile&lt;/span&gt; dynacode_profile
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Sure thing, you need to create a YAML file before you run this command. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;eksctl.io/v1alpha5&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ClusterConfig&lt;/span&gt;

&lt;span class="na"&gt;metadata&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;basic-cluster001&lt;/span&gt;
  &lt;span class="na"&gt;region&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;us-east-1&lt;/span&gt;

&lt;span class="na"&gt;nodeGroups&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;ng-1&lt;/span&gt;
    &lt;span class="na"&gt;instanceType&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;m5.large&lt;/span&gt;
    &lt;span class="na"&gt;desiredCapacity&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;10&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;ng-2&lt;/span&gt;
    &lt;span class="na"&gt;instanceType&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;m5.xlarge&lt;/span&gt;
    &lt;span class="na"&gt;desiredCapacity&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you want to download this small yaml, you can do so from our &lt;a href="https://github.com/vmgomez/devops-scripts/" rel="noopener noreferrer"&gt;GitHub repository&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;apiVersion:&lt;/code&gt;&lt;br&gt;
This line specifies the eksctl API version  that this configuration file uses. In this case, it's  eksctl.io/v1alpha5, which corresponds to eksctl API version 1 alpha 5.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;kind: ClusterConfig&lt;/code&gt;&lt;br&gt;
This line defines the type of  configuration object being described. Here, it specifies that this is a  ClusterConfig object, which contains the details for creating a  Kubernetes cluster.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;metadata:&lt;/code&gt;&lt;br&gt;
This section provides metadata about the cluster being created.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;name:&lt;/code&gt;&lt;br&gt;
 Specify the name you want to give your EKS cluster. In this case, it is set to basic-cluster.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;region:&lt;/code&gt;&lt;br&gt;
 Specify the AWS region where you want to create your cluster. In this case, it is set to us-east-1.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;nodeGroups:&lt;/code&gt;&lt;br&gt;
This section defines the different worker node groups that will be created for your cluster.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;name:&lt;/code&gt;&lt;br&gt;
 Define the name of the node group. The configuration has two groups called ng-1 y ng-2.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;instanceType:&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Pick the Amazon EC2 instance type you want to use for the nodes in this  group. In this case, "ng-1" uses m5.large instances and "ng-2" uses  m5.xlarge instances. These instance types offer different levels of  processing power and memory.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;desiredCapacity:&lt;/code&gt;&lt;br&gt;
Set the number of nodes you want in this group. The configuration sets "ng-1" to have 10 nodes and "ng-2" to have 2.&lt;/p&gt;

&lt;p&gt;This YAML file sets up a Kubernetes cluster called "basic-cluster" in the  eu-north-1 region of Amazon EKS. It creates two node groups: "ng-1" with 10 m5.large instances and "ng-2" with 2 m5.xlarge instances. You can  use this configuration with the eksctl create cluster command to  provision the cluster in AWS.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;eksctl update&lt;/strong&gt; This command updates the configuration of an existing Amazon EKS cluster. It takes the same parameters as &lt;strong&gt;eksctl create&lt;/strong&gt;, such as the cluster name and the instance type.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;    eksctl update name mycluster nodes  instancetype m.xlarge
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;eksctl delete&lt;/strong&gt; This command deletes an Amazon EKS cluster. It takes the cluster name as a parameter.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;eksctl delete cluster basic-cluster001 &lt;span class="nt"&gt;--profile&lt;/span&gt; dcode_profile &lt;span class="nt"&gt;--region&lt;/span&gt; us-east-1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;eksctl get&lt;/strong&gt; This command returns information about an Amazon EKS cluster, such as its ID, node count, and instance type. It takes the cluster name as a parameter.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;eksctl get name mycluster
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;eksctl listnodes&lt;/strong&gt;  This command lists all the nodes in an Amazon EKS cluster. It takes no parameters.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;eksctl listnodes name mycluster
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;eksctl logs&lt;/strong&gt; This command displays the log output of a container running on an Amazon EKS node. It takes the name of the container as a parameter, followed by the node name.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;eksctl logs container mycontainer node mynode
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;eksctl scale&lt;/strong&gt;: This command scales the number of nodes in an Amazon EKS cluster up or down. It takes the cluster name and the desired number of nodes as parameters.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;eksctl scale name mycluster nodes
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;eksctl tag&lt;/strong&gt;: This command adds a tag to an Amazon EKS cluster. It takes the cluster name, the tag key, and the tag value as parameters.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;eksctl tag name mycluster key &lt;span class="s1"&gt;'owner'&lt;/span&gt; value &lt;span class="s1"&gt;'dynacode'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;eksctl untag&lt;/strong&gt; This command removes a tag from an Amazon EKS cluster. It takes the cluster name and the tag key as parameters. For example: &lt;code&gt;eksctl untag name mycluster key “owner”&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;eksctl rollback&lt;/strong&gt; This command restores an Amazon EKS cluster to a previous state. It takes the cluster name and the desired  revision as parameters. For example: &lt;code&gt;eksctl rollback name mycluster  revision d&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;eksctl commands is essential for any  DevOps engineer working with Kubernetes clusters in the cloud. By  understanding these commands and how to use them effectively, you can  streamline your workflow, reduce errors, and increase productivity.  Remember, practice makes perfect, so keep experimenting with these  commands to become a certified eksctl expert.&lt;/p&gt;

&lt;p&gt;Hey there, don't forget to show some love on our Patreon!&lt;/p&gt;

&lt;p&gt;If you found this post helpful, please consider supporting us on &lt;a href="https://patreon.com/dynacode" rel="noopener noreferrer"&gt;Patreon&lt;/a&gt;. We also have a &lt;a href="https://dynacode.us/" rel="noopener noreferrer"&gt;website&lt;/a&gt; where we dive into all things Python and DevOps/DevSecOps.&lt;/p&gt;

&lt;p&gt;Your support means the world to us, so thank you for being a part of our community!&lt;/p&gt;

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