<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Categories on Luigi Zhou&#39;s Blog on Linux, Kubernetes, Observability and more...</title>
    <link>https://www.luigizhou.com/categories/</link>
    <description>Recent content in Categories on Luigi Zhou&#39;s Blog on Linux, Kubernetes, Observability and more...</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-us</language>
    <copyright>©2023 - Luigi Zhou.</copyright>
    <lastBuildDate>Sun, 30 Jul 2023 16:56:56 +0000</lastBuildDate>
    
        <atom:link href="https://www.luigizhou.com/categories/index.xml" rel="self" type="application/rss+xml" />
    
    
    <item>
      <title>Understanding Kubernetes Resource Quotas and Limits: Best Practices for Optimal Cluster Management</title>
      <link>https://www.luigizhou.com/posts/2023-07-30-understanding-kubernetes-resource-quotas-and-limits-best-practices-for-optimal-cluster-management/</link>
      <pubDate>Sun, 30 Jul 2023 16:56:56 +0000</pubDate>
      
      <guid>https://www.luigizhou.com/posts/2023-07-30-understanding-kubernetes-resource-quotas-and-limits-best-practices-for-optimal-cluster-management/</guid>
      <description>&lt;h2 id=&#34;introduction&#34;&gt;Introduction&lt;/h2&gt;
&lt;p&gt;Kubernetes has revolutionized container orchestration and brought scalability and flexibility to modern applications. As your Kubernetes cluster grows and accommodates an increasing number of workloads, managing resource allocation becomes critical. In this blog post, we will delve into Kubernetes resource quotas and limits, exploring their significance in cluster management and sharing best practices to optimize resource utilization for a stable and efficient environment.&lt;/p&gt;
&lt;h2 id=&#34;the-importance-of-resource-quotas-and-limits&#34;&gt;The Importance of Resource Quotas and Limits&lt;/h2&gt;
&lt;p&gt;Resource quotas and limits play a vital role in Kubernetes by ensuring a well-functioning and fair cluster. They prevent resource-hungry workloads from affecting others and help maintain overall stability.&lt;/p&gt;
&lt;h2 id=&#34;understanding-resource-quotas&#34;&gt;Understanding Resource Quotas&lt;/h2&gt;
&lt;p&gt;Kubernetes resource quotas control the amount of resources that a namespace or user can consume. They are essential for preventing individual applications from using excessive resources and ensure that all applications get their fair share.&lt;/p&gt;
&lt;p&gt;Types of resource quotas include:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Compute resource quotas (CPU, memory, etc.).&lt;/li&gt;
&lt;li&gt;Object count quotas (number of Pods, Services, etc.).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Configuring resource quotas is a straightforward process and can be done through YAML manifests or Kubernetes API.&lt;/p&gt;
&lt;h2 id=&#34;working-with-resource-limits&#34;&gt;Working with Resource Limits&lt;/h2&gt;
&lt;p&gt;Resource limits set caps on the maximum amount of resources that a container or Pod can consume. By setting resource limits, you prevent applications from monopolizing resources and causing cluster instability.&lt;/p&gt;
&lt;p&gt;Types of resource limits include:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;CPU limits&lt;/li&gt;
&lt;li&gt;Memory limits&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Setting resource limits can be done alongside resource requests in Pod specifications.&lt;/p&gt;
&lt;h2 id=&#34;best-practices-for-resource-allocation&#34;&gt;Best Practices for Resource Allocation&lt;/h2&gt;
&lt;p&gt;Optimizing resource allocation is crucial for efficient cluster management. Follow these best practices to ensure optimal resource utilization:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Analyze Application Requirements: Understand the resource needs of your applications to set accurate quotas and limits. This prevents overallocation or underallocation of resources.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Resource Requests vs. Limits: Distinguish between resource requests and limits. Resource requests are what a container needs to start running, while limits define the maximum resources it can use.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Leveraging Horizontal Pod Autoscaler (HPA): Utilize HPA to automatically adjust resource limits based on application demands. HPA ensures that your applications have sufficient resources during peak usage.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;monitoring-and-troubleshooting-resource-quotas-and-limits&#34;&gt;Monitoring and Troubleshooting Resource Quotas and Limits&lt;/h2&gt;
&lt;p&gt;Monitoring resource utilization is crucial for identifying potential issues and bottlenecks. Use monitoring tools and techniques to track resource consumption in real-time. In case of problems, troubleshoot common issues related to resource constraints.&lt;/p&gt;
&lt;p&gt;Additionally, set up alerts and automate remediation for resource-related problems to maintain cluster health.&lt;/p&gt;
&lt;h2 id=&#34;conclusion&#34;&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;Resource quotas and limits are indispensable tools for effective Kubernetes cluster management. By implementing best practices for resource allocation and monitoring, you can optimize resource utilization and ensure a stable and high-performing environment for your applications.&lt;/p&gt;
&lt;p&gt;Follow the guidelines shared in this blog post to make the most of Kubernetes resource quotas and limits, ensuring the seamless operation of your containerized workloads.&lt;/p&gt;
&lt;p&gt;Happy container orchestration!&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>CKA Tips for Kubernetes Veterans</title>
      <link>https://www.luigizhou.com/posts/cka-tips/</link>
      <pubDate>Sun, 04 Sep 2022 14:16:09 +0000</pubDate>
      
      <guid>https://www.luigizhou.com/posts/cka-tips/</guid>
      <description>&lt;p&gt;&lt;img  src=&#34;https://davidstamen.com/images/cka.png&#34;
        alt=&#34;CKA&#34;/&gt;&lt;/p&gt;
