<?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: Anand Kumar R</title>
    <description>The latest articles on Forem by Anand Kumar R (@ranand12).</description>
    <link>https://forem.com/ranand12</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%2F57623%2Fb7c35911-3d14-4aba-9793-12ce200923e6.jpeg</url>
      <title>Forem: Anand Kumar R</title>
      <link>https://forem.com/ranand12</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/ranand12"/>
    <language>en</language>
    <item>
      <title>Stop Coding, Start Managing: A First Look at Google's AntiGravity IDE 🚀</title>
      <dc:creator>Anand Kumar R</dc:creator>
      <pubDate>Mon, 24 Nov 2025 02:36:38 +0000</pubDate>
      <link>https://forem.com/ranand12/stop-coding-start-managing-a-first-look-at-googles-antigravity-ide-3j9h</link>
      <guid>https://forem.com/ranand12/stop-coding-start-managing-a-first-look-at-googles-antigravity-ide-3j9h</guid>
      <description>&lt;p&gt;&lt;strong&gt;TL;DR:&lt;/strong&gt; I took Google's new agentic IDE, &lt;strong&gt;AntiGravity&lt;/strong&gt;, for a spin. It shifts the workflow from writing code to &lt;em&gt;managing&lt;/em&gt; asynchronous agents. In this post, I break down how I built a Stock Dividend Tracker using Google Antigravity and Gemini 3, parallel task execution, and the tool's really cool feature: verifiable screen recordings.&lt;/p&gt;

&lt;p&gt;The biggest difference in AntiGravity is the interface. While it has a traditional code editor (VS Code style) on the left, the right side is dominated by the &lt;strong&gt;Agent Manager&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Think of the Agent Manager as an autonomous coding engine. Instead of pair programming, you are assigning tasks.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The Inbox:&lt;/strong&gt; This is your command center. You spin up tasks and check your inbox for status updates.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Modes:&lt;/strong&gt; You can toggle between &lt;strong&gt;Planning Mode&lt;/strong&gt; (for complex architecture) and &lt;strong&gt;Fast Mode&lt;/strong&gt; (for quick fixes).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Models:&lt;/strong&gt; You can swap models per task (e.g., using Gemini 3 for logic and a faster model for boilerplate).&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The Killer Feature: Verifiable Artifacts 📹
&lt;/h2&gt;

&lt;p&gt;We’ve all had an LLM tell us "Task Complete," only to run the code and watch it crash.&lt;/p&gt;

&lt;p&gt;AntiGravity solves this with &lt;strong&gt;browser tool&lt;/strong&gt;. When the agent claims it built a feature, it doesn't just show you the code—it proves it works.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;Browser Control:&lt;/strong&gt; The agent spins up a browser instance (you can see the "blue halo" indicating agent control).&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;DOM Interaction:&lt;/strong&gt; It clicks buttons, enters data, and navigates the UI.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Screen Recording:&lt;/strong&gt; It records a video of the test and analyzes that video to verify success.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In my demo, I asked it to build a Dividend Tracker. It didn't just write the API fetch; it opened the browser, added Apple and Microsoft stocks, verified the yield calculation, and sent me a video recording of the successful test.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Workflow: Asynchronous &amp;amp; Parallel
&lt;/h2&gt;

&lt;p&gt;Because the Agent Manager acts like an employee, you can multitask.&lt;/p&gt;

&lt;p&gt;In the demo, I reached a point where the core app was working. I then issued &lt;strong&gt;two parallel tasks&lt;/strong&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; &lt;em&gt;Thread A:&lt;/em&gt; Update logic to calculate total dividends based on share count.&lt;/li&gt;
&lt;li&gt; &lt;em&gt;Thread B:&lt;/em&gt; Create a visualization (Pie Chart) of the portfolio.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I sent both requests, stepped back, and monitored the &lt;strong&gt;Inbox&lt;/strong&gt;. Both tasks ran simultaneously. The agent updated the implementation plan, modified the code, verified the output, and notified me when done.&lt;/p&gt;

&lt;h2&gt;
  
  
  Human-in-the-Loop Configuration
&lt;/h2&gt;

&lt;p&gt;For those worried about an AI running &lt;code&gt;rm -rf /&lt;/code&gt; on your machine, AntiGravity allows for granular permissions. You can set the &lt;strong&gt;Review Policy&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Always Approve:&lt;/strong&gt; For low-stakes environments.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ask for Approval:&lt;/strong&gt; The agent pauses and asks permission before running CLI commands or critical file changes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Auto-detect:&lt;/strong&gt; The agent decides based on task complexity.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The experience felt less like "coding" and more like "code reviewing." I spent my time editing the &lt;strong&gt;Task List&lt;/strong&gt; and &lt;strong&gt;Implementation Plan&lt;/strong&gt; documents rather than wrestling with syntax.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;AntiGravity represents a shift from &lt;em&gt;writing&lt;/em&gt; software to &lt;em&gt;architecting&lt;/em&gt; software. The ability to trust the output because of the &lt;strong&gt;verifiable artifacts (screen recordings)&lt;/strong&gt; is a massive step forward in reducing the friction of AI development.&lt;/p&gt;

&lt;p&gt;Check out the full video below to see the agent driving the browser in real-time!&lt;/p&gt;

&lt;p&gt;

  &lt;iframe src="https://www.youtube.com/embed/8aNv221Vvu8"&gt;
  &lt;/iframe&gt;


&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Have you tried Agentic workflows yet? Let me know in the comments!&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>googlecloud</category>
      <category>devtools</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Create Your First Google ADK Agent: A Beginner's Guide</title>
      <dc:creator>Anand Kumar R</dc:creator>
      <pubDate>Thu, 13 Nov 2025 18:43:07 +0000</pubDate>
      <link>https://forem.com/ranand12/create-your-first-google-adk-agent-a-beginners-guide-5d41</link>
      <guid>https://forem.com/ranand12/create-your-first-google-adk-agent-a-beginners-guide-5d41</guid>
      <description>&lt;p&gt;

  &lt;iframe src="https://www.youtube.com/embed/X2jTp6qvbzM"&gt;
  &lt;/iframe&gt;


&lt;/p&gt;

&lt;p&gt;In this tutorial, we'll walk through how to create your first agent using Google's Agent Development Kit (ADK). We'll explore two primary methods: using the intuitive Visual Builder and a straightforward, no-code YAML configuration.&lt;/p&gt;

&lt;h3&gt;
  
  
  Understanding the Anatomy of an ADK Agent
&lt;/h3&gt;