&lt;p&gt;I&amp;rsquo;ve recently taken the CKA certification exam online after working for a few years with Kubernetes and just wanted to share a few tips for the veterans!&lt;/p&gt;
&lt;h2 id=&#34;tip-1---dont-be-scared&#34;&gt;Tip 1 - Don&amp;rsquo;t be scared!&lt;/h2&gt;
&lt;p&gt;Do not be afraid. If you&amp;rsquo;ve been working with Kubernetes for a relatively long time, chances are that you&amp;rsquo;ll be able to breeze through the exam quite easily.
I have been in the space for a few years now and I was confidently able to complete the exam with just a couple of days of preparation&lt;/p&gt;
&lt;h2 id=&#34;tip-2---you-should-still-prepare-yourself&#34;&gt;Tip 2 - You should still prepare yourself&lt;/h2&gt;
&lt;p&gt;While the test for a veteran Kubernetes engineer won&amp;rsquo;t be too hard, you still want to make sure you work through your hands-on skill.
The CKA test requires a lot of hands-on skill, so roughly knowing the Pod/Deployment/Statefulset/Daemnset spec will come in handy. I always have a hard time remembering the whole syntax for pod/node affinity!&lt;/p&gt;
&lt;h2 id=&#34;tip-3---get-familiar-with-navigating-the-kubernetes-official-documentation&#34;&gt;Tip 3 - Get familiar with navigating the Kubernetes official documentation&lt;/h2&gt;
&lt;p&gt;This is probably the most crucial tip I can give you. The Kubernetes documentation is very powerful and it&amp;rsquo;s one of the sources you can freely use during the exam. That is how, even without remembering by heart how to write the pod affinity, I was able to still write it correctly when I was asked to.&lt;/p&gt;
&lt;p&gt;Of course, I was very familiar with the concept, so the documentation is just a way to not lose time trying to remember what fields go where.&lt;/p&gt;
&lt;h2 id=&#34;tip-4---kubectl-explain&#34;&gt;Tip 4 - kubectl explain&lt;/h2&gt;
&lt;p&gt;You might not know this, but kubectl has an explain command! This is very handy when you&amp;rsquo;re not entirely sure what values are accepted in certain fields and it can also be used to go through the tree of fields that are available in a Kubernetes object spec!&lt;/p&gt;
&lt;p&gt;And while not inherent to the CKA exam, the kubectl explain command also works with Custom Resources and therefore is very useful when you don&amp;rsquo;t have the documentation page for that CRD readily available!&lt;/p&gt;
&lt;h2 id=&#34;tip-5---killersh&#34;&gt;Tip 5 - killer.sh&lt;/h2&gt;
&lt;p&gt;As ominous as that name sounds, killer.sh is a CKA exam simulator that is a MUST to take if you want to increase your chances of passing the exam!
It&amp;rsquo;s so good now that when you buy the CKA exam, 2 tries at the killer.sh simulation exams are included in the price and can be redeemed if you&amp;rsquo;re using your Linuxfoundation account to log in!&lt;/p&gt;
&lt;p&gt;The exam is much more difficult and has more questions, so don&amp;rsquo;t feel down if you&amp;rsquo;re not able to complete it in the allocated time. If you can get 50-60% right, then you&amp;rsquo;re good to go!&lt;/p&gt;
&lt;h2 id=&#34;tip-6---relax&#34;&gt;Tip 6 - Relax&lt;/h2&gt;
&lt;p&gt;You&amp;rsquo;re bound to have an answer or two that you&amp;rsquo;re not sure about but you shouldn&amp;rsquo;t worry too much and just skip to the next one!
You can always go back and review your answer before you submit them and remember that you can attempt the exam twice!&lt;/p&gt;
&lt;h2 id=&#34;tip-7---location-location-location&#34;&gt;Tip 7 - Location, Location, Location&lt;/h2&gt;
&lt;p&gt;It is now much more common to take the exam at home now that we&amp;rsquo;re in a post-covid society. Be sure to follow all the guidelines as the proctor of the exam will ask you to turn your webcam around to check if there are any irregularities.&lt;/p&gt;
&lt;p&gt;Make sure you&amp;rsquo;re in a quiet room and that no one will disturb you for the next 2-3 hours!&lt;/p&gt;
&lt;h2 id=&#34;tip-8---put-aside-enough-time-for-the-exam&#34;&gt;Tip 8 - Put aside enough time for the exam&lt;/h2&gt;
&lt;p&gt;While the time of the exam is roughly around 2 hours, you want to make sure you&amp;rsquo;re going to be disturbance-free for at least 3 hours in a room you know you won&amp;rsquo;t be interrupted.
When I took the exam, I ended up starting 30 minutes later due to making sure my local setup for the exam was working fine and doing a tour of my room via my webcam&lt;/p&gt;
&lt;h2 id=&#34;after-the-exam&#34;&gt;After the exam?&lt;/h2&gt;
&lt;p&gt;If you&amp;rsquo;re not a Kubernetes veteran already, now that you have the CKA you&amp;rsquo;re ready to work with Kubernetes!
Otherwise, as a Kubernetes veteran, there are a couple of paths I would suggest to continue:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Learn to create Kubernetes Controller and Admission/Mutating Webhook. They&amp;rsquo;ll greatly enhance your knowledge of how Kubernetes works internally. It&amp;rsquo;s a topic that is not covered during the CKA but I consider it to be a must to learn if you&amp;rsquo;re managing a Kubernetes platform.&lt;/li&gt;
&lt;li&gt;Start looking into the CKS certification. I haven&amp;rsquo;t done that yet myself, but I&amp;rsquo;ve been working in a very secure Kubernetes environment and one thing I can tell you for certain, you can go to great lengths in ensuring that Kubernetes is secure and it&amp;rsquo;s worth looking into it&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I hope this article will be useful to you all, if so let me know!&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>About Me</title>
      <link>https://www.luigizhou.com/about/</link>
      <pubDate>Sun, 04 Sep 2022 12:49:45 +0000</pubDate>
      
      <guid>https://www.luigizhou.com/about/</guid>
      <description>&lt;hr&gt;
&lt;p&gt;Hey All, I&amp;rsquo;m Luigi nice to meet ya!
I work as Platform Engineer and here&amp;rsquo;s a few things about me:&lt;/p&gt;
&lt;p&gt;I&amp;rsquo;m passionate about IT and tecnology, love Kubernetes and write golang/python whenever I have the chance.&lt;/p&gt;
&lt;p&gt;Discovered I love cycling so been doing that for a while now (you can find me on Strava, but I&amp;rsquo;m a very private person eheh).&lt;/p&gt;
&lt;p&gt;When I am not working or exploring new tech/hobbies, I enjoy a good movie, videogames and spending time with my family ;)&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Helm Charts V3</title>
      <link>https://www.luigizhou.com/posts/helm-charts-attempt/</link>
      <pubDate>Wed, 12 Feb 2020 00:00:00 +0000</pubDate>
      
      <guid>https://www.luigizhou.com/posts/helm-charts-attempt/</guid>
      <description>&lt;p&gt;&lt;img  src=&#34;https://www.luigizhou.com/images/helm.png&#34;
        alt=&#34;Helm&#34;/&gt;&lt;/p&gt;
&lt;p&gt;When I started my journey into Kubernetes back in 2018, I remember people talking about Helm as the easiest way to deploy applications into Kubernetes. I remember the tool was a favourite for developers and I got curious about it and started to look more into it.&lt;/p&gt;
&lt;p&gt;It was with a heavy heart that I decided to drop Helm altogether at the time.&lt;/p&gt;
&lt;p&gt;The main concerns I had were about:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Security around the Tiller component&lt;/li&gt;
&lt;li&gt;A non-purist approach towards Kubernetes declarative manifests&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The first reason is pretty self-explanatory since Tiller was also described as one giant sudo server. The second one was around the argument that &amp;ldquo;cloud-native&amp;rdquo; application should be able to gracefully handle dependencies that takes more time to be deployed either by implementing a retry logic or other means.&lt;/p&gt;
&lt;p&gt;What changed my mind now? Well, the advent of helm 3&lt;/p&gt;
&lt;h2 id=&#34;helm-3---a-tillerless-world&#34;&gt;Helm 3 - A Tillerless world&lt;/h2&gt;
&lt;p&gt;To my surprise, Helm 3 was released without the need of having Tiller deployed in Kubernetes.&lt;/p&gt;
&lt;p&gt;You can read more about all the changes &lt;a href=&#34;https://helm.sh/docs/faq/&#34;target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;here&lt;/a&gt;
 and in case you didn&amp;rsquo;t know, you can also read more in detail about the security concerns around Tiller.&lt;/p&gt;