&lt;p&gt;Before we build, let's break down the core components of a Google ADK agent:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Name&lt;/strong&gt;: A unique identifier for your agent.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Model&lt;/strong&gt;: The engine powering your agent. This can be a first-party Google model (like Gemini) or any third-party/open-source model via the LightLLM integration.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Instructions&lt;/strong&gt;: This is where you define the agent's persona, its core logic, and the desired output schema. Think of it as a detailed, structured prompt.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Description&lt;/strong&gt;: A concise summary of the agent's purpose. This is crucial in multi-agent systems, where agents interact based on each other's descriptions.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Tools&lt;/strong&gt;: These equip your agent with external capabilities. ADK provides several built-in tools like Google Search and File Retrieval. You can also integrate with third-party tools (LangChain, CrewAI) or build your own custom logic using a &lt;strong&gt;Function Tool&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Prerequisites
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Get a Gemini API Key&lt;/strong&gt;: You'll need a Gemini API key for this project. Create a &lt;code&gt;.env&lt;/code&gt; file in your project root and add your key:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;GEMINI_API_KEY="YOUR_API_KEY_HERE"
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Set up a Virtual Environment&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python &lt;span class="nt"&gt;-m&lt;/span&gt; venv .venv
&lt;span class="nb"&gt;source&lt;/span&gt; .venv/bin/activate
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Install or Upgrade Google ADK&lt;/strong&gt;: The Visual Builder requires version &lt;code&gt;1.18&lt;/code&gt; or higher.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--upgrade&lt;/span&gt; google-adk
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Method 1: Create an Agent with the Visual Builder &amp;amp; AI Assist
&lt;/h3&gt;

&lt;p&gt;The fastest way to get started is with the ADK web interface and its natural language capabilities.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Launch the ADK Web Console&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;adk web
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Create a New Agent&lt;/strong&gt;: In the web UI, select "Create a new agent in visual mode" and give it a name (e.g., &lt;code&gt;Visual-Agent-1&lt;/code&gt;).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Use the AI Assistant&lt;/strong&gt;: On the right-hand side, you'll find an assistant. Let's give it a prompt to create a research agent.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Prompt&lt;/strong&gt;: "Create a bull and bear research agent for a given stock. It should use Google Search to analyze the bull and bear cases for the stock and return a summary in a bulleted list."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The assistant will generate the necessary YAML configuration.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Save and Test&lt;/strong&gt;: Once you approve the generated YAML, the agent's instructions and the required &lt;code&gt;GoogleSearch&lt;/code&gt; tool will be auto-populated. Save the agent and test it directly in the UI by providing a stock ticker like "Nvidia".&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The agent will now perform a search and return a formatted analysis of the bull and bear cases for the stock.&lt;/p&gt;

&lt;h3&gt;
  
  
  Method 2: Create an Agent with YAML Configuration
&lt;/h3&gt;