&lt;p&gt;This was incredibly liberating since it was my biggest concern with the tool so far and combined with the fact that I was getting a little bit tired of having to write Kubernetes manifests with very repeatable fields, it made adopting helm all the more compelling.&lt;/p&gt;
&lt;p&gt;Helm templating was anyway a great feature you could use if you didn&amp;rsquo;t want tiller in your cluster and many people were using it that way, but because my work on Kubernetes was more project focused I never had a big need for it until quite recently.&lt;/p&gt;
&lt;h2 id=&#34;the-bad-things&#34;&gt;The bad things&lt;/h2&gt;
&lt;p&gt;Finally getting started with Helm proved to be more difficult than I hoped.
Although plenty of charts were out there ready to be consumed, developing one was not as easy as I originally believed.&lt;/p&gt;
&lt;h3 id=&#34;the-problem-with-documentation&#34;&gt;The problem with documentation&lt;/h3&gt;
&lt;p&gt;I found it quite hard to navigate the documentation. Although very complete and descriptive about the features available to Helm, I found it hard to read it through since sometimes it feels more like a collection of blog posts.&lt;/p&gt;
&lt;p&gt;The way it is also formatted makes it hard to find the information you&amp;rsquo;re seeking and the side menu that keeps on closing every time you click an element is a little irritating.&lt;/p&gt;
&lt;p&gt;A great deal of improvement could be made by just adjusting the website font size and menu, which hopefully is something other people can agree with.&lt;/p&gt;
&lt;h3 id=&#34;the-problem-with-secrets&#34;&gt;The problem with secrets&lt;/h3&gt;
&lt;p&gt;Another big issue I found with Helm is the lack of management of the secrets or more specifically generated secrets. There is a whole thread opened in &lt;a href=&#34;https://github.com/helm/charts/issues/5167&#34;target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;github&lt;/a&gt;
 if you want to read about it, but in essence, at the moment of my writing, you shouldn&amp;rsquo;t use Helm to define your secrets.&lt;/p&gt;
&lt;p&gt;I stumbled upon a nice way of generating random password in a helm way, but I soon found out that successive releases were breaking because a new randomly generated password would be pushed into my Kubernetes secrets and would break functionality.&lt;/p&gt;
&lt;p&gt;This is because Helm doesn&amp;rsquo;t handle secrets. It was very confusing for me since many charts had randomly generated password for defaults and I didn&amp;rsquo;t notice until I started to play around with it.&lt;/p&gt;
&lt;p&gt;For my charts, secrets are at the moment statically defined by the values yaml file. I believe it&amp;rsquo;s the best way to have a chart user being more aware of what&amp;rsquo;s going on. Because Helm doesn&amp;rsquo;t do secret management, the best way I believe to move forward is to define secrets externally and load them at runtime during deployment in a pipeline.&lt;/p&gt;
&lt;h3 id=&#34;the-problem-with-ready-to-use-charts&#34;&gt;The problem with ready to use charts&lt;/h3&gt;
&lt;p&gt;The charts that can be found under the stable repository of Helm are very nice, definitely really good to get started quickly, but a bad idea to use &amp;ldquo;AS IS&amp;rdquo; for production.&lt;/p&gt;
&lt;p&gt;The biggest problem I have with them is the over-generalization, which is a must if you want to share your work with other people since what works for you may not work with everyone else depending on different configurations and other factors, but it&amp;rsquo;s daunting when you want to adopt it in your company.&lt;/p&gt;
&lt;p&gt;It becomes a big vetting process, where you try to understand what the chart is doing and why is it doing it in that way. This becomes even more difficult given the fact that Charts are incredibly hard to read especially with if/else logic and obscure template function you may not know about.&lt;/p&gt;
&lt;h3 id=&#34;the-lack-of-an-out-of-the-box-diff-feature&#34;&gt;The lack of an out of the box diff feature&lt;/h3&gt;
&lt;p&gt;This is not really on Helm, as I believe this is not available out of the box in Kubernetes as well, but I believe it could be a cool feature to implement out of the box in the tool. I know there is a plugin that does this and I haven&amp;rsquo;t tested it yet, but since it is possible I believe it would be nice to have it in Helm.&lt;/p&gt;
&lt;p&gt;This opinion comes from a heavy Terraform user, which is an incredible tool that gives you the ability to see what is going to happen before you push your infrastructure as code into production (or any other environment). It let me know what is going to change, which is a great way to double-check if I&amp;rsquo;m doing something wrong.&lt;/p&gt;
&lt;p&gt;If Helm had a feature like that out of the box, I believe it could be the killer feature that would push the whole community to adopt helm as a standard for deployment in Kubernetes.&lt;/p&gt;
&lt;h2 id=&#34;the-good-things&#34;&gt;The good things&lt;/h2&gt;
&lt;p&gt;Helm is an incredible tool that in my opinion fits quite well with the Kubernetes world.&lt;/p&gt;
&lt;p&gt;It enables you to create reusable deployments, package it and share it within the company or the community. I also believe it is the only tool so far that makes this possible without having to write additional scripts.&lt;/p&gt;
&lt;p&gt;I previously mentioned how Helm approach was &amp;ldquo;non-purist&amp;rdquo;, but I learned over time that in real-world scenario it can be quite difficult to have the time to implement the necessary logic to make the application smarter. Sometimes it&amp;rsquo;s just difficult to convince management that it is worth the time, and sometimes it&amp;rsquo;s just not that trivial. That&amp;rsquo;s why the dependency management of Helm comes out as a winner since the outcome is faster implementation and delivery to production.&lt;/p&gt;
&lt;h2 id=&#34;conclusion&#34;&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;Although I wrote more about the bad instead of the good, Helm still comes out on top as the tool to use for deployment in Kubernetes. There is no valid alternative at the moment and so far it&amp;rsquo;s the best way to properly package and standardise your deployment.&lt;/p&gt;
&lt;p&gt;It could be further polished, which is what all of the &amp;ldquo;bad things&amp;rdquo; I described are all about, but overall it&amp;rsquo;s pretty good.
This is, of course, coming out of a 2-week experience with Helm so I could change my mind in the future (which I will, of course, write about in this blog) but for what I see, the tool can only improvement so I don&amp;rsquo;t think I will.&lt;/p&gt;
</description>
    </item>
    
  </channel>
</rss>