&lt;p&gt;If you prefer a code-free, configuration-driven approach from the start, you can use the CLI.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Run the &lt;code&gt;create&lt;/code&gt; Command&lt;/strong&gt;: Use the &lt;code&gt;adk create&lt;/code&gt; command with the &lt;code&gt;--configuration&lt;/code&gt; flag.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;adk create &lt;span class="nt"&gt;--name&lt;/span&gt; &lt;span class="s2"&gt;"My-YAML-Agent"&lt;/span&gt; &lt;span class="nt"&gt;--configuration&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Follow the Prompts&lt;/strong&gt;: The CLI will guide you through a series of questions to set up your agent:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Select the model you want to use (e.g., &lt;code&gt;gemini-2.5-pro&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;  Choose the provider (e.g., &lt;code&gt;Google AI&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;  Enter your API key.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Agent Created&lt;/strong&gt;: This process generates a &lt;code&gt;root_agent.yaml&lt;/code&gt; file with a minimal configuration. You can now run &lt;code&gt;adk web&lt;/code&gt; to test it or begin customizing the YAML file with more detailed instructions and tools.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;And that's it! You've successfully created your first ADK agent using three different approaches: the AI-assisted builder, the visual workflow, and the no-code YAML configuration. In future posts, we'll dive into more advanced concepts like multi-agent systems and callbacks.&lt;/p&gt;

&lt;p&gt;Short videos &lt;/p&gt;

&lt;p&gt;(Google ADK Visual Builder)- &lt;a href="https://youtube.com/shorts/fIv6fvUM3gg?si=6U_DeU2NRXFaBy8M" rel="noopener noreferrer"&gt;https://youtube.com/shorts/fIv6fvUM3gg?si=6U_DeU2NRXFaBy8M&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;(Anatomy of a Google Agent Development Kit (ADK) Agent) - &lt;a href="https://youtube.com/shorts/pkttZnC5DCU?si=DvaLy5Z-F1Tg1EgQ" rel="noopener noreferrer"&gt;https://youtube.com/shorts/pkttZnC5DCU?si=DvaLy5Z-F1Tg1EgQ&lt;/a&gt;&lt;/p&gt;

</description>
      <category>google</category>
      <category>adk</category>
      <category>visualbuilder</category>
      <category>agents</category>
    </item>
    <item>
      <title>Gemini CLI Custom Slash Commands</title>
      <dc:creator>Anand Kumar R</dc:creator>
      <pubDate>Fri, 07 Nov 2025 20:19:23 +0000</pubDate>
      <link>https://forem.com/ranand12/gemini-cli-custom-slash-commands-42ja</link>
      <guid>https://forem.com/ranand12/gemini-cli-custom-slash-commands-42ja</guid>
      <description>&lt;p&gt;Are you looking for a way to make your command-line experience with Gemini CLI more powerful and personalized? If you're performing repetitive tasks, then it's time for you to discover the magic of custom slash commands.&lt;/p&gt;

&lt;p&gt;To help you with that, I've created a step-by-step video guide that breaks down how you can create your own slash commands to automate just about anything. I believe it's a total game-changer for streamlining your development workflow.&lt;/p&gt;

&lt;p&gt;Check out the full video I made for you here:&lt;/p&gt;

&lt;p&gt;

  &lt;iframe src="https://www.youtube.com/embed/oGfCcVCpGGg"&gt;
  &lt;/iframe&gt;


&lt;/p&gt;

&lt;h3&gt;
  
  
  What are Slash Commands?
&lt;/h3&gt;

&lt;p&gt;Slash commands are custom shortcuts you can create in the Gemini CLI. Instead of typing out long, complex commands, you can define a simple &lt;code&gt;/your-command-name&lt;/code&gt; to execute a script or a series of instructions. Think of them as personalized macros for your CLI.&lt;/p&gt;

&lt;h3&gt;
  
  
  Key Takeaways from My Video
&lt;/h3&gt;

&lt;p&gt;I've packed my guide with practical information, but here are some of the highlights I'll walk you through:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Introduction to Custom Commands:&lt;/strong&gt; I'll give you a clear overview of what they are and why they are so useful.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Step-by-Step Creation:&lt;/strong&gt; I'll guide you through the entire process of creating your first command from scratch.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Dynamic Arguments:&lt;/strong&gt; You'll learn how to make your commands flexible by passing arguments, allowing them to handle different inputs and scenarios.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Organizing with Namespaces:&lt;/strong&gt; As you build more commands, keeping them organized is key. I'll show you how to group related commands using namespaces.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Pre-built Commands Repository:&lt;/strong&gt; If you don't want to start from zero, you can tap into a repository of pre-built commands to get started even faster.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Why You Should Try This
&lt;/h3&gt;

&lt;p&gt;Automating repetitive tasks is one of the best investments you can make in your productivity. By creating your own slash commands, you can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Save Time:&lt;/strong&gt; Execute complex operations in seconds.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reduce Errors:&lt;/strong&gt; Avoid typos and mistakes from re-typing long commands.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Share Workflows:&lt;/strong&gt; Easily share your custom commands with your team to standardize processes.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I made this video to be a perfect starting point for anyone looking to level up their Gemini CLI skills.&lt;/p&gt;

&lt;p&gt;I hope you enjoy it. Happy coding!&lt;/p&gt;

</description>
      <category>gemini</category>
      <category>cli</category>
      <category>tutorial</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Google's Unified Gen AI SDK: A Hands-on Guide</title>
      <dc:creator>Anand Kumar R</dc:creator>
      <pubDate>Tue, 11 Mar 2025 12:03:39 +0000</pubDate>
      <link>https://forem.com/ranand12/googles-unified-genai-sdk-a-hands-on-guide-2n2d</link>
      <guid>https://forem.com/ranand12/googles-unified-genai-sdk-a-hands-on-guide-2n2d</guid>
      <description>&lt;h1&gt;
  
  
  Google's Unified Gen AI SDK: A Hands-on Guide
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;If you prefer learning visually, here is a YouTube Video I created for the same article:&lt;br&gt;
&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/vH2iMV2Y3dI"&gt;
&lt;/iframe&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If you've been working with Google's Generative AI model Gemini, you might have encountered a frustrating challenge: using different client libraries for the Gemini Developer API and the enterprise version on Vertex AI. While these libraries were similar, they weren't interchangeable, meaning that moving from experimentation to production required code rewrites.&lt;/p&gt;

&lt;p&gt;Google's new unified Gen AI SDK solves this problem by providing a single library that works seamlessly with both Gemini 2 and 1.5, across both developer and enterprise environments.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffgeom5aagy0eg970b82r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffgeom5aagy0eg970b82r.png" alt="Unified Gen AI SDK bridges the gap between Developer API and Vertex AI" width="800" height="440"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this guide, we'll explore three key methods for leveraging this SDK:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Generate content&lt;/li&gt;
&lt;li&gt;Generate streaming content&lt;/li&gt;
&lt;li&gt;Chat client&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxbtyfwob47zl60qeop1l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxbtyfwob47zl60qeop1l.png" alt="Python client methods" width="800" height="443"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's dive in and see how this unified SDK simplifies working with Google's generative AI capabilities.&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting Started
&lt;/h2&gt;

&lt;p&gt;First, let's install the SDK using pip:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Install the Google Gen AI SDK
&lt;/span&gt;&lt;span class="n"&gt;pip&lt;/span&gt; &lt;span class="n"&gt;install&lt;/span&gt; &lt;span class="n"&gt;google&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;generativeai&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  For Developer API
&lt;/h3&gt;

&lt;p&gt;If you're using Google Colab, you can find your API key under the secrets section by clicking on "Import key from AI Studio." If you're not using Colab, you can generate a free API key at &lt;a href="https://aistudio.google.com" rel="noopener noreferrer"&gt;aistudio.google.com&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;google&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;genai&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;google.colab&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;userdata&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;IPython.display&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Markdown&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;display&lt;/span&gt;

&lt;span class="n"&gt;GOOGLE_API_KEY&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;userdata&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;GOOGLE_API_KEY&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Create a client instance using Google Gemini API Key
&lt;/span&gt;&lt;span class="n"&gt;client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;genai&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Client&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;api_key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;GOOGLE_API_KEY&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;generate_content&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;gemini-2.0-flash&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
    &lt;span class="n"&gt;contents&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Create a short bedtime story for a 7 year old using unicorn and rainbows&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;display&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Markdown&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  For Vertex AI (Enterprise)
&lt;/h3&gt;

&lt;p&gt;For the enterprise version on Vertex AI, you would use the same code after authenticating to Google Cloud and provide your GCP project ID:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Authenticate to Google Cloud &lt;/span&gt;
gcloud auth application-default login
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Provide project details
&lt;/span&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;google&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;genai&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;IPython.display&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Markdown&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;display&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;google.colab&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;userdata&lt;/span&gt;

&lt;span class="n"&gt;PROJECT_ID&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;userdata&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;PROJECT_ID&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;LOCATION&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;userdata&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;LOCATION&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Create a client instance using Vertex AI in Google Cloud
&lt;/span&gt;&lt;span class="n"&gt;client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;genai&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Client&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vertexai&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;project&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;PROJECT_ID&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;location&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;LOCATION&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;generate_content&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;gemini-2.0-flash&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
    &lt;span class="n"&gt;contents&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Create a short bedtime story for a 3 year old using unicorns and rainbows&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;display&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Markdown&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With the unified SDK, the code is identical whether you're using the developer API or Vertex AI. The only difference is in the initial setup.&lt;/p&gt;

&lt;h2&gt;
  
  
  Generate Streaming Content
&lt;/h2&gt;

&lt;p&gt;If you prefer a streaming response that delivers content chunk by chunk:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;generate_content_stream&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;gemini-2.0-flash&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;contents&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Create a poem with unicorns and rainbows&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;chunk&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="n"&gt;chunk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;end&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The streaming approach can provide a more interactive user experience, especially for longer responses.&lt;/p&gt;

&lt;h2&gt;
  
  
  Chat Client
&lt;/h2&gt;

&lt;p&gt;The chat client method maintains conversation history and context, making it ideal for interactive applications:&lt;/p&gt;

&lt;h3&gt;
  
  
  Turn 1
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;chat&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;chats&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;gemini-2.0-flash&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;chat&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;send_message&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;I want to play a tic tac toe game. I selected top right as X. Your turn&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Turn 2
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;chat&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;send_message&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;ok, I go bottom right as X&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You would see that the response from the LLM maintains the context from the previous conversations.&lt;/p&gt;

&lt;h2&gt;
  
  
  Customizing Configuration Parameters
&lt;/h2&gt;

&lt;p&gt;By default, the SDK uses a set of standard configurations. However, you can modify these to suit your needs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;google&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;genai&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;google.genai&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;types&lt;/span&gt;

&lt;span class="n"&gt;PROJECT_ID&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;userdata&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;PROJECT_ID&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;LOCATION&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;userdata&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;LOCATION&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Create a client instance using Vertex AI in Google Cloud
&lt;/span&gt;&lt;span class="n"&gt;client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;genai&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Client&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vertexai&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;project&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;PROJECT_ID&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;location&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;LOCATION&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;generate_content&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;gemini-2.0-flash&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;contents&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Create a short bedtime story for a 3 year old using unicorns and rainbows&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;config&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;types&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;GenerateContentConfig&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;max_output_tokens&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;temperature&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;display&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Markdown&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Using System Instructions
&lt;/h2&gt;

&lt;p&gt;System instructions help define the persona of your client instance:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Set system instructions to define a persona
&lt;/span&gt;&lt;span class="n"&gt;sys_instruct&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;You speak like a short tempered pirate&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;generate_content&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;gemini-2.0-flash&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;contents&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Create a short bedtime story for a 3 year old using unicorns and rainbows&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;config&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;types&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;GenerateContentConfig&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;systemInstruction&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;sys_instruct&lt;/span&gt;
        &lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nf"&gt;display&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Markdown&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This can be useful for creating specialized agents with specific personalities or expertise.&lt;/p&gt;

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

&lt;p&gt;Google's unified Gen AI SDK significantly simplifies the process of working with Gemini models across both development and production environments. With a consistent API for generating content, streaming responses, and maintaining chat sessions, developers can now experiment freely and move to production without the pain of code rewrites.&lt;/p&gt;

&lt;p&gt;The SDK also provides extensive customization options through configuration parameters and system instructions, allowing for fine-tuned control over model behavior.&lt;/p&gt;

&lt;p&gt;In upcoming articles, we'll explore more advanced features of the SDK, including vision, audio, and multimodal capabilities. Stay tuned!&lt;/p&gt;

&lt;h2&gt;
  
  
  Resources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.cloud-monk.com/blog/genaisdk" rel="noopener noreferrer"&gt;Original Blog&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://aistudio.google.com" rel="noopener noreferrer"&gt;Google AI Studio&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://googleapis.github.io/python-genai/" rel="noopener noreferrer"&gt;Google Gen AI Python SDK Documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://cloud.google.com/vertex-ai/generative-ai/docs/sdks/overview" rel="noopener noreferrer"&gt;Vertex AI Documentation&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>google</category>
      <category>genai</category>
      <category>gemini</category>
      <category>python</category>
    </item>
    <item>
      <title>aks patching and node pool upgrade azure kubernetes services (aks) explained in plain english</title>
      <dc:creator>Anand Kumar R</dc:creator>
      <pubDate>Tue, 29 Mar 2022 17:02:21 +0000</pubDate>
      <link>https://forem.com/ranand12/aks-patching-and-node-pool-upgrade-azure-kubernetes-services-aks-explained-in-plain-english-2p5l</link>
      <guid>https://forem.com/ranand12/aks-patching-and-node-pool-upgrade-azure-kubernetes-services-aks-explained-in-plain-english-2p5l</guid>
      <description>&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/Afl72C-FEMg"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;This is part 3 of a multi-part series explaining "everything you need to know about node pools in Azure Kubernetes Services AKS" in plain english using animations. For part 1 click here &lt;a href="https://youtu.be/aGT3UtZoiA0" rel="noopener noreferrer"&gt;https://youtu.be/aGT3UtZoiA0&lt;/a&gt; and part 2 please click here - &lt;a href="https://youtu.be/45UxnRj11_g" rel="noopener noreferrer"&gt;https://youtu.be/45UxnRj11_g&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this video we will talk about: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The different patching and upgrade options for nodepool - Kubernetes Version upgrade and NodeImage upgrade&lt;/li&gt;
&lt;li&gt;The upgrade process using cordon and drain methodology&lt;/li&gt;
&lt;li&gt;Auto upgrade channels and options for AKS&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Commands from the video
&lt;/h3&gt;

&lt;h2&gt;
  
  
  Command to list the kubernetes version and the available kubernetes version upgrades on control plane
&lt;/h2&gt;

&lt;p&gt;az aks get-upgrades \&lt;br&gt;
   --resource-group ResourceGroupName --name AKSClusterName --output table&lt;/p&gt;

&lt;h2&gt;
  
  
  Command to list the kubernetes version for all the nodes in your nodepools
&lt;/h2&gt;

&lt;p&gt;az aks nodepool list \&lt;br&gt;&lt;br&gt;
   --resource-group ResourceGroupName --cluster-name AKSClusterName \&lt;br&gt;
   --query "[].{Name:name,k8version:orchestratorVersion}" --output table&lt;/p&gt;

&lt;h2&gt;
  
  
  Upgrade kubernetes version on all nodes at once
&lt;/h2&gt;

&lt;p&gt;In order to upgrade all nodes at once - we run the following command, this will upgrade all control plane and worker nodes at once to the desired kubernetes version&lt;/p&gt;

&lt;p&gt;az aks upgrade \&lt;br&gt;
   --resource-group ResourceGroupName --name AKSClusterName \&lt;br&gt;
    --no-wait \&lt;br&gt;
   --kubernetes-version KubernetesVersion&lt;/p&gt;

&lt;h2&gt;
  
  
  Upgrade kubernetes version on control plane alone
&lt;/h2&gt;

&lt;p&gt;If we only want to upgrade the kubernetes version for control plane alone - we run the same command but with the --control-plane-only switch &lt;/p&gt;

&lt;p&gt;az aks upgrade \&lt;br&gt;
   --resource-group ResourceGroupName --name AKSClusterName \&lt;br&gt;
   --control-plane-only --no-wait \&lt;br&gt;
   --kubernetes-version KubernetesVersion&lt;/p&gt;

&lt;h2&gt;
  
  
  Upgrade Kubernetes version on specific node pools
&lt;/h2&gt;

&lt;p&gt;If we need to upgrade the kubernetes version on only specific node pools we can run the following command by specifiying the nodepoolname and the kubernetes version &lt;/p&gt;

&lt;p&gt;az aks nodepool upgrade \&lt;br&gt;
   --resource-group ResourceGroupName --cluster-name AKSClusterName --name NodePoolName \&lt;br&gt;
   --no-wait --kubernetes-version KubernetesVersion&lt;/p&gt;

&lt;h2&gt;
  
  
  Nodepool image upgrade
&lt;/h2&gt;

&lt;p&gt;Running the following command lists all the current nodeimage versions of the  nodepool &lt;/p&gt;

&lt;p&gt;az aks nodepool list \&lt;br&gt;
   --resource-group ResourceGroupName --cluster-name AKSClusterName \&lt;br&gt;
   --query "[].{Name:name,NodeImageVersion:nodeImageVersion}" --output table&lt;/p&gt;

&lt;p&gt;the following command to list the available latest nodeimage version for us &lt;/p&gt;

&lt;p&gt;az aks nodepool get-upgrades \&lt;br&gt;
   --resource-group ResourceGroupName --cluster-name AKSClusterName \&lt;br&gt;
   --nodepool-name NodePoolName --output table&lt;/p&gt;

&lt;h2&gt;
  
  
  Upgrade nodeimage version for specific nodepool
&lt;/h2&gt;

&lt;p&gt;In order to upgrade the nodeimage vefsion for a specific nodepool we run the following command : &lt;/p&gt;

&lt;p&gt;az aks nodepool upgrade \&lt;br&gt;
    --resource-group myResourceGroup \&lt;br&gt;
    --cluster-name myAKSCluster \&lt;br&gt;
    --name mynodepool \&lt;br&gt;
    --node-image-only&lt;/p&gt;

&lt;p&gt;az aks nodepool show \&lt;br&gt;
    --resource-group myResourceGroup \&lt;br&gt;
    --cluster-name myAKSCluster \&lt;br&gt;
    --name mynodepool&lt;/p&gt;

&lt;h2&gt;
  
  
  Upgrade nodeimage version for all nodepools at once
&lt;/h2&gt;

&lt;p&gt;az aks upgrade \&lt;br&gt;
    --resource-group myResourceGroup \&lt;br&gt;
    --name myAKSCluster \&lt;br&gt;
    --node-image-only&lt;/p&gt;

&lt;p&gt;Remember If you don’t run the nodeimage switch remember the whole cluster including the kubernetes version of the control plane is also upgraded.&lt;/p&gt;

&lt;p&gt;az aks show \&lt;br&gt;
    --resource-group myResourceGroup \&lt;br&gt;
    --name myAKSCluster&lt;/p&gt;

&lt;h1&gt;
  
  
  azure #aks #nodepools #kubernetes #upgrade #cordon #drain #explained #plainenglish
&lt;/h1&gt;

&lt;p&gt;For more simplified video tutorials on Azure and Kubernetes - check out &lt;a href="http://www.azuremonk.com/video" rel="noopener noreferrer"&gt;www.azuremonk.com/video&lt;/a&gt; &lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>patching</category>
      <category>upgrade</category>
    </item>
    <item>
      <title>taints, tolerations, nodeselector in aks (azure kubernetes services) explained in plain english</title>
      <dc:creator>Anand Kumar R</dc:creator>
      <pubDate>Tue, 29 Mar 2022 17:01:04 +0000</pubDate>
      <link>https://forem.com/ranand12/taints-tolerations-nodeselector-in-aks-azure-kubernetes-services-explained-in-plain-english-2c0h</link>
      <guid>https://forem.com/ranand12/taints-tolerations-nodeselector-in-aks-azure-kubernetes-services-explained-in-plain-english-2c0h</guid>
      <description>&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/aGT3UtZoiA0"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;This is part 2 of a multi-part series explaining node pools in Azure Kubernetes Services AKS. For part 1 please click here - &lt;a href="https://youtu.be/45UxnRj11_g" rel="noopener noreferrer"&gt;https://youtu.be/45UxnRj11_g&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this video we will talk about: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;How we can use taints and tolerations to schedule pods in AKS nodes with demo&lt;/li&gt;
&lt;li&gt;How we can use NodeSelectors in AKS&lt;/li&gt;
&lt;li&gt;Link to Blogpost - &lt;a href="https://www.azuremonk.com/blog/kube-scheduler" rel="noopener noreferrer"&gt;https://www.azuremonk.com/blog/kube-scheduler&lt;/a&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h1&gt;
  
  
  azure #aks #nodepools #taints #tolerations #nodeselector #kubernetesscheduler #scheduler
&lt;/h1&gt;

&lt;p&gt;For more simplified video tutorials on Azure and Kubernetes - check out &lt;a href="http://www.azuremonk.com/video" rel="noopener noreferrer"&gt;www.azuremonk.com/video&lt;/a&gt;&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>taints</category>
      <category>aks</category>
    </item>
    <item>
      <title>azure kubernetes services (aks) node pools explained in plain english</title>
      <dc:creator>Anand Kumar R</dc:creator>
      <pubDate>Tue, 29 Mar 2022 16:59:43 +0000</pubDate>
      <link>https://forem.com/ranand12/azure-kubernetes-services-aks-node-pools-explained-in-plain-english-3e9h</link>
      <guid>https://forem.com/ranand12/azure-kubernetes-services-aks-node-pools-explained-in-plain-english-3e9h</guid>
      <description>&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/45UxnRj11_g"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;This is part 1 of a multi-part series explaining node pools in Azure Kubernetes Services AKS. &lt;/p&gt;

&lt;p&gt;In this video we will talk about: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;What is a nodepool? Why do we need them? &lt;/li&gt;
&lt;li&gt;Difference between system node pools and user node pools&lt;/li&gt;
&lt;li&gt;Walkthrough of how to create a nodepool in AKS&lt;/li&gt;
&lt;/ol&gt;

&lt;h1&gt;
  
  
  azure #aks #nodepools #systemnodepools #usernodepools #simplified
&lt;/h1&gt;

&lt;p&gt;For more simplified video tutorials on Azure and Kubernetes - check out &lt;a href="http://www.azuremonk.com/video" rel="noopener noreferrer"&gt;www.azuremonk.com/video&lt;/a&gt;&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>nodepool</category>
      <category>aks</category>
    </item>
    <item>
      <title>aks integration with azure ad explained in plain english - azure rbac, kubernetes rbac, kubeconfig</title>
      <dc:creator>Anand Kumar R</dc:creator>
      <pubDate>Tue, 16 Nov 2021 21:55:24 +0000</pubDate>
      <link>https://forem.com/ranand12/aks-integration-with-azure-ad-explained-in-plain-english-azure-rbac-kubernetes-rbac-kubeconfig-cih</link>
      <guid>https://forem.com/ranand12/aks-integration-with-azure-ad-explained-in-plain-english-azure-rbac-kubernetes-rbac-kubeconfig-cih</guid>
      <description>&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/ABbJWP6TToc"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;This is the super simplified video animated explanation on everything you ever wanted to know about Azure Active Directory and AKS (Azure Kubernetes Services) - from the basics&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;What is a kubeconfig file ? Why is it important ?&lt;/li&gt;
&lt;li&gt;Azure AD integrated AKS cluster v/s non-Azure AD integrated AKS cluster&lt;/li&gt;
&lt;li&gt;Azure Role based access control (RBAC) v/s Kubernetes Role Based Access Control (K8s RBAC)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://www.azuremonk.com/video" rel="noopener noreferrer"&gt;https://www.azuremonk.com/video&lt;/a&gt; &lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>rbac</category>
      <category>aks</category>
    </item>
    <item>
      <title>scaling an aks (azure kubernetes services) cluster explained in plain english</title>
      <dc:creator>Anand Kumar R</dc:creator>
      <pubDate>Tue, 16 Nov 2021 21:53:44 +0000</pubDate>
      <link>https://forem.com/ranand12/scaling-an-aks-azure-kubernetes-services-cluster-explained-in-plain-english-339g</link>
      <guid>https://forem.com/ranand12/scaling-an-aks-azure-kubernetes-services-cluster-explained-in-plain-english-339g</guid>
      <description>&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/HGUQW8fCBz8"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;This is the super simplified video animated explanation on everything you ever wanted to know about scaling in the context of an AKS cluster (Azure Kubernetes Services). We will cover the following topics: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Manually scale a pod in or our an AKS cluster - how to and demo &lt;/li&gt;
&lt;li&gt;Automatically scale pod in or out in an AKS cluster using horizontal pod autoscaler (hpa) - how to and demo.&lt;/li&gt;
&lt;li&gt;Manually scale a node in or out an AKS cluster - how to and demo &lt;/li&gt;
&lt;li&gt;Automatically scale a node in or out an AKS clusters - the gotchas, how to and demo&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://www.azuremonk.com/video" rel="noopener noreferrer"&gt;https://www.azuremonk.com/video&lt;/a&gt; &lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>scaling</category>
      <category>aks</category>
    </item>
    <item>
      <title>Kubernetes scheduler visually explained in plain English with a story</title>
      <dc:creator>Anand Kumar R</dc:creator>
      <pubDate>Thu, 25 Mar 2021 18:11:51 +0000</pubDate>
      <link>https://forem.com/ranand12/kubernetes-scheduler-visually-explained-in-plain-english-with-a-story-5h0g</link>
      <guid>https://forem.com/ranand12/kubernetes-scheduler-visually-explained-in-plain-english-with-a-story-5h0g</guid>
      <description>&lt;p&gt;In Kubernetes pod is the smallest deployable unit of workload. So the obvious question : &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;"Where should the pods be deployed?"&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Pods always execute inside a Node. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;But but.. there are so many Nodes - which one should node should I deploy this pod to ??!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Hello - "Kubernetes Scheduler"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Let's break down how the Kubernetes Scheduler works and the way it chooses a node in plain english with an analogy. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Lets say we have a "social-restaurant" where we have several tables and several seats around each table, lots of customers and a waiter for the hotel. "Social-restaurant" meaning different set of customers can sit around the same table, if there are enough seats and all conditions are met.&lt;/em&gt; &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmhlou7e2e080e8puv0pr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmhlou7e2e080e8puv0pr.png" alt="image-20200307040320255" width="800" height="485"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Table = Node (VM or a Physical Macine)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Seats = Resources availability on the VM&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Waiter = Kube-Scheduler&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Customer-Group = Pod&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;A single customer inside the group = Container&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Resource requirements and availability
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F77br9bjm54vu7vwiiiaq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F77br9bjm54vu7vwiiiaq.png" alt="image-20200307040320255" width="800" height="486"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;A **Customer-Group&lt;/em&gt;* comes into the restaurant and makes a simple request for a table to be seated. The waiter analyses the requirement of the &lt;strong&gt;Customer-Group&lt;/strong&gt; and looks at how many &lt;strong&gt;Seats&lt;/strong&gt; they would need. He then looks through all the available tables, filters the tables that cannot be "&lt;strong&gt;scheduled&lt;/strong&gt;" and assigns (&lt;strong&gt;binds&lt;/strong&gt;) them a table which would meet their &lt;strong&gt;Seating&lt;/strong&gt; requirement.* &lt;/p&gt;

&lt;p&gt;This is the basic kind of scheduling - where the kube scheduler constantly watches the API server to see if there are any pods which are unscheduled. Looks through the resource requirement for each of the container inside the pods. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Remember the containers are the ones which have the resource requirement in the spec not the pods themselves. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In the example below we have a CPU and Memory requirement under the container spec for the pod deployment. Requirements are 500 millicpu and an 128 MiB of memory.&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;v1&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;Pod&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;nginx&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;containers&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;nginx&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nginx:1.7.9&lt;/span&gt;
    &lt;span class="na"&gt;resources&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;requests&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;memory&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;128Mi"&lt;/span&gt;
        &lt;span class="na"&gt;cpu&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;500m"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now let's take a look at one of the nodes (&lt;strong&gt;&lt;em&gt;restaurant tables&lt;/em&gt;&lt;/strong&gt;) to ensure they have capacity. The way we would do that is run the following command :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl describe nodes &amp;lt;node-name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;which outputs all the properties of the nodes, but the ones we are interested are the Capacity and Allocatable. &lt;/p&gt;

&lt;p&gt;Remember CPU and memory are not the only filter criteria, there are lots more like persistent storage, network port requirements. Detailed list here.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjqrjxkbcq6t05rfy89dl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjqrjxkbcq6t05rfy89dl.png" alt="image-20200307040320255" width="800" height="476"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Node Selector
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmt67paibbqh0943w618p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmt67paibbqh0943w618p.png" alt="image-20200307040320255" width="800" height="485"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Another **Customer-Group&lt;/em&gt;* come in to the restaurant with a &lt;strong&gt;requirement&lt;/strong&gt; to be placed in any table which is "&lt;strong&gt;blue&lt;/strong&gt;". The waiter looks through his inventory and finds all the tables which has a &lt;strong&gt;label&lt;/strong&gt; of blue and assigns the Customer-Group to the appropriate &lt;strong&gt;table&lt;/strong&gt;*&lt;/p&gt;

&lt;p&gt;In this scenario the pod has a nodeSelector (key-value pair) specified which requests the pod to be deployment to any node which matches the key-value pair. &lt;/p&gt;

&lt;p&gt;Here is how the new YAML file will look like:&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;v1&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;Pod&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;nginx-blue&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;containers&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;nginx&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nginx:1.7.9&lt;/span&gt;
  &lt;span class="na"&gt;nodeSelector&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;color&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;blue&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In order to query all my nodes to check if we have the label "blue", we run the following command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl get nodes &lt;span class="nt"&gt;--show-labels&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;From the list we can see that "worker-2" has a label of &lt;strong&gt;&lt;em&gt;color=blue&lt;/em&gt;&lt;/strong&gt;. Also there are several built-in labels which Kubernetes provides us with too.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl40skhw9f76e40u7gdtg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl40skhw9f76e40u7gdtg.png" alt="image-20200307053046638" width="800" height="96"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Great ! If you now deploy this, the scheduler automatically assigns it to the right node. (worker-2). We can confirm this by running the following command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl get pod &lt;span class="nt"&gt;-o&lt;/span&gt; wide
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7vp8mft74bmggv48lzh6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7vp8mft74bmggv48lzh6.png" alt="image-20200307053808136" width="800" height="215"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note that if you did not have a node with the appropriate label the deployment would be Pending. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  3. Node affinity and anti-affinity
&lt;/h2&gt;

&lt;p&gt;Node affinity and anti-affinity are a lot like node selectors, but it gives you more flexibility by supporting expressive language and soft/hard preference rather than just a hard &lt;strong&gt;requirement&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl7k913xo2nxvmp4duaak.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl7k913xo2nxvmp4duaak.png" alt="image-20200307040320255" width="800" height="485"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Lets say another **Customer-Group&lt;/em&gt;* come in to the restaurant . They have a &lt;strong&gt;preference&lt;/strong&gt; to be placed in any table which is "&lt;strong&gt;ocean-view&lt;/strong&gt;", but its not &lt;strong&gt;required&lt;/strong&gt;. The waiter looks through his inventory and finds all the tables which has a &lt;strong&gt;label&lt;/strong&gt; of "&lt;strong&gt;ocean&lt;/strong&gt;" and assigns the Customer-Group to the appropriate &lt;strong&gt;table&lt;/strong&gt;*&lt;/p&gt;

&lt;p&gt;In this example the pod has a nodeAffinity defined which states that we &lt;strong&gt;&lt;em&gt;prefer&lt;/em&gt;&lt;/strong&gt; a "&lt;strong&gt;&lt;em&gt;node&lt;/em&gt;&lt;/strong&gt;" which matches the key value pair --&amp;gt; &lt;strong&gt;view : ocean&lt;/strong&gt; ( and we do that by the matchExpressions  below)&lt;/p&gt;

&lt;p&gt;There are two options here : &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;u&gt;preferredDuringSchedulingIgnoredDuringExecution&lt;/u&gt;&lt;/strong&gt; : which means that the nodes that match the criteria will be preferred, but not guaranteed when the allocation to the node happens. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;IgnoredDuringExecution - If you remove or change the label of the node after the pod is scheduled, the pod won’t be removed. In other words, the affinity selection works only at the time of scheduling the pod but not at execution &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;u&gt;requiredDuringSchedulingIgnoredDuringExecution&lt;/u&gt;&lt;/strong&gt; : which means that the nodes that match the criteria will be required when selecting the node. IgnoredDuringExecution is the same as before.
&lt;/li&gt;
&lt;/ul&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;v1&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;Pod&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;nginx-oceanview&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;containers&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;nginx&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nginx:1.7.9&lt;/span&gt;
  &lt;span class="na"&gt;affinity&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;nodeAffinity&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;preferredDuringSchedulingIgnoredDuringExecution&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;weight&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;
        &lt;span class="na"&gt;preference&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;matchExpressions&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
            &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;key&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;view&lt;/span&gt;
              &lt;span class="na"&gt;operator&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;In&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="s"&gt;ocean&lt;/span&gt;

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

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;The operator in this case can also be other values such as In, NotIn, Exists, DoesNotExist, Gt, Lt. NotIn and DoesNotExist will create the opposite effect of nodeAntiAffinity&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  4. Pod affinity and anti-affinity
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fofpf4zbrnfh98sqq4ot9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fofpf4zbrnfh98sqq4ot9.png" alt="image-20200307040320255" width="800" height="485"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Another vegan girl-gang **Customer-Group&lt;/em&gt;* come in to the restaurant . They have a &lt;strong&gt;requirement&lt;/strong&gt; &lt;strong&gt;not&lt;/strong&gt; to be placed in any &lt;strong&gt;table&lt;/strong&gt; which contain &lt;strong&gt;seats&lt;/strong&gt; which are already occupied by meat eaters. They are a little more choosy - they also want to be seated in tables which contains seats which are already occupied by boys. In other words they have a &lt;strong&gt;non-affinity&lt;/strong&gt; towards meat-eaters, but have an &lt;strong&gt;affinity&lt;/strong&gt; towards boys.*&lt;/p&gt;

&lt;p&gt;Lets take a real world scenario where you have a set of redis-cache and web-server deployments. Here are the conditions: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You want the &lt;strong&gt;redis-cache&lt;/strong&gt; pods deployed as close to the &lt;strong&gt;web-servers&lt;/strong&gt; pods as possible (podAffinity)&lt;/li&gt;
&lt;li&gt;You don't want two &lt;strong&gt;redis-cache&lt;/strong&gt; pods in the same node (podAntiAffinity)&lt;/li&gt;
&lt;li&gt;You don't want to deploy two &lt;strong&gt;web-server&lt;/strong&gt; pods in the same node (podAntiAffiinity)&lt;/li&gt;
&lt;li&gt;You want these rules to hold good for the &lt;strong&gt;scope&lt;/strong&gt; of a node. (topology)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here is how the &lt;strong&gt;redis-cache&lt;/strong&gt; deployment YAML would look.  :&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;apps/v1&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;Deployment&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;redis-cache&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;selector&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;matchLabels&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;apptype&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;redis-cache&lt;/span&gt;
  &lt;span class="na"&gt;replicas&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;3&lt;/span&gt;
  &lt;span class="na"&gt;template&lt;/span&gt;&lt;span class="pi"&gt;:&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;labels&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;apptype&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;redis-cache&lt;/span&gt;
    &lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;affinity&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;podAntiAffinity&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;requiredDuringSchedulingIgnoredDuringExecution&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;labelSelector&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
              &lt;span class="na"&gt;matchExpressions&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
              &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;key&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;apptype&lt;/span&gt;
                &lt;span class="na"&gt;operator&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;In&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="s"&gt;redis-cache&lt;/span&gt;
            &lt;span class="na"&gt;topologyKey&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;kubernetes.io/hostname"&lt;/span&gt;
      &lt;span class="na"&gt;containers&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;redis-server&lt;/span&gt;
        &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;redis:3.2-alpine&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the example above: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In the example above you see that the redis-cache label (&lt;strong&gt;apptype=redis-cache&lt;/strong&gt;) is added to every pod which gets deployed as part of this deployment&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;podAntiAffinity&lt;/strong&gt; is described such that no two redis-cache pods are deployed inside the same server. This is defined by the by the built-in topology "kubernetes.io/hostname" which means its a single node. This can also be extended to zones or any other legal-key if required. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Awesome - once you deploy this - here is what you would get : &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fovggc2h70gndzzetg2ol.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fovggc2h70gndzzetg2ol.png" alt="image-20200307111559647" width="800" height="56"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, lets take a look at the &lt;strong&gt;web-server&lt;/strong&gt; deployment YAML file&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;apps/v1&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;Deployment&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;web-server&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;selector&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;matchLabels&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;apptype&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;web-server&lt;/span&gt;
  &lt;span class="na"&gt;replicas&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;3&lt;/span&gt;
  &lt;span class="na"&gt;template&lt;/span&gt;&lt;span class="pi"&gt;:&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;labels&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;apptype&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;web-server&lt;/span&gt;
    &lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;affinity&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;podAntiAffinity&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;requiredDuringSchedulingIgnoredDuringExecution&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;labelSelector&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
              &lt;span class="na"&gt;matchExpressions&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
              &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;key&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;apptype&lt;/span&gt;
                &lt;span class="na"&gt;operator&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;In&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="s"&gt;web-server&lt;/span&gt;
            &lt;span class="na"&gt;topologyKey&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;kubernetes.io/hostname"&lt;/span&gt;
        &lt;span class="na"&gt;podAffinity&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;requiredDuringSchedulingIgnoredDuringExecution&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;labelSelector&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
              &lt;span class="na"&gt;matchExpressions&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
              &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;key&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;apptype&lt;/span&gt;
                &lt;span class="na"&gt;operator&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;In&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="s"&gt;redis-cache&lt;/span&gt;
            &lt;span class="na"&gt;topologyKey&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;kubernetes.io/hostname"&lt;/span&gt;
      &lt;span class="na"&gt;containers&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;web-app&lt;/span&gt;
        &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nginx:1.12-alpine&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the example above: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In the example above you see that the web-server label (&lt;strong&gt;apptype=web-server&lt;/strong&gt;) is added to every pod which gets deployed as part of this deployment&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;podAntiAffinity&lt;/strong&gt; is described such that no two &lt;strong&gt;web-server&lt;/strong&gt; pods are deployed inside the same server. This is defined by the by the built-in &lt;strong&gt;topologyKey&lt;/strong&gt; "kubernetes.io/hostname" which means its a single node. This can also be extended to zones or any other legal-key if required. &lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;podAffinity&lt;/strong&gt; is described such that the &lt;strong&gt;web-server&lt;/strong&gt; pods are deployed as close to the &lt;strong&gt;redis-cache&lt;/strong&gt; as possible. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once you deploy this - we got what we were aiming for - 3 web-servers and 3 redis-cache servers - one copy of each on one node !&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frnlwt8f3lscqoyrfa5k8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frnlwt8f3lscqoyrfa5k8.png" alt="image-20200307112522256" width="800" height="99"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Taint and Tolerations
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5nb2ylf1nro5ckvupj92.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5nb2ylf1nro5ckvupj92.png" alt="image-20200307040320255" width="800" height="485"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This time around the restaurant got one of the tables "&lt;/em&gt;&lt;em&gt;tainted&lt;/em&gt;&lt;em&gt;" with a peanut spillage disaster. So they have said no new **Customer-Groups&lt;/em&gt;* will be scheduled on this table to avoid allergic reactions. So any new Customer-Groups are placed on every other table except this tainted one.* &lt;/p&gt;

&lt;p&gt;So far we have been looking at scheduling from a pod perspective. But what if the other way around the node decides not to schedule anymore new pods ? This is where &lt;strong&gt;taints&lt;/strong&gt; come in.  Once you &lt;strong&gt;taint&lt;/strong&gt; a node you have two options : &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;u&gt;NoSchedule&lt;/u&gt;&lt;/strong&gt; - This means no new pods should be scheduled on this pod once its tainted. *unless they have a toleration &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;u&gt;NoExecute&lt;/u&gt;&lt;/strong&gt; - Existing pods will be evicted from the pod once its tainted. *unless they have a toleration (we will talk about tolerations in just a minute) &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So how do we taint a node ?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl taint nodes &amp;lt;nodename&amp;gt; &lt;span class="nv"&gt;mytaintkey&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;mytaintvalue:NoSchedule
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once we have this set the node is now tainted with the following key value pair (&lt;strong&gt;mytaintkey=mytaintvalue&lt;/strong&gt;). So no new pods can be scheduled. &lt;/p&gt;

&lt;p&gt;But what if you want to evict the existing pods from the nodes ?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl taint nodes &amp;lt;nodename&amp;gt; &lt;span class="nv"&gt;mytaintkey&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;mytaintvalue:NoExecute
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will evict all pods from the current node and move them to another available node. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fci55lok8mxt7onizhs50.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fci55lok8mxt7onizhs50.png" alt="image-20200307040320255" width="800" height="485"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;But after a while a Customer-Group comes along and says - "Oh that's fine. We have *&lt;/em&gt;"toleration"** for peanut allergies. So please proceed and place us in the "&lt;strong&gt;tainted&lt;/strong&gt;" table". The Kube scheduler verifies their toleration and places them in the tainted table*&lt;/p&gt;

&lt;p&gt;Now if the pod has a toleration for the taint key value that the node has specified, then this pod will get exempted from the taint and will be placed on the node if necessary.&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;v1&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;Pod&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;web-server&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;containers&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;web-app&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nginx:1.12-alpine&lt;/span&gt;
  &lt;span class="na"&gt;tolerations&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;key&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;mytaintkey"&lt;/span&gt;
    &lt;span class="na"&gt;operator&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Equal"&lt;/span&gt;
    &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;mytaintvalue"&lt;/span&gt;
    &lt;span class="na"&gt;effect&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;NoExecute"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;credits to Carson Anderson for planting this idea-seed from his &lt;a href="https://www.youtube.com/watch?v=90kZRyPcRZw" rel="noopener noreferrer"&gt;awesome Kube-Decon talk&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This article originally appeared on &lt;a href="https://www.cloud-monk.com/blog/kube-scheduler" rel="noopener noreferrer"&gt;www.cloud-monk.com&lt;/a&gt;&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>beginners</category>
      <category>tutorial</category>
      <category>simplified</category>
    </item>
    <item>
      <title>aks storage - persistent volumes, persistent volume claims and storage classes explained in plain english in less than 5 minutes</title>
      <dc:creator>Anand Kumar R</dc:creator>
      <pubDate>Sun, 21 Mar 2021 15:21:18 +0000</pubDate>
      <link>https://forem.com/ranand12/aks-storage-persistent-volumes-persistent-volume-claims-and-storage-classes-explained-in-plain-english-in-less-than-5-minutes-5c8p</link>
      <guid>https://forem.com/ranand12/aks-storage-persistent-volumes-persistent-volume-claims-and-storage-classes-explained-in-plain-english-in-less-than-5-minutes-5c8p</guid>
      <description>&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/ggIEe8wPGJM"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;This is the simplified visual animated explanation of Persistent Volumes, Persistent Volume Claims and Storage Classes in Azure Kubernetes Services (AKS) with the help of a real world example&lt;/p&gt;

&lt;p&gt;In this part we will discuss : &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1. What a persistent volume is and why it's important ?
2. What is a persistent volume claim and how to leverage it ? 
3. What is a storage class and how it helps in provisioning persistent volumes dynamically.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;If you haven't seen part 1 of the video, please do check it out here --&amp;gt; &lt;a href="https://www.youtube.com/watch?v=o7UTiRTfk-M" rel="noopener noreferrer"&gt;https://www.youtube.com/watch?v=o7UTiRTfk-M&lt;/a&gt; where we cover : Volumes and Volume Mounts Different Kinds of Volumes - Azure Files, Azure Disks, EmptyDir, Secrets and ConfigMaps. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.azuremonk.com/video" rel="noopener noreferrer"&gt;https://www.azuremonk.com/video&lt;/a&gt; #aks #azure #azurein5minutes #aksstorage #azuredisks #azurefiles #k8s #aksvolumes #volumetypes #emptydir #secrets #configmaps #persistentvolumes #persistentvolumeclaims #pvc #persistentvolumes #pv #storageclasses &lt;a href="https://www.azuremonk.com" rel="noopener noreferrer"&gt;https://www.azuremonk.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.azuremonk.com" rel="noopener noreferrer"&gt;https://www.azuremonk.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;AKS (azure kubernetes services) in plain english &lt;/p&gt;

&lt;h1&gt;
  
  
  aks​ #azure​ #azurein5minutes​ #aksstorage​ #azuredisks​ #azurefiles​ #k8s​ #aksvolumes​ #volumetypes​ #emptydir​ #secrets​ #configmaps​ #persistentvolumes​ #persistentvolumeclaims​  #pvc​ #persistentvolumes​ #pv​ #storageclasses
&lt;/h1&gt;

</description>
      <category>kubernetes</category>
      <category>persistentvolume</category>
      <category>storageclass</category>
    </item>
    <item>
      <title>aks storage - volumes explained in plain english in less than 5 minutes</title>
      <dc:creator>Anand Kumar R</dc:creator>
      <pubDate>Thu, 04 Feb 2021 11:15:02 +0000</pubDate>
      <link>https://forem.com/ranand12/aks-storage-volumes-explained-in-plain-english-in-less-than-5-minutes-3omm</link>
      <guid>https://forem.com/ranand12/aks-storage-volumes-explained-in-plain-english-in-less-than-5-minutes-3omm</guid>
      <description>&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/o7UTiRTfk-M"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;This is the ridiculously simple animated explanation of Azure Storage Options - in less than 5 minutes. In part 1 of the video we will cover : &lt;/p&gt;

&lt;p&gt;Volumes and Volume Mounts&lt;br&gt;
Different Kinds of Volumes - Azure Files, Azure Disks, EmptyDir, Secrets and ConfigMaps&lt;br&gt;
Step by step creation of Azure Files and Azure Disks Volumes&lt;/p&gt;

&lt;p&gt;In part 2 of the video we will discuss --&lt;/p&gt;

&lt;p&gt;Persistent Volume (PV)&lt;br&gt;
Persistent Volume Claims (PVC)&lt;br&gt;
Storage Classes&lt;/p&gt;

&lt;p&gt;For more animated Azure videos and simplified Azure content and podcasts please check out &lt;a href="https://www.azuremonk.com/video%E2%80%8B" rel="noopener noreferrer"&gt;https://www.azuremonk.com/video​&lt;/a&gt; #aks​ #azure​ #azurein5minutes​ #aksstorage​ #azuredisks​ #azurefiles​ #k8s​ #aksvolumes​ #volumetypes​ #emptydir​ #secrets​ #configmaps​ #persistentvolumes​ #persistentvolumeclaims​  #pvc​ #persistentvolumes​ #pv​ #storageclasses​&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.azuremonk.com" rel="noopener noreferrer"&gt;https://www.azuremonk.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;AKS (azure kubernetes services) in plain english &lt;/p&gt;

&lt;h1&gt;
  
  
  aks​ #azure​ #azurein5minutes​ #aksstorage​ #azuredisks​ #azurefiles​ #k8s​ #aksvolumes​ #volumetypes​ #emptydir​ #secrets​ #configmaps​ #persistentvolumes​ #persistentvolumeclaims​  #pvc​ #persistentvolumes​ #pv​ #storageclasses
&lt;/h1&gt;

</description>
      <category>beginners</category>
      <category>kubernetes</category>
      <category>aks</category>
      <category>storage</category>
    </item>
  </channel>
</rss>
