<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Emin ALEMDAR on Medium]]></title>
        <description><![CDATA[Stories by Emin ALEMDAR on Medium]]></description>
        <link>https://medium.com/@eminalemdar?source=rss-b3bf23b97abd------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*eoQI-OOGDQFwkgepaZpPQw.jpeg</url>
            <title>Stories by Emin ALEMDAR on Medium</title>
            <link>https://medium.com/@eminalemdar?source=rss-b3bf23b97abd------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 08:53:33 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@eminalemdar/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Now what? Kubernetes Troubleshooting with AI?]]></title>
            <link>https://eminalemdar.medium.com/now-what-kubernetes-troubleshooting-with-ai-9c68d26e00ac?source=rss-b3bf23b97abd------2</link>
            <guid isPermaLink="false">https://medium.com/p/9c68d26e00ac</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[troubleshooting]]></category>
            <category><![CDATA[k8s]]></category>
            <category><![CDATA[cloud-native]]></category>
            <dc:creator><![CDATA[Emin ALEMDAR]]></dc:creator>
            <pubDate>Mon, 24 Jun 2024 15:55:18 GMT</pubDate>
            <atom:updated>2024-06-24T15:55:18.611Z</atom:updated>
            <content:encoded><![CDATA[<p>We all know that Kubernetes troubleshooting is difficult and it can get pretty complex from time to time. We can easily get lost in the logs, jumping between pods, searching through events and what have you. Most importantly, finding a meaningful explanation can be an extremely huge problem because not all of the logs are easily understandable. We also have to accept that it is time consuming. Of course we can use an external observability tool or even an observability stack with all of the components but still not all of the outputs are easy to understand and even read. At the end of the day, diagnose times and of course the troubleshooting times are extending drastically as a result.</p><p>But let’s talk about the elephant in the room here. Can AI help us here? Especially for Kubernetes troubleshooting. Because we started using <strong>AI</strong> and mostly <strong>LLMs</strong> everyday not just in our jobs but in our daily activities as well. There are of course some <strong>AIOps</strong> tools out there that help us implement the observability solution with the help of AI but almost all of those tools consume huge amounts of GPU resources and that increases the underlying cost and of course the maintainability issue here.</p><p>So, in this blog post, I want to introduce a <strong>CNCF Sandbox</strong> project to you which is a really powerful tool designed to simplify Kubernetes management using AI and natural language processing. The project is called <strong>K8sGPT</strong> and K8sGPT is a tool for scanning your Kubernetes clusters, diagnosing and triaging issues in simple English. So basically, K8sGPT integrates with various AI backends, including OpenAI, Azure OpenAI, and Amazon Bedrock, to provide clear and actionable insights into your Kubernetes environment and it provides these insights in a user friendly format.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rWs5LOWvxt5df7gW" /></figure><h3>Key Features of K8sGPT</h3><p>Before sharing some examples of K8sGPT usage, I want to share some specific key features of it. Let’s break them down into bullet points.</p><ul><li><strong>Workload Health Analysis</strong></li></ul><p>Of course we should start with this because that is one of the most important reasons this tool is here. K8sGPT scans your Kubernetes clusters to identify critical issues affecting your workloads. It transforms complex diagnostic data and logs into simple, understandable suggestions, making it easier to maintain cluster health. Yes, K8sGPT also provides suggestions for the problems it detects in the cluster.</p><ul><li><strong>AI-Powered Diagnostics</strong></li></ul><p>This one is obvious. K8sGPT leverages AI and LLMs. K8sGPT provides detailed explanations of detected issues in plain English. This feature is powered by integrations with leading AI platforms like OpenAI. Basically, by using these AI platforms, K8sGPT transforms the diagnostic data into a very human friendly format.</p><ul><li><strong>Built-in and Custom Analysers</strong></li></ul><p>K8sGPT includes several built-in analyzers for various Kubernetes resources, such as Pods, Services, and Nodes. But of course with additional integrations, you can also create custom analysers to meet specific needs. K8sGPT has integrations with AWS, Prometheus, KEDA and Trivy. With these native integrations, you can have more detailed analysis. Of course I believe this list is going to be extended and more integrations will be added here in the future.</p><ul><li><strong>Continuous Monitoring and Integration</strong></li></ul><p>You can also deploy K8sGPT as a Kubernetes Operator within a Kubernetes cluster. K8sGPT can continuously monitor the environment and integrate seamlessly with existing tools like Prometheus and Alertmanager in the cluster. You can see the components that the K8sGPT Operator instals and manages from the diagram below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*loluayfTjzR3OyVv" /></figure><ul><li><strong>Security CVE Review</strong></li></ul><p>With the Trivy integration, K8sGPT helps in identifying and addressing security vulnerabilities within your Kubernetes clusters. Once you activate the Trivy integration, Trivy Kubernetes Operator will be installed into the Kubernetes cluster and make it possible for K8sGPT to interact with the results of the Operator.</p><p>I also want to specifically talk about the <strong>AWS</strong> integration here. I’m pretty sure you’re already familiar with the <strong>AWS Controllers for Kubernetes (ACK)</strong> project but if not, I also have a blog post about that and you can check that out from <a href="https://medium.com/@eminalemdar/manage-your-aws-resources-from-kubernetes-with-ack-3cf06a4b0770">here</a>. In short, ACK allows you to manage AWS services from your Kubernetes clusters with CRDs. This integration also helps K8sGPT to interact with the AWS resources managed by ACK. As a result, you can use K8sGPT to analyse and manage not only your Kubernetes resources but also your AWS resources that are under the management of ACK.</p><h3>Let’s play with K8sGPT</h3><p>Installation of K8sGPT CLI is extremely easy and you can use popular packet managers like Brew to install it on your machine. After the installation, you will need to authenticate with your chosen AI provider. I’m using OpenAI here with GPT4 but you can of course choose the appropriate one for you:</p><pre>k8sgpt auth list<br>Default:<br>&gt; openai<br>Active:<br>&gt; openai<br>Unused:<br>&gt; localai<br>&gt; azureopenai<br>&gt; cohere<br>&gt; amazonbedrock<br>&gt; amazonsagemaker<br>&gt; google<br>&gt; noopai<br>&gt; huggingface<br>&gt; googlevertexai<br>&gt; oci</pre><p>You can use k8sgpt auth add command to add the provider backend authentication.</p><p>After this step, it’s pretty straightforward actually. Let’s start the first analysis with the k8sgpt analyse command. But before running the command let me just deploy a broken Pod to see the actual diagnosis part.</p><pre>kubectl apply -f - &lt;&lt;EOF<br>apiVersion: v1<br>kind: Pod<br>metadata:<br>name: broken-pod<br>namespace: default<br>spec:<br>containers:<br>- name: broken-pod<br>image: nginx:1.a.b.c<br>livenessProbe:<br>httpGet:<br>path: /<br>port: 81<br>initialDelaySeconds: 3<br>periodSeconds: 3<br>EOF</pre><p>As you can see the image part of this Pod definition is wrong. So let me run the k8sgpt analyse command and see the output.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/997/0*mSTa1ykjgzbeBas2" /></figure><p>We can see the error but not in detail but there is a flag for us to use here. If we add the k8sgpt analyse --explain flag here, K8sGPT will connect to the AI provider and LLM here.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xAdRU8htHZ3VxrtY" /></figure><p>So now we have some more details about the issue and also some recommendations as well. I know this is a very basic example but let’s extend this. I will now enable two integrations, AWS and Trivy. If we look at the filters we can use now, we see the added filters coming from the integrations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/390/0*s-zY2Cb0irELZNms" /></figure><p>Let’s start with the EKS filter and see if there’s anything wrong with that.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/466/0*uwSRiMmwhveF5-k5" /></figure><p>Brilliant! No problems here but let’s see the results of the Vulnerability Report from Trivy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/909/0*5tX1K5Wi2SOZNAv2" /></figure><p>Wow! That’s a lot! Let’s dive in to understand some of these issues.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*smPQrxM4w4VOtjP0" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*YtfG2_J9R1f4oWMk" /></figure><p>As you can see from the screenshots, We have very detailed information about each issue and again some really good recommendations on how to solve the problems.</p><p>Let me also deploy some other resources to the cluster and see the information about those.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5rbT8-9aQ-bXGYcz" /></figure><p>As you can see from the broken resources, I now have a very good understanding of what is really happening in my cluster here.</p><p>Some final words here. Of course we all have some questions around security of these AI backends but there is also another option here called anonymise which basically anonymise the data before sending it to the AI backend.</p><h3>Conclusion</h3><p>In the future K8sGPT might turn into one of the tools that’s going to transform Kubernetes management, problem diagnosis and of course troubleshooting by making it more accessible and efficient. Whether you’re an SRE, DevOps Engineer or Platform Engineer, K8sGPT can help you reduce troubleshooting times. It is extremely easy to get started with K8sGPT, you can just install it on your Kubernetes environment or on your local machine, authenticate with your chosen AI backend, and connect it to your cluster. In my opinion, you should definitely give K8sGPT a try.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9c68d26e00ac" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Network Policies with VPC CNI on Amazon EKS]]></title>
            <link>https://eminalemdar.medium.com/network-policies-with-vpc-cni-on-amazon-eks-c6993d6ae596?source=rss-b3bf23b97abd------2</link>
            <guid isPermaLink="false">https://medium.com/p/c6993d6ae596</guid>
            <category><![CDATA[ek]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[network-policies]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[cloud-native]]></category>
            <dc:creator><![CDATA[Emin ALEMDAR]]></dc:creator>
            <pubDate>Wed, 20 Sep 2023 09:40:02 GMT</pubDate>
            <atom:updated>2023-09-20T09:40:02.186Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>By default, all Pod communications in Kubernetes are allowed without any restriction.</strong> But if you want to control the network traffic between Pods on IP address and port level you can use <strong>Kubernetes Network Policies</strong>. With Network Policies, you can enforce rule sets to have control over the flow. Network Policies first introduced to the upstream Kubernetes in 2016 as an alpha feature but of course now it’s stable and widely used across the industry. Network Policies act like a firewall and it allows you to create rules for both ingress and egress network traffic.</p><p>But of course there is one prerequisite for using Network Policies within Kubernetes. Network Policies are implemented by network plugins aka CNI plugins. You must have a CNI plugin that supports Network Policies installed on your Kubernetes cluster. You can choose plugins like <a href="https://cilium.io/">Cilium</a>, <a href="https://www.tigera.io/project-calico/">Calico</a>, <a href="https://www.weave.works/">Weave</a>. When Network Policies first introduced the most used implementation option was using <strong><em>iptables</em></strong>. But iptables implementation has some limitations especially when using big scale Kubernetes clusters. Some of these CNI Plugins use <a href="https://ebpf.io/"><strong>eBPF</strong></a>. eBPF offers a more efficient way for packet filtering and it really improves the performance dramatically compared to iptables.</p><p>When using Amazon EKS, the users have the option to choose which CNI Plugin they want to use. AWS also has its own open source CNI Plugin called <a href="https://github.com/aws/amazon-vpc-cni-k8s">VPC CNI</a> and it’s a really good option because of the integration between AWS services and the networking configuration options. But there was one problem with VPC CNI. It didn’t support Network Policies natively. Users would need to install additional tools to be able to control the network traffic in their clusters. This situation of course brings additional operational burdens.</p><p>In August, AWS announced the native support for Network Policies to VPC CNI. That means users now don’t have to install third party applications to use native Network Policies. VPC CNI also uses eBPF. Amazon EKS now introduce three new components to the clusters to be able to support Network Policies:</p><ul><li>Network Policy Controller</li><li>Node Agents</li><li>eBPF SDK</li></ul><h3>How it Works</h3><p>In order to use Network Policies with VPC CNI on Amazon EKS, you need to have a cluster using <strong>Kubernetes v1.25</strong> version or later and also you need to have <strong>VPC CNI version 1.14.0</strong> or later and also you need to use an EKS optimised AMI with the <strong>Kernel version 5.10</strong> or later. If you are using a Kernel version below 5.10 you can check out the EKS documentation to follow the instructions to mount the eBPF file system. This feature is also disabled by default and you need to enable it by changing the VPC CNI configuration parameters.</p><p>Network Policies also can be used with both IPv4 and IPv6 EKS cluster configurations.</p><h3>Demo Time!</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*b4VYIo-M5TFjgnqG" /></figure><p>For this demo, I’ve created an example <a href="https://github.com/eminalemdar/vpc-cni-network-policies">GitHub repository</a> with example Terraform code to create an EKS cluster and I’ve also created a bash script to enable Network Policies on VPC CNI.</p><p>There are also sample Kubernetes manifests in this repository to deploy a sample application. You can see the application layout in the diagram above but to put it in words, I can say these manifests creates these resources in the cluster:</p><ul><li>A Kubernetes namespace with the name “another-ns”</li><li>A Demo application in the default namespace</li><li>Two clients in the default namespace</li><li>Two clients in the another-ns namespace</li></ul><p>I’ve also added some example Network Policy definition manifests in the repository to test the functionality.</p><p>After creating the EKS cluster, I will run this command to be able to authenticate with the cluster. aws eks --region eu-west-1 update-kubeconfig --name eks-cluster-vpc-cni. Don’t forget to update the region name and cluster name according to your environment.</p><p>The configuration I have, install the VPC CNI version 1.14.1.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/814/0*9BMWCoKKcnvVVOeE" /></figure><p>I will run the vpc_cni.sh script to enable Network Policies and configure the required IAM Roles for Service Account for the VPC CNI Plugin.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/914/0*f1AG5lInKuAqrFph" /></figure><p>You can see the Network Policy is now enabled on VPC CNI from the AWS Management Console.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*w0J64xCGVsn_xOkt" /></figure><p>You can also run this command to confirm if the Node Agent is running in VPC CNI:</p><p>kubectl get ds -n kube-system aws-node -o jsonpath=&#39;{.spec.template.spec.containers[*].name}{&quot;\n&quot;}&#39;</p><p>Let’s install the application resources with kubectl apply -f example-manifests/</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/604/0*iYSxdJz5SpR55TQz" /></figure><p>You can check out the connectivity between these components with these commands and you should see the expected output in the screenshot below:</p><p>kubectl exec -it client-one -- curl --max-time 3 demo-app</p><p>kubectl exec -it another-client-one -n another-ns -- curl --max-time 3 demo-app.default</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/856/0*rAAyc3jOZNLuExUP" /></figure><p>Let’s apply some policies to this application stack. First let me create the deny all policy.</p><pre>kind: NetworkPolicy<br>apiVersion: networking.k8s.io/v1<br>metadata:<br>  name: demo-app-deny-all<br>spec:<br>  podSelector:<br>    matchLabels:<br>      app: demo-app<br>  policyTypes:<br>  - Ingress</pre><p>kubectl apply -f example-manifests/policies/deny-all-ingress.yaml. After creating the policy, let’s check if I can still access the application with the commands above.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/928/0*p1q27a1vwuphcs2n" /></figure><p>As you can see from the screenshot above, Network Policy actually works and denies access from both namespaces.</p><p>You can of course try other example policies I have in the repository to simulate different scenarios for multi namespace application deployments.</p><p>With native support for network policy in Amazon VPC CNI, when using EKS, you can now create policies that isolate sensitive workloads and protect them from unauthorised access. This opportunity to have granular control enables you to implement the principle of least privilege access. This feature was awaited for a long time and it really reduced the operational overhead.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c6993d6ae596" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Policy Management in Kubernetes is Changing]]></title>
            <link>https://eminalemdar.medium.com/policy-management-in-kubernetes-is-changing-9d4808f548a0?source=rss-b3bf23b97abd------2</link>
            <guid isPermaLink="false">https://medium.com/p/9d4808f548a0</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[policy-management]]></category>
            <category><![CDATA[policy]]></category>
            <category><![CDATA[k8s]]></category>
            <category><![CDATA[cloud-native]]></category>
            <dc:creator><![CDATA[Emin ALEMDAR]]></dc:creator>
            <pubDate>Sun, 10 Sep 2023 11:31:14 GMT</pubDate>
            <atom:updated>2023-09-10T11:31:14.205Z</atom:updated>
            <content:encoded><![CDATA[<p>The Kubernetes API Server is one of the core components of the Kubernetes Control Plane. This component exposes the Kubernetes API and acts like a front end for the Control Plane. When a user or a process interacts with Kubernetes, the API Server handles those requests and also API Server validates and configures the Kubernetes API objects such as deployments or namespaces. But of course with the help of the Kubernetes Admission Controllers. So, what is an Admission Controller?</p><p>As explained in the official Kubernetes documentation, an Admissions Controller is a piece of code that intercepts requests to the Kubernetes API server prior to persistence of the object, but after the request is authenticated and authorised. There are two types of Admission Controllers, Mutating and Validating. Some controllers may be both but generally speaking, controllers are either mutating the requests and modify the objects or as the name suggests, validating the requests.</p><p>To understand it more clearly, let me explain how it works in general. Let’s say you have a YAML file with some Kubernetes object definitions such as a deployment or a pod and you want to apply that to your cluster. When you send that request to the API Server, it first checks if you have the necessary permissions to create that object. Then that request is forwarded to the Mutating Admission Controllers. Those controllers may change the definition of that object depending on your configurations in the cluster. After that, if the definition schema is valid, the request is then being forwarded to the Validating Admission Controllers. If everything is correct, the resource is going to be created and the details for the objects are sent to the etcd.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ysfawao2_9xTZYsWr_HztQ.png" /><figcaption>How Admission Controllers Work</figcaption></figure><p>Third party policy engine tools like <a href="https://kyverno.io/">Kyverno</a>, <a href="https://open-policy-agent.github.io/gatekeeper/website/">OPA Gatekeeper</a> and <a href="https://www.datree.io/">Datree</a> use Mutating and Validating Admission Webhooks to manage policies. For example, Kyverno runs as a Dynamic Admission Controller inside the cluster. It receives Mutating and Validating webhook requests from the Kubernetes API Server and it applies matching policies to return results that enforce admission policies or reject requests. OPA Gatekeeper is similar as well. It’s a Validating and Mutating webhook that enforces policies executed by <a href="https://www.openpolicyagent.org/">Open Policy Agent</a>. But these tools have their own formats for defining these policies and there are of course differences between them. For example, OPA uses a language called Rego and it can be difficult for some people to write or even understand policies at first because it’s a different language and there is a learning curve.</p><p>But in Kubernetes 1.26, the first alpha release of <strong>Kubernetes </strong><a href="https://kubernetes.io/docs/reference/access-authn-authz/validating-admission-policy/"><strong>Validating Admission Policies</strong></a> became available. With Kubernetes 1.28, it is now in beta stage. This feature is bringing standardisation for declarative policy management into the Kubernetes API. That means we are able to manage and define policies in a Kubernetes native way. Validating Admission Policies use <a href="https://github.com/google/cel-spec">Common Expression Language</a> (CEL) to define policy rules and it allows us to have parameterised and scoped policies. Building, installing and managing third party webhooks can be quite complicated but this new feature will remove all that requirement for calling a remote webhook and it will allow us to manage policies inside the cluster as a built-in process within the API with the CEL expressions.</p><p>Does that mean it is the end of third party tools? I would say no personally and I believe tools like OPA Gatekeeper and Kyverno will adapt their methods to this new approach. But if they don’t, I think there might be a problem for these tools because most of the users of Kubernetes wouldn’t want to choose to manage a different tool for policy management if that’s already available natively in the Kubernetes API. <em>That is my personal opinion of course.</em></p><h3>Let’s see Kubernetes Validating Admission Policies in action!</h3><p>Before jumping into the demo I should remind you that this feature is not enabled by default in the Kubernetes API and you need to enable the necessary <strong>ValidatingAdmissionPolicy</strong> feature gate. Depending on your Kubernetes version, you also need to enable <strong>admissionregistration.k8s.io/v1alpha1</strong> or <strong>admissionregistration.k8s.io/v1beta1</strong> in the API. In this demo, I’ll be using a Kubernetes cluster with the 1.27 version and I’ll use the ‘v1alpha1’ API version for the Validating Admission Policy resources.</p><p>For the policies, we need two resources. First, the policy that will define the actual rules for a resource and the validation actions and secondly, the binding resource that will bind the actual policy to for example a namespace.</p><p>I will use a simple example policy that will define a rule for deployment objects in the namespace that has a label defined to have a limit for the number of replicas. Let me first create a simple namespace resource.</p><pre>apiVersion: v1<br>kind: Namespace<br>metadata:<br>  labels:<br>    environment: demo<br>  name: demo</pre><p>Nothing special here of course and I will create this namespace using kubectl apply. Let’s define our policy:</p><pre>apiVersion: admissionregistration.k8s.io/v1alpha1<br>kind: ValidatingAdmissionPolicy<br>metadata:<br>  name: &quot;demo-policy&quot;<br>spec:<br>  matchConstraints:<br>    resourceRules:<br>    - apiGroups:   [&quot;apps&quot;]<br>      apiVersions: [&quot;v1&quot;]<br>      operations:  [&quot;CREATE&quot;, &quot;UPDATE&quot;]<br>      resources:   [&quot;deployments&quot;]<br>  validations:<br>    - expression: &quot;object.spec.replicas &lt;= 5&quot;<br>      message: &quot;You can not have more than 5 replicas in the demo namespace for deployments&quot;</pre><p>This policy will check the deployment resources and this will track the create and update actions. And these deployments needs to have 5 or less replicas defined. But I also need a Policy Binding resource:</p><pre>apiVersion: admissionregistration.k8s.io/v1alpha1<br>kind: ValidatingAdmissionPolicyBinding<br>metadata:<br>  name: &quot;demo-binding&quot;<br>spec:<br>  policyName: &quot;demo-policy&quot;<br>  validationActions: [Deny]<br>  matchResources:<br>    namespaceSelector:<br>      matchLabels:<br>        environment: demo</pre><p>As you can see from the binding resource, this policy is going to be enforced to the deployment resources in the namespaces that have a label “environment = demo”. Let’s create these resources with kubectl apply.</p><p>Now it’s time to test our new policy. I’m going to use a simple deployment definition:</p><pre>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name: demo-app<br>  labels:<br>    app: nginx<br>spec:<br>  replicas: 6<br>  selector:<br>    matchLabels:<br>      app: nginx<br>  template:<br>    metadata:<br>      labels:<br>        app: nginx<br>    spec:<br>      containers:<br>      - image: nginx<br>        name: nginx</pre><p>I am not going define a Service or anything specific for this deployment object. Let’s apply this deployment:</p><pre>kubectl apply -f deployment.yaml -n demo</pre><p>I couldn’t create the deployment object as expected. The policy kicked in and here is the error message:</p><pre>The deployments &quot;demo-app&quot; is invalid: : ValidatingAdmissionPolicy<br>&#39;demo-policy&#39; with binding &#39;demo-binding&#39; denied request: <br>You can not create more than 5 replicas in the demo namespace for deployments</pre><p>That’s a success for the purposes of this demo of course. If I change the the spec.replicas to 5, the deployment will be created successfully.</p><p>As you can see from the example demonstration I’ve shown in this blog post, Validating Admission Policies makes it extremely easier to write, enforce and use policies in Kubernetes without the need of a third party tool. This is also really flexible. With the usage of CEL expressions, you can create well defined custom policies for multiple actions and multiple validation rules. You can of course add more validation rules to expand these policies or you can use different validation actions. I truly believe this will become the de facto approach for policy management in Kubernetes.</p><p>This feature is now in beta stage for Kubernetes 1.28, so you can try it out yourselves by enabling the feature gate but I believe when it’s enabled by default or when it’s moved to the stable, this feature will become really handy.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9d4808f548a0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Is Multi Cluster / Multi Cloud Strategy Really a Nightmare?]]></title>
            <link>https://eminalemdar.medium.com/is-multi-cluster-multi-cloud-strategy-really-a-nightmare-e08e3e417b2e?source=rss-b3bf23b97abd------2</link>
            <guid isPermaLink="false">https://medium.com/p/e08e3e417b2e</guid>
            <category><![CDATA[multi-cloud]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[cloud-native]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Emin ALEMDAR]]></dc:creator>
            <pubDate>Fri, 07 Apr 2023 15:15:23 GMT</pubDate>
            <atom:updated>2023-04-07T15:15:23.800Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*y3WlXPfMVb96x_IU" /></figure><p>Cloud computing is the ultimate reality for all of us. With the help of huge Public Cloud Providers like <strong>Amazon Web Services</strong>, <strong>Google Cloud</strong> and <strong>Microsoft Azure</strong>, our workloads, products and applications become available globally in minutes. They all have great features and services and they all have their benefits. Transforming all of our environments and applications to <strong>Cloud Native</strong> architectures is really becoming much easier with these vendors.</p><p>We all love and use <strong>Kubernetes</strong> because the platform really allows us to be flexible between environments in general. We can easily migrate our workloads between cloud providers or between different Kubernetes engines. I believe Kubernetes really changed “<strong>worked on my machine</strong>” to “<strong>works on any Kubernetes</strong>” and it’s really a game changer for all of us. When you have multiple Kubernetes clusters, you can distribute traffic between clusters very easily with native integration of Cloud Native tools and increase your availability, portability, performance and reliability.</p><p>Sometimes, organisations choose one Public Cloud Provider and run all their workloads there but most of the companies started going <strong>Multi Cloud</strong>. But what is Multi Cloud exactly? Multi Cloud is a company’s use of different services from different vendors in a single heterogeneous architecture to improve cloud infrastructure capabilities and cost. Basically, organisations use a service from one provider and use another service from another provider. This could also refer to distribution of services between different Public Cloud Providers to increase availability or for distributing the cost. The Multi Cloud approach also eliminates the dependency to a single cloud provider. When using a Multi Cloud architecture, you can have more flexibility and more performance.</p><p>With all of the benefits, the <strong>Multi Cluster / Multi Cloud</strong> approach comes with problems as well and these problems can be a nightmare for every organisation. This approach might not be the perfect solution for everyone.</p><p>But, what can be done?</p><h3>Things to look out for in Multi Cloud</h3><p>When we talk about multi cluster, multi cloud architectures, we need to consider multiple aspects and look from different perspectives. There are multiple and crucially important challenges with this approach. So, what are these challenges and problems?</p><ul><li>Operational Excellence / Complexity</li><li>Configuration Challenges / Connectivity</li><li>Organisational Challenges</li><li>Cost</li><li>Security Challenges</li><li>Authentication and Authorisation a.k.a. IAM</li><li>Observability</li></ul><p>Even looking at this list can give some people goosebumps. But, let me share details and things to look out for each of them.</p><h3>Operational Excellence / Complexity</h3><p>Every added service or cluster to the stack adds more complexity to the whole architecture. When we add another Public Cloud Provider into the picture, the complexity increases even faster. Operational tasks can take up days of multiple engineers’ time. It’s not easy to implement workloads to a new cloud or adapt the whole environment to a new cloud with new and specific configurations of that new cloud. There are of course different and easier ways to manage cloud environments like using an Infrastructure as Code tool like Terraform and modularise the provisioning part. But it adds repetitive tasks for every cloud provider you add to the equation. This takes so much time and effort. You need to take different operational actions for every cloud provider you decide to use.</p><p>Of course you can implement GitOps methodology or have another automated way to provision all the required resources and infrastructure components. Designing this architecture as automated as possible would decrease human error and also the time to go online.</p><h3>Configuration Challenges / Connectivity</h3><p>There are general best practices for general cloud computing but every cloud provider has different approaches and different configuration options for these best practices. That means you need to apply different configurations or you need to have different approaches for every cloud provider in your environment. This can include setting up a network infrastructure or configuring authentication and authorisation. Having different configurations for each can lead up to serious mistakes.</p><p>Because of this, implementing a centralised solution for connectivity between clusters and clouds and also authentication and authorisation would be an ideal approach to overcome these configuration challenges.</p><h3>Organisational Challenges</h3><p>Managing every cloud provider requires different expertise and different skills. Organisations need multiple engineers, maybe multiple teams to handle this situation and this could lead to creating silos. Not every organisation has the capacity to manage this scenario. This situation reduces the time spent on innovation. Engineers start spending their time on daily operational, manual and repetitive tasks. People aspect of every organisation should also adapt Cloud Native transformation. Changing only the tech stack is not the ultimate answer for every problem. Training teams for every cloud provider you add to the stack or hiring new engineers for new cloud providers could be the main problem in the long term for organisations.</p><p>That’s why planning an onboarding process for a multi-cluster and multi cloud approach and taking one step at a time would be a more possible solution. <strong>I truly believe the mental health of internal team members and also the community within the organisation helps companies thrive</strong>.</p><h3>Cost</h3><p>Pricing on cloud computing relies mostly on a pay-as-you-go model. That means you only pay for what you use and every service has a different pricing model depending on capacity, how long you used the service, inbound and outbound access, etc. When you have a multi-cluster, multi cloud architecture, maybe you need to use the same services in every cloud provider to have redundancy and reduced configuration drift between cloud providers. That multiplies the cost automatically. Not just the increased cost, managing the finance for multiple cloud providers is a huge responsibility. Tiny mistakes can be the end of an organisation.</p><p>That’s why most organisations started using <strong>ephemeral clusters</strong> and <strong>ephemeral environments</strong>. These ephemeral clusters can be for a development environment or a test environment. Once the work is finished removing/destroying the environment will dramatically reduce the cost.</p><p>Also, having a well-defined <strong>autoscaling</strong> methodology will help reduce the cost and also increase the availability of the workloads between clusters and cloud providers. You can choose between multiple autoscaling tools and solutions for both workloads and underlying infrastructure resources. For example, you can implement HPA (Horizontal Pod Autoscaler), Keda, Cluster Autoscaler or autoscaling services from cloud providers.</p><h3>Security Challenges</h3><p>Creating a secure environment is really the ultimate goal. Every cloud provider features different services for different aspects of security. This includes network security, data security, compliance, audit, vulnerability management and supply chain security. Even configuring connections between cloud providers for every service required can easily become a nightmare. Multi cloud approach can easily increase the attack surface if not taken care of carefully.</p><p>That’s why centralising most parts of security is the ideal solution. Separating some layers from the underlying infrastructure could ease the management and also gives more control over the environments.</p><h3>Authentication and Authorisation a.k.a. IAM</h3><p>User management in a single environment is difficult enough. Least privilege access method is crucially important for managing every environment. Creating roles, policies and identity management rules within the organisation should be the first priority because implementing this afterwards can lead up to bigger problems. It gets more difficult when new cloud providers are added to the equation. Also, you need to have an audit mechanism for monitoring user actions to have control over your whole environment.</p><p>The shortest solution for this is restricting access whenever not needed.</p><h3>Observability</h3><p>For every metric, log and trace data, you need to have a centralised observability approach to be able to monitor the environment. Also, there should be a centralised alert management mechanism to get into the action when there is a problem in the system. There can be even a preventive solution or automated solution for some of the actions. But configuring this system for multiple cloud providers can be tricky. That’s why when choosing a solution for observability, you should carefully investigate integrations before implementation. If you decide to use the cloud providers’ own services you may not be able to collect all the required data in a central location. That’s why a centralised solution would be the best option.</p><h3>Final Thoughts</h3><p>When designing an architecture we all know there are many aspects of the architecture we need to keep in mind. <strong>That’s why the design phase for a project should be the most important phase</strong>. Because, dealing with problems after implementing a huge architecture couldn’t be possible or can be extremely difficult to overcome. Looking at the design from different perspectives and approaching the problems with pre-defined principles can really help every organisation.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e08e3e417b2e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Reversing the Workflow with External Secrets Operator’s Push Secret Feature]]></title>
            <link>https://eminalemdar.medium.com/reversing-the-workflow-with-external-secrets-operators-push-secret-feature-f2a64f3db748?source=rss-b3bf23b97abd------2</link>
            <guid isPermaLink="false">https://medium.com/p/f2a64f3db748</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[cloud-native]]></category>
            <dc:creator><![CDATA[Emin ALEMDAR]]></dc:creator>
            <pubDate>Wed, 11 Jan 2023 14:43:24 GMT</pubDate>
            <atom:updated>2023-01-11T15:07:17.495Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>External Secrets Operator (ESO)</strong> is a great tool to manage secrets centrally across different providers from Kubernetes clusters. ESO is extremely easy to use and it removes the complexity from secret management. As I explained in my previous blog posts you can install, configure and integrate ESO with different Secret Management Providers by using plain Kubernetes yaml files.</p><p>You can read my previous blog posts about ESO from these links to understand the nature of the project more clearly:</p><ul><li><a href="https://medium.com/@eminalemdar/cloud-native-secret-management-with-external-secrets-operator-2912f41f9c49">Cloud Native Secret Management with External Secrets Operator</a></li><li><a href="https://medium.com/@eminalemdar/external-secrets-operator-integration-with-hashicorp-vault-aff3f956237b">External Secrets Operator Integration with HashiCorp Vault</a></li></ul><p>Up until the 0.7.0 release, ESO only allowed fetching secret data from external secret management providers. But within that release <strong>Push Secret</strong> feature is published. You can now push Kubernetes secrets to third party secret management providers with this feature. This allows you to reverse the workflow. With Push Secret you can also migrate secrets between providers even more easily.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jEXaUKL9gHtbmkTo" /></figure><p>As you can see in the diagram above, with Push Secret you can also send secrets to multiple secret management providers at the same time. As a side note, Push Secret is a namespaced resource. Push Secret resource should be in the same namespace with the Secret Stores.</p><p>You can still use the same method to authenticate with an external secret management provider which is creating a SecretStore resource. You can then create a Push Secret resource and reference the Kubernetes secret and SecretStore to push that data.</p><h3>Demo</h3><p>In this demo I will pull a secret from the <strong>AWS SSM Parameter Store</strong> with ESO. ESO will create a Kubernetes secret object from the new External Secret resource. Finally, I will use the Push Secret feature to push that newly created Kubernetes secret to <strong>AWS Secrets Manager</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3bBalRBySUMzqLWE" /></figure><p>I will start with creating a Secret Store for Parameter Store from this example Yaml file.</p><pre>apiVersion: external-secrets.io/v1beta1<br>kind: SecretStore<br>metadata:<br> name: aws-parameter-store<br>spec:<br> provider:<br>   aws:<br>     service: ParameterStore<br>     region: eu-west-1<br>     auth:<br>       secretRef:<br>         accessKeyIDSecretRef:<br>           name: awssm-secret<br>           key: access-key<br>         secretAccessKeySecretRef:<br>           name: awssm-secret<br>           key: secret-access-key</pre><p>As you can see I’ve used a Kubernetes secret with AWS Access Key and Secret Access Key information to authenticate with my AWS Account for this demonstration. I don’t recommend this approach in production environments. You can use <strong>IAM Roles for Service Accounts (IRSA)</strong> to authenticate with AWS. Also, you can change any information according to your configurations when following along.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/950/0*7fRCRnpbOfPOFan0" /></figure><p>After creating the Secret Store, I’ve created a secret on AWS SSM Parameter Store.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*mYrK01JmegqdnOfq" /></figure><p>As you can see there is a simple JSON object with one key value pair. It’s time for me to create an External Secret object to fetch that secret data into a Kubernetes secret. I’ve used this External Secret Yaml file to do that.</p><pre>apiVersion: external-secrets.io/v1beta1<br>kind: ExternalSecret<br>metadata:<br> name: eso-push-secret<br>spec:<br> secretStoreRef:<br>   name: aws-parameter-store<br>   kind: SecretStore<br> target:<br>   name: eso-push-secret<br> data:<br> - secretKey: password<br>   remoteRef:<br>     key: eso-push-secret<br>     property: secret.password</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*M3E19Yo52p-hoH-D" /></figure><p>The secret is synced. Let’s see if the data is correctly fetched.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*mwcMoz0V4ysosENP" /></figure><p>Perfect! I’ve used a tiny tool called <strong><em>cowsay</em></strong> for fun. Data is correct and that means I can move on to creating the Secret Store for AWS Secrets Manager and the Push Secret resource.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/0*DKGRyzejBpatgstB" /></figure><p>I’ve used this example Yaml file to create the Push Secret resource.</p><pre>apiVersion: external-secrets.io/v1alpha1<br>kind: PushSecret<br>metadata:<br> name: push-secret<br> namespace: default<br>spec:<br> refreshInterval: 10s<br> secretStoreRefs:<br>   - name: aws-secrets-manager<br>     kind: SecretStore<br> selector:<br>   secret:<br>     name: eso-push-secret<br> data:<br>   - match:<br>       secretKey: password<br>       remoteRef:<br>         remoteKey: eso-push-secret</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/766/0*Q3FAweHEtwz3I5zV" /></figure><p>After creating the Push Secret object as you can see it’s status is synced. Let’s check the AWS side.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1xog37gGERzqK-lS" /></figure><p>I can see the newly created secret on my AWS Management Console.</p><p>Also, ESO adds a tag to the pushed secrets. You can see which secrets came from ESO by looking up for the tag “managed-by”. If the secret already exists at the provider, ESO will only update it if the secret has that tag. That means you can stop reconciliation by removing the tag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jJTrx5n61r9y-i4zlwBT0w.png" /></figure><p>Let me check if the data is correctly pushed to AWS Secrets Manager. I’ve used AWS CLI to get the secret value.</p><pre>aws secretsmanager get-secret-value — secret-id eso-push-secret — region=eu-west-1</pre><p>You can change the secret name and region if you are using different configurations. This command gave me an output like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XxuQE9Fh55KjSomc" /></figure><p>The actual secret data is the SecretBinary and it’s base64 encoded. Let me decode that value and see if the secret is pushed correctly to AWS Secrets Manager.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/822/0*TYMY81SiC1sf9lW7" /></figure><p>As you can see, with ESO, I’ve fetched the secret from AWS SSM Parameter Store and pushed that secret data to AWS Secrets Manager.</p><p>With this new Push Secret feature ESO makes it easier to manage secrets centrally from your Kubernetes cluster and across Secret Management providers. As I’ve mentioned in my previous blog posts, you can always contribute to ESO with issues and PRs. You can also check out the <a href="https://github.com/external-secrets/external-secrets">GitHub Repository</a> and the <a href="https://external-secrets.io/">website</a> for learn more about ESO.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f2a64f3db748" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[External Secrets Operator Integration with HashiCorp Vault]]></title>
            <link>https://eminalemdar.medium.com/external-secrets-operator-integration-with-hashicorp-vault-aff3f956237b?source=rss-b3bf23b97abd------2</link>
            <guid isPermaLink="false">https://medium.com/p/aff3f956237b</guid>
            <category><![CDATA[secrets]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[external-secrets-operator]]></category>
            <category><![CDATA[vault]]></category>
            <category><![CDATA[cloud-native]]></category>
            <dc:creator><![CDATA[Emin ALEMDAR]]></dc:creator>
            <pubDate>Wed, 05 Oct 2022 13:49:13 GMT</pubDate>
            <atom:updated>2022-10-05T13:49:13.559Z</atom:updated>
            <content:encoded><![CDATA[<p>In my <a href="https://eminalemdar.medium.com/cloud-native-secret-management-with-external-secrets-operator-2912f41f9c49">last blog post</a>, I’ve explained what <strong>External Secrets Operator (ESO)</strong> is and how it works. External Secrets Operator is an Open Source Kubernetes Operator that integrates external Secret Management Systems like <strong>AWS Secrets Manager</strong>, <strong>HashiCorp Vault</strong>, <strong>Google Secrets Manager</strong>, etc. and it is designed to synchronize secrets from external APIs to Kubernetes. In the last blog post, I’ve shared how to integrate ESO with AWS Secrets Manager. This time, I will explain the integration between ESO and HashiCorp Vault.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RwjcADVexKSDYg4Q" /></figure><p>Before getting started, I want to mention again ESO’s acceptance to the <strong>CNCF</strong> as a <strong>Sandbox</strong> project. This is a huge accomplishment for ESO and also the community around the project getting larger and larger everyday. If you also want to contribute to the ESO project you can check out <a href="https://github.com/external-secrets/external-secrets/#contributing">this part</a> in the official External Secrets <a href="https://github.com/external-secrets/external-secrets">GitHub repository</a>. You can also reach out to the maintainers from social media accounts like <a href="https://twitter.com/ExtSecretsOptr">Twitter</a> and there is a Slack channel <strong>#external-secrets</strong> in the official <strong>Kubernetes</strong> Slack Workspace.</p><h3>In Action!</h3><p>In this demonstration, I will use a Vault installation on a Kubernetes cluster with the official Helm chart and show the authentication with Kubernetes auth method. ESO allows several authentication methods and if you already have a Vault installation in place you can configure the authentication accordingly. I will also use a local cluster with <strong>minikube </strong>for all the installation but you need to have these in your environment:</p><ul><li>Helm v3</li><li>Kubectl</li><li>A Kubernetes Cluster</li><li>Vault CLI</li></ul><p>I have already deployed ESO and Vault with the official Helm charts to my Kubernetes Cluster. If you haven’t done so already, you can follow the documentation for <a href="https://external-secrets.io/v0.6.0-rc1/guides/getting-started/#installing-with-helm">ESO</a> and <a href="https://www.vaultproject.io/docs/platform/k8s/helm">Vault</a> for the installation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*d7zd4VZah4wD2v0_" /></figure><p>You can use <a href="https://learn.hashicorp.com/tutorials/vault/kubernetes-minikube-raft?in=vault/kubernetes">this Tutorial</a> from <strong>HashiCorp Learn</strong> to install, initialize and authenticate with Vault.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RqVUux6Fz9X25nt7" /></figure><p>It’s time to create the secure authentication and authorization between HashiCorp Vault and ESO. I will first create a read policy for all the paths in the Vault. This is of course not the best practices you should follow in your production environment. You can create your own policies accordingly.</p><pre>vault policy write eso -&lt;&lt;EOF<br>path &quot;*&quot;<br>{  capabilities = [&quot;read&quot;]<br>}<br>EOF</pre><p>I will now enable the Kubernetes Authentication method for Vault.</p><pre>vault auth enable kubernetes</pre><p>I will create some environment variables for completing the authentication configuration.</p><pre>kubernetes_host=&quot;$(kubectl exec vault-0 -n vault — printenv | grep KUBERNETES_PORT_443_TCP_ADDR | cut -f 2- -d &quot;=&quot; | tr -d &quot; &quot;)&quot;</pre><pre><br>kubernetes_port=&quot;443&quot;</pre><pre><br>kubernetes_cert=&quot;$(kubectl config view — raw — minify — flatten -o jsonpath=&#39;{.clusters[].cluster.certificate-authority-data}&#39; | base64 — decode)&quot;</pre><p>There is a service account created in the Vault Kubernetes namespace with the name vault and there is also a secret attached to that service account. I will create another environment variable with the token data inside this secret. <strong>You should change the secret name according to your environment.</strong></p><pre>account_token=&quot;$(kubectl get secret -n vault <strong>vault-token-5lwdt</strong> -o jsonpath=&#39;{.data.token} {&quot;\n&quot;}&#39; | base64 — decode)&quot;</pre><p>It’s time to configure the Kubernetes authentication method in Vault.</p><pre>vault write auth/kubernetes/config token_reviewer_jwt=&quot;${account_token}&quot; kubernetes_host=&quot;https://${kubernetes_host}:${kubernetes_port}&quot; kubernetes_ca_cert=&quot;${kubernetes_cert}&quot; disable_issuer_verification=true</pre><p>Next I will create a Vault role to access the secrets. Just like the previous environment variable I fetched the secret name for the external secrets service account and again <strong>you should change the secret name according to your environment</strong>.</p><pre>demo_token=&quot;$(kubectl get secret -n external-secrets <strong>external-secrets-token-wz2fp</strong> -o jsonpath=&#39;{.data.token} {&quot;\n&quot;}&#39; | base64 — decode)&quot;</pre><pre>vault write auth/kubernetes/role/eso-role bound_service_account_names=external-secrets bound_service_account_namespaces=external-secrets policies=eso ttl=24h</pre><pre>vault write auth/kubernetes/login role=eso-role jwt=$demo_token iss=<a href="https://kubernetes.default.svc.cluster.local/">https://kubernetes.default.svc.cluster.local</a></pre><p>After creating the Kubernetes Authentication method and configuring the required permissions, policies and roles, I can now move on to secret creation and synchronization.</p><p>ESO currently only supports KV Secrets Engine in HashiCorp Vault. I will now configure the KV Secrets Engine and create a secret.</p><pre>vault secrets enable -version=2 kv</pre><pre>vault kv put kv/secret password=extremely-secure-password</pre><p>Now, let’s configure External Secrets Operator to fetch the secrets from Vault. I will create the Secret Store first.</p><pre>cat &lt;&lt; EOF | kubectl apply -f -<br> apiVersion: external-secrets.io/v1alpha1<br> kind: SecretStore<br> metadata:<br>   name: hashicorp-vault<br>   spec:<br>     provider:<br>       vault:<br>         server: &quot;http://vault.vault:8200&quot;<br>         path: &quot;kv&quot;<br>         version: &quot;v2&quot;<br>         auth:<br>           kubernetes:<br>             mountPath: &quot;kubernetes&quot;<br>             role: &quot;eso-role&quot;<br>EOF</pre><p>Now let’s create the External Secret object.</p><pre>cat &lt;&lt;EOF | kubectl apply -f -<br> apiVersion: external-secrets.io/v1alpha1<br> kind: ExternalSecret<br> metadata:<br>   name: vault-secret<br> spec:<br>   secretStoreRef:<br>     name: hashicorp-vault<br>     kind: SecretStore<br>   target:<br>     name: vault-secret-example<br>   data:<br>   - secretKey: password<br>     remoteRef:<br>       key: secret<br>       property: password<br>EOF</pre><p>After applying these resources, my secret is now created and synced with Vault.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PIDS-9SJpavHRM-Y" /></figure><p>I can now use my newly created Kubernetes secret in my application pods. ESO automatically synced the secret data into a Kubernetes object. You can also add <strong>refreshInterval</strong> parameter to the External Secret definition to be able to keep the secret up to date.</p><h3>Conclusion</h3><p>Managing secret objects in Kubernetes is relatively an easy task. With integration benefits and a rich feature set of ESO, you can improve operational excellence in your environments. External Secrets Operator supports integration with many more secret management providers with easy configuration options. ESO provides secure connection between secret management provider and Kubernetes cluster and automates the secret synchronization operations. ESO’s acceptance to the CNCF as a Sandbox Project is a strong proof of the project’s capabilities.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aff3f956237b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cloud Native Secret Management with External Secrets Operator]]></title>
            <link>https://eminalemdar.medium.com/cloud-native-secret-management-with-external-secrets-operator-2912f41f9c49?source=rss-b3bf23b97abd------2</link>
            <guid isPermaLink="false">https://medium.com/p/2912f41f9c49</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[cloud-native]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[secrets]]></category>
            <category><![CDATA[external-secrets-operator]]></category>
            <dc:creator><![CDATA[Emin ALEMDAR]]></dc:creator>
            <pubDate>Wed, 31 Aug 2022 12:08:12 GMT</pubDate>
            <atom:updated>2022-08-31T12:08:12.078Z</atom:updated>
            <content:encoded><![CDATA[<p>We are always dealing with sensitive data and secrets while managing our infrastructure and application resources. That’s why there are so many secret management tools out there and all of them are great solutions in their area. In the past we might not need these approaches but right now we must show the extra effort for keeping our data safe. Because the amount of secrets we use in our system has gone from one or two to hundreds. When we shift gears to Cloud Native architectures and microservices it started to become more difficult to keep the data safe.</p><p>Almost every application needs secrets. Those secrets can be usernames and passwords, tokens, certificate data, etc. Secret Management tools are the best way to keep those secrets safe. They have great features like encryption at rest, secret lifecycle management, RBAC, policy based management. But the major problems with these tools are the integration part and of course having different approaches for consuming secret data.</p><p>Managing secrets in Kubernetes is relatively an easy task. You can create secrets from the command line, from reading a file or creating a YAML file with the secret definition. Of course, consuming the Kubernetes secrets in pods or applications running inside pods is an easy task as well.</p><p>As you already know, secrets in Kubernetes are stored in etcd with base64 encoding and if you don’t encrypt your etcd those secrets are easily accessible and consumable by third parties. This is one of the key tasks we all should complete for securing our Kubernetes clusters. But when it comes to consuming secrets from external Secret Management Providers, there are some other things we should consider. For example, there can be secret sprawl between providers and implementing the access and other configurations for each provider can become difficult. And of course, if you have Kubernetes clusters in different environments, for example, on top of different cloud providers you would probably need to consume secrets from multiple providers and have different configurations in each cluster for different providers.</p><p>These will lead to some problems. To be more specific, security problems because of the different access methods, roles and permissions and extra operational burdens such as all configuration differences between these providers.</p><h3>Enter External Secrets Operator</h3><p>There were different solutions for consuming secret data from third party providers. With the beauty of open source and the community, <strong>External Secrets Operator (ESO)</strong> was borned with an issue on GitHub.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vRCEtupAb-RXQePE" /></figure><p>External Secrets Operator is an Open Source Kubernetes Operator that integrates external Secret Management Systems like AWS Secrets Manager, HashiCorp Vault, Google Secrets Manager, etc. and the project is initiated by Container Solutions and GoDaddy. It is designed to synchronize secrets from external APIs to Kubernetes.</p><p>The architecture is relatively simple. ESO uses the operator / controller pattern. It extends the Kubernetes API using Custom Resources. You define where your secrets live, access configurations and how to synchronize those secrets. ESO fetches the secrets from the provider and creates a Kubernetes secret object. And also if the secret changes in the provider, ESO detects this change and updates the secrets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*bckqL3V34epQLjfP" /></figure><p>External Secrets Operator recently accepted into <strong>CNCF</strong> as a <strong>Sandbox</strong> project. This is a huge accomplishment for the project and I believe it’s going to affect the project’s future in a good way. Of course there is always room for more contributors. If you want to use or contribute to the project you can check out the project’s <a href="https://github.com/external-secrets/external-secrets/">GitHub repository</a>.</p><h3>Let’s see ESO in action</h3><p>For this blog post, I will fetch secrets from <strong>AWS Secrets Manager</strong> with External Secrets Operator on an <strong>EKS Cluster</strong>. I will use <a href="https://github.com/aws-ia/terraform-aws-eks-blueprints">Amazon EKS Blueprints for Terraform</a> to create the required resources. I have also created this <a href="https://github.com/eminalemdar/eso-aws-secrets-manager">GitHub Repository</a> for this demonstration.</p><p>The Terraform configurations will create the following resources:</p><ul><li>A VPC</li><li>An EKS Cluster</li><li>A Secret Resource on AWS Secrets Manager</li></ul><p>I also have two Bash scripts in this repository and the installation script does the following:</p><ul><li>Deploying ESO on EKS Cluster</li><li>Configuring required IAM Policy and Role for IRSA</li><li>Creating and configuring Kubernetes Service Account and configuring the permissions</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*EhHKgTiOUGmknao5" /></figure><p>After running the scripts, I have ESO installed on my EKS Cluster and now it’s time to create the Secret Store and External Secret resources. I will create them manually with <em>kubectl</em>.</p><pre>cat &lt;&lt;EOF | kubectl apply -f -<br>apiVersion: external-secrets.io/v1beta1<br>kind: ClusterSecretStore<br>metadata:<br>  name: aws-secrets-manager<br>spec:<br>  provider: <br>    aws:<br>      service: SecretsManager<br>      region: eu-west-1<br>      auth:<br>        jwt:<br>          serviceAccountRef:<br>            name: eso-sa<br>            namespace: external-secrets<br>EOF</pre><p>This command above will create a SecretStore resource on the cluster and it will connect to the AWS Secrets Manager service in the eu-west-1 region.</p><pre>cat &lt;&lt;EOF | kubectl apply -f -<br>apiVersion: external-secrets.io/v1beta1<br>kind: ExternalSecret<br>metadata:<br>  name: eso-demo-secret<br>  namespace: external-secrets<br>spec:<br>  refreshInterval: 1h<br>  secretStoreRef:<br>    name: aws-secrets-manager<br>    kind: ClusterSecretStore<br>  target:<br>    name: eso-created-secret<br>    creationPolicy: Owner<br>  dataFrom:<br>  - extract:<br>      key: eso-secret<br>EOF</pre><p>With the command above I am creating the External Secret resource and this will sync the secret and create a Kubernetes secret in my cluster.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7ENfmpuDX8L3h3WA" /></figure><p>As you can see from the screenshots above, ESO automatically synced the secret from AWS Secrets Manager into a Kubernetes secret object. That means I can use this newly created secret in my pod definitions.</p><h3>Conclusion</h3><p>Secret Management in Cloud Native environments can become a really difficult job in time because of secret sprawl, different secret management provider configurations and integration problems. Managing secrets inside Kubernetes clusters is relatively an easier task. With <strong>External Secrets Operator (ESO)</strong>, you will have the chance to manage your secrets from your Kubernetes clusters centrally without having to implement different approaches for every different secret provider and you will access and synchronize your secrets securely. Also, ESO’s acceptance into the <strong>CNCF</strong> will grow the community around the tool and I believe this is really a solid proof of the ESO’s power.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2912f41f9c49" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Manage Your AWS Resources from Kubernetes with ACK]]></title>
            <link>https://eminalemdar.medium.com/manage-your-aws-resources-from-kubernetes-with-ack-3cf06a4b0770?source=rss-b3bf23b97abd------2</link>
            <guid isPermaLink="false">https://medium.com/p/3cf06a4b0770</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[cloud-native]]></category>
            <category><![CDATA[eng]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Emin ALEMDAR]]></dc:creator>
            <pubDate>Thu, 09 Jun 2022 16:54:43 GMT</pubDate>
            <atom:updated>2022-06-09T16:54:43.577Z</atom:updated>
            <content:encoded><![CDATA[<p>More people are adopting <strong>Kubernetes</strong> in their environments every day and it is already a huge leap in the evolving of the technology. Kubernetes project started as a <strong>Container Orchestration Platform</strong> but now it is much more than that. We run our mission critical and production workloads on Kubernetes, we run our end to end tests on Kubernetes and we use Kubernetes as a development environment. But Kubernetes is evolving too. The project is becoming a <strong>Control Plane</strong> for everything. That means we are using Kubernetes to manage other resources in other environments or other platforms. This includes Public Cloud environments too of course. Because, its API is easily extensible and can integrate with other things. Also, managing Kubernetes resources with YAML files is a lot easier than learning third party tools every day.</p><p>Most of us use AWS services with either one of these options:</p><ul><li>AWS Management Console</li><li>AWS CLI</li><li>IaC (Infrastructure as Code) with tools like Terraform or Cloudformation or Pulumi</li></ul><p>But that means we need to learn these tools or approaches for managing the AWS Resources we have in our environment. That’s not extremely hard and actually I use Terraform on a daily basis. But some people don’t have the time to learn all these new technologies/approaches and already have familiarity with Kubernetes and managing Kubernetes resources with a declarative approach using YAML. Also, using AWS Management Console and AWS CLI makes it harder for everyone to follow the changes in the infrastructure. Having a declarative option is the best approach for everyone.</p><p>The question is how to manage AWS resources from Kubernetes.</p><p><strong>AWS Controllers for Kubernetes (</strong><a href="https://aws-controllers-k8s.github.io/community/"><strong>ACK</strong></a><strong>)</strong> allows you to manage AWS Services directly from your Kubernetes cluster with plain YAML files. ACK is an open source project built by the engineers in AWS and you can find the details about the project from <a href="https://github.com/aws-controllers-k8s">GitHub</a>. You can also contribute to the project and I should mention it is highly encouraged. As you already know, AWS provides a lot of managed services like Databases, Object Stores, Message Queues etc. and we often need these supporting resources for our applications running on Kubernetes clusters. With ACK, you can define and consume these resources from your Kubernetes clusters.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rrtJy_x5OpJMbVNr" /><figcaption>ACK Architecture</figcaption></figure><p>As you can see from the architecture diagram above, a user makes a request to the kube-apiserver to create an S3 Bucket resource. Apiserver writes that request to etcd and makes an API request to AWS for creating that S3 Bucket. These AWS resources are managed in Kubernetes Clusters as Custom Resources(CR). If the user making that request has the permissions for creating this CR then the Bucket is created.</p><p>There are multiple Controllers for different AWS Services and these are called <strong>Service Controllers</strong>. You can find the detailed information for these Service Controllers and their release cycles from the project’s <a href="https://aws-controllers-k8s.github.io/community/docs/community/services/">website</a>. Contributors are working really hard to extend the supported services list in ACK. You can also raise an issue in the project’s GitHub page if you want additional AWS services to be added to ACK.</p><h3>Let’s see the ACK in action!</h3><p>I have created a<strong> </strong><a href="https://github.com/eminalemdar/aws-controllers-for-kubernetes"><strong>GitHub repository</strong></a> for this demonstration. In this repository, you can find Terraform codes for creating an EKS Cluster, scripts for creating Service Controllers and example Kubernetes YAML files for ACK Resources. I will also update this repo constantly to add more examples for ACK Resources.</p><p>I have already created the EKS Cluster and connected to it. For this demonstration I will create an S3 bucket. I run the script with the service name option: <em>./ack_controller_install.sh s3</em></p><p>The script has two functions with different actions.</p><p>First function pulls the required Service Controller Helm Chart from the official AWS ECR Registry and installs it to the cluster.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KbDErv_kZ9k4L25I" /></figure><p>Second function creates the required OIDC Provider for the Kubernetes cluster and creates IAM Roles for Service Account (IRSA) configurations with the required permissions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ABoVsxTNn6jnK4jL" /></figure><p>After running this script, I can now create S3 Bucket resources using the example files in the repository. I use the <em>simple_bucket.yaml</em> file and change the bucket name to test-bucket-ack-resource. I create the resource with the <em>kubectl apply</em> command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LN2KFjU-_UlzEg-l" /></figure><p>Now, I have an S3 Bucket created in my AWS Account. Let’s see the details.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*sJ36HAJDbzsW4gKp" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ID5BdaWn6D5YQyJK" /></figure><p>Great! I can now start using the S3 Bucket.</p><p>I also created a cleanup script in the repository that you can use. The cleanup script uninstalls the Helm Chart for the Service Controller, deletes the CRDs, deletes the OIDC Provider for EKS Cluster and deletes the EKS Cluster itself. You can use the script with adding the service name in the end like <em>./cleanup.sh s3</em>.</p><h3>Conclusion</h3><p>Kubernetes is becoming much more than just a container orchestration tool. With the help of tools like ACK our life is getting easier. Creating and consuming AWS Services from Kubernetes Clusters with ACK is making it extremely easy for everyone to use supporting resources for their application. Supported services for ACK will increase in time for sure but you can definitely check out and start using in your environments.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3cf06a4b0770" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[New Way of HCI — Harvester]]></title>
            <link>https://medium.com/kloia/new-way-of-hci-harvester-a2440002a628?source=rss-b3bf23b97abd------2</link>
            <guid isPermaLink="false">https://medium.com/p/a2440002a628</guid>
            <category><![CDATA[harvesters]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[eng]]></category>
            <category><![CDATA[hci]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Emin ALEMDAR]]></dc:creator>
            <pubDate>Fri, 07 Jan 2022 12:18:35 GMT</pubDate>
            <atom:updated>2022-01-07T12:28:13.389Z</atom:updated>
            <content:encoded><![CDATA[<h3>New Way of HCI — Harvester</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/717/1*1u3_5H_pSkGdvg2tVC9BaA.jpeg" /></figure><p>In this blog post, I’m going to dive into the on-premises world and talk about an innovative solution for managing different workloads and platforms from a single pane.</p><p><strong>HCI (Hyperconverged Infrastructure)</strong> is a software-defined infrastructure solution that virtualizes and combines compute, storage and networking layers together. It allows you to manage your traditional data center components in a single hardware device. Before HCI, you would have to purchase and manage the storage layer separately.</p><p>There are many traditional and proprietary HCI options available from different vendors like VMware, HPE, Nutanix and Dell EMC. These solutions add some new features to their current virtualization platform. Specifically, these solutions use datacenter server hardware with locally attached storage devices and deliver the capacity to the upstream workloads with a software-defined approach. This structure eliminates the need for a separate SAN device and reduces the operational burden of the storage system. While these abstractions are helpful, these traditional solutions do not embody the modern IT approaches in their architecture and their codebases.</p><p>There are two main problems with these solutions. The first problem is the <strong>architecture</strong>. These solutions are meant to manage only virtual machines (VM) and traditional IT components. But we are now using containers and Kubernetes in our environments with all of the other cloud-native technologies for our application workloads. Also, adding a software layer on top of the existing platform is not very innovative. It is like the automobile companies building EV models on the same platform with the company’s old combustion engine model cars. It works but it is not completely modern.</p><p>Second problem with these traditional HCI solutions is <strong>licensing</strong> <strong>options </strong>and <strong>pricing</strong>. These solutions are extremely expensive. You would have to pay for the hardware, virtualization software, HCI software, centralized management software, support subscription separately and then you have to pay extra for some features in these solutions. Furthermore, licensing options are complex with these solutions. For example, some of these solutions are quoted based on both the physical CPU count of the nodes and CPU Core count of the CPUs, separately.</p><p>In 2020, <strong>SUSE</strong> announced a new solution called <a href="https://harvesterhci.io/"><strong>Harvester </strong></a>. In December 2021, they announced the v1.0 GA release of Harvester and it is now production-ready.</p><p>So, what is Harvester? Harvester is an <strong>open source, simple, %100 free-to-use </strong>modern HCI solution built for running VMs and container workloads together. It’s built on open source, cloud native, enterprise-grade technologies such as <strong>Kubernetes</strong>, <strong>KubeVirt</strong> and <strong>Longhorn</strong>.</p><p>You don’t have to have prior knowledge for these technologies with Harvester because it is designed to be easy to understand, operate and benefit from those cloud native technologies. This simplification opens up interesting opportunities with other technologies that can integrate with Kubernetes. With Harvester’s small footprint, you can install and operate your workloads even at the <strong>Edge</strong>.</p><p>You can also use the official <a href="https://registry.terraform.io/providers/harvester/harvester/latest">Terraform Provider </a>for Harvester to manage your Virtual Machine management platform with IaC.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/943/0*VsgEu5ucIkRQ3ErL" /></figure><p>As you can see from the architecture diagram above, Harvester contains three main components. <a href="https://longhorn.io/"><strong>Longhorn </strong></a>, <a href="https://kubevirt.io/"><strong>KubeVirt </strong></a>and <a href="https://github.com/rancher-sandbox/cOS-toolkit"><strong>openSUSE Leap 15.3 </strong></a>OS. <strong>Longhorn</strong> is a lightweight distributed block storage solution for Kubernetes. <strong>KubeVirt </strong>is a VM management toolkit for Kubernetes environments. Finally, <strong>openSUSE Leap </strong>is a Linux distro optimized for running Kubernetes clusters.</p><p>Harvester supports ISO and PXE boot installation methods. You can download and install Harvester on your bare metal servers easily. It also supports nested virtualization, so that you can try Harvester on top of your existing Virtualization platform. The ISO image contains all the necessary packages for air-gapped installations.</p><p>Last but not least, I should mention the Rancher integration. Rancher is an open source Kubernetes multi-cluster management platform. Rancher integration is one of the most exciting features of Harvester. With this integration you can now manage both Virtual Machine workloads and Kubernetes workloads from a single platform. Prior to this integration, you would have to manage different environments individually. Now you can import Harvester Clusters to Rancher’s Virtualization Management page and benefit from Rancher’s Authentication, Authorization and RBAC featureset for multi-tenant environments. Also, you can now deploy RKE and RKE2 Kubernetes Clusters on Harvester Clusters. Built-in Harvester Node Driver support is added to Rancher in v2.6.3. Furthermore, you can get the Load Balancer and persistent storage support automatically with clusters provisioned on Harvester.</p><p>Using these two solutions together will bring a lot of efficiencies with the consolidation of management and operation burden.</p><p>Now let’s move on to the demonstration.</p><p>In this demonstration, I will explain how to install a Harvester Cluster, how to join a node to the cluster, how to configure it and manage resources inside the cluster. Finally, I will integrate the Harvester Cluster with Rancher and show some features of that integration.</p><p>I’ve also created a <a href="https://github.com/eminalemdar/harvester-hci">GitHub repository </a>with example Terraform codes for managing Harvester Resources like VMs, Networks and Images that you can use but I will show you how to operate the environment from the UI with screenshots.</p><p>Let’s start with the installation. I will use the ISO installation method for this and I will setup a three node cluster. Installation is actually pretty simple and straightforward.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fPlFFW4MCn414TWA" /></figure><p>When the first node boots up, you have two options as you can see from the screenshot. I am choosing the first one with the first node.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*CuH9uJZt97yuW-r8" /></figure><p>Then I move on with network configuration, choosing the physical NIC for the management and HostName.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*lldOdCBqML80Vwuj" /></figure><p>After configuring the network, I configure the DNS as well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9ygbyxEOOMZ4ypzK" /></figure><p>After configuring the DNS, I am creating a Cluster token for adding the additional nodes to the cluster.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Yym-XYeAAD4tW-NX" /></figure><p>After reviewing the configuration, I select Yes and the installation starts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*w2jh2SuiVNUPt34c" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*EEyGuylt8piwmjKE" /></figure><p>After completion of the installation, the node’s current status is Ready. I can now login to the UI using the management URL.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*O9LEVGoGC3QhBTYR" /></figure><p>After logging in to the system for the first time, I see this dashboard. The dashboard consists of general information about the Hosts, VMs, Capacity information and Cluster/VM metrics.</p><p>I will start configuring the cluster options starting with the Host Network.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*R_fuuQ8hLMSXbVog" /></figure><p>I will choose the Physical NIC and configure the required sections. Then I move on to adding VM Network configurations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*AqmLPwSpKI6WQ56n" /></figure><p>I have created one VM Network and chosen the Vlan ID of 110, but of course you can change it and add other networks.</p><p>I will now add Images to the cluster. There are two options to choose from: URL and ISO File upload.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VDtRY7Kb62xLznmd" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*z3IjdMkrmUUKxL1_" /></figure><p>After creating the images, Harvester downloads the first image from the Global URL and uploads the local ISO file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*CRbC5cevAiHUJtHt" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*s0gXwhImUo-dUGpT" /></figure><p>Now let’s move on to adding the other nodes to the Cluster. I will add the screenshots of the second node only but I will have a total of three nodes finally.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MitE8nw_UWoqCHl-" /></figure><p>I am choosing the Join option and starting the process by configuring network options.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4509GN6LJ0e4DhhZ" /></figure><p>After network configurations, I am going to configure the cluster details like Management Host and Cluster Token options and after reviewing all the options I will start the installation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*h8R2UbE9n0xJ-NVs" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*mCC2GN7nkG8zz0gu" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*AC4qjP6mymHrZK7l" /></figure><p>After adding the nodes, I can now see the details of them in the UI as well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qHsCEVSRA2f4X_fd" /></figure><p>Now let me create a VM from one of the images I’ve created before.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*SkjmH4LiIzS3ih0I" /></figure><p>As you can see, I’m creating an Ubuntu VM with 2 CPUs and 2 GB of Memory. I will also add some cloud-config parameters to the VM from the Advanced Options section.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*h_FMdHL-qT2VOOwe" /></figure><p>I’ve added some configurations to both User Data and Network Data sections. You can also create templates for these configurations and use them repeatedly.</p><p>After creating the VM it boots up and I can now connect to it. There are two options to connect the VM from the UI. The first one is the VNC Console and the second one is the Serial Console. Also, you can add SSH Key to your VMs to access them from the network but I haven’t configured it in this demonstration.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RFOIbjM8VIIOGNSZ" /></figure><p>As you can see, it took an IP address from the DHCP and the VM is automatically placed on Node 02. Let me connect to the VM and test the internet connection.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jZEF2nivSY8mqZ1n" /></figure><p>It works. Perfect!</p><p>As I’ve mentioned before, Harvester comes with a preinstalled monitoring stack that includes Prometheus and Grafana. There are even preconfigured dashboards in Grafana and you can explore these from both Harvester’s and Grafana’s UI. You can also manage these dashboards and add some custom ones according to your needs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*lnO1IYasBU9k3IXF" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PHqDNGoj4eN4ErQ2" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*tS9460_UxPph9Zqy" /></figure><p>Now it’s time for the Rancher Integration. I have installed a single node Rancher Server for this demonstration. The first step of this integration is importing clusters. In the Rancher UI, there is a section called Virtualization Management that you can import the Harvester Clusters. I am going to import the cluster now.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*j6abz0-UWEBSJiMj" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9kKMSMwWY77KPC69" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*K8YAACgfeOcJAh3s" /></figure><p>After creating the cluster from the Rancher UI, it pops up a Registration URL and shows me the steps I need to take to complete the process. From the Harvester UI, I will add the URL to the required section.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*U710OSQNqDOjhJTa" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JIzgMrkwWgtXqniG" /></figure><p>Now it’s time to create a Kubernetes cluster on the imported Harvester. I will use the built-in Harvester Node Driver to create a Node Template and create the cluster with these templates.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*AIW5sunv8GfFV6Z9" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Ue2V2cmLpr8JP1W9" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OBD3-aselWN1N0Ep" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5kUvDU64Rc9h098G" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZuvWX-midD0Hh-tP" /></figure><p>As you can see, it’s now provisioning the RKE Cluster from scratch on the Harvester Cluster.</p><p>With this integration, managing both VM and Kubernetes environments from a single platform is now possible and very straight-forward.</p><h3>Conclusion</h3><p>We are living in the Modernization Era right now and modernizing our infrastructure is at the core of this transformation. Having a cloud-native HCI solution like Harvester will really help with this. Harvester has huge potential and has benefits like being open source and %100 free. You can stop using the old, proprietary, expensive, traditional HCI solutions and start the innovation at the core of your platform with Harvester.</p><p><em>Originally published at </em><a href="https://www.kloia.com/blog/new-way-of-hci-harvester"><em>https://www.kloia.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a2440002a628" width="1" height="1" alt=""><hr><p><a href="https://medium.com/kloia/new-way-of-hci-harvester-a2440002a628">New Way of HCI — Harvester</a> was originally published in <a href="https://medium.com/kloia">kloia</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Karpenter Cluster Autoscaler]]></title>
            <link>https://medium.com/kloia/karpenter-cluster-autoscaler-76d7f7ec0d0e?source=rss-b3bf23b97abd------2</link>
            <guid isPermaLink="false">https://medium.com/p/76d7f7ec0d0e</guid>
            <category><![CDATA[ek]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[cluster-autoscaler]]></category>
            <category><![CDATA[eng]]></category>
            <dc:creator><![CDATA[Emin ALEMDAR]]></dc:creator>
            <pubDate>Fri, 24 Dec 2021 11:59:33 GMT</pubDate>
            <atom:updated>2021-12-24T12:07:19.932Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-e11cMZ0Le1sIJ7ZuJKjsQ.jpeg" /></figure><p>There are three main options for autoscaling in Kubernetes clusters. <strong>HPA (Horizontal Pod Autoscaling)</strong>, <strong>VPA (Vertical Pod Autoscaling)</strong> and <strong>Cluster Autoscaling</strong>. I will talk about Cluster Autoscaling in this blog post. As you already know, many Kubernetes operators have been using the Official <a href="https://github.com/kubernetes/autoscaler/tree/master/cluster-autoscaler">Cluster Autoscaler </a>for years. Cluster Autoscaler works perfectly for most environments.</p><p>AWS has developed and published an <a href="https://github.com/aws/karpenter">Open Source </a>Cluster Autoscaling tool called <a href="https://karpenter.sh/">Karpenter </a>and released the GA version at <strong>re:Invent 2021</strong>. Right now, <strong>Karpenter only supports AWS</strong> as the underlying Cloud Provider but I believe this will extend in the future with contributions from the community.</p><p>The tool aims to simplify the Autoscaling configurations. With Karpenter, we don’t have to worry about configuring Node Pools beforehand, we don’t have to worry about right-sizing the compute resources beforehand. That improves the application availability and minimizes the operation overhead. Also, this helps with Cost Optimization.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2Vur7aAqRa7l41zR" /></figure><p>Karpenter watches the events in the Kubernetes cluster and resource requests for workloads. After detecting unschedulable pods Karpenter makes the decisions about creating and terminating the nodes. It doesn’t use Node Groups, instead it uses Launch Templates for nodes and you can configure custom Launch Templates for your needs.</p><p>With Karpenter, as operators we only need to configure Provisioner CRDs. We can configure Provider options, Annotations, Taints and most importantly TTL second values for node termination. With the TTL options Karpenter cordons the nodes, drains all the pods and finally safely deletes the node. We can also add multiple provisioners with different configurations to a single cluster and separate our workloads within these provisioners.</p><p>So, the question is how Karpenter differentiates from Cluster Autoscaler. Mostly these two tools are doing the same thing, that is managing nodes in your cluster on your behalf. But there are three main differences between the two. Let me explain those.</p><ul><li>Karpenter allows you to use all the flexibility of the cloud. That means you use all of the EC2 instance types AWS has to offer. Also, you can choose the purchase options like On-Demand and Spot, Availability Zone options.</li><li>Karpenter does not use Node Groups. Karpenter manages each instance directly without configuring any other orchestration mechanism. In Cluster Autoscaler, you need to configure Node Groups for each instance type, purchasing options. That brings operational overhead.</li><li>With Karpenter you don’t need to rely on the kube-scheduler. When Cluster Autoscaler launches a node, it doesn’t bind the pods to those nodes. Kube-scheduler makes that decision. But Karpenter uses a <a href="https://kubernetes.io/docs/concepts/scheduling-eviction/scheduling-framework/#pre-bind">scheduler plugin </a>for these operations. This plugin creates a v1/Binding object and injects the node’s information into the pod without waiting for the node to become ready. By doing that, when a node becomes ready, pod schedules on that node immediately. This approach saves some time off of latency.</li></ul><h3>Let’s See Karpenter in Action!</h3><p>I’ve prepared a <a href="https://github.com/eminalemdar/karpenter">GitHub </a>repository for this demonstration. You can follow the instructions in this blog post and codes from the repository to try Karpenter. In the repo, there are some Terraform codes to deploy an EKS cluster, necessary IAM Roles for Karpenter and of course Karpenter Controller itself. Also, there are some yaml files for example Provisioner and application deployments as well.</p><p>I’ve deployed the EKS cluster and Karpenter controller already.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*q-_K8E4n_pLXJJmW" /></figure><p>I only have one Node Group in the cluster and one Node inside the Node Group. I’ll only use this Node for Karpenter resources.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*C6ACmbClmqYo1xJA" /></figure><p>As you can see from the screenshot, the Karpenter Helm chart creates a Namespace, two Deployments, and some Configmaps. The</p><p>kubectl patch configmap config-logging -n karpenter --patch &#39;{&quot;data&quot;:{&quot;loglevel.controller&quot;:&quot;debug&quot;}}</p><p>command changes the log level to DEBUG.</p><p>Karpenter also creates some Role, RoleBinding, ClusterRole and ClusterRoleBinding resources. After deploying Karpenter, you can inspect those resources too.</p><p>By the way, I’m using an alias for kubectl as k .</p><p>Next, I am going to create Provisioners for different Node Types. Provisioner resources are just CRDs and easily configurable as Kubernetes yaml definition files. You can find the examples in the GitHub repository as well.</p><p>First one is for AMD64 type architecture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Onwj5JqSxq8EWeDp" /></figure><p>As you can see, in the spec.Requirements section I’ve defined three parameters. First one is purchasing options, the second one is for AWS Availability Zones and the final one is for Node Architecture. I’ve also added the Instance Profile to the nodes that Karpenter will create. I haven’t added any instance types for this provisioner but you can add them to the requirements section if you want specific instance types for your workloads. With this configuration, Karpenter will choose the right instance type and size for my application.</p><p>I will create a Deployment for this amd64 Provisioner. I will create the Deployment with 0 replicas and scale it afterward.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zzl-thN7pLb3f3_n" /></figure><p>In the screenshot above, you can see I’ve added a nodeSelector that has the necessary parameter to match the amd64 Provisioner.</p><p>Now, let’s scale the deployment and see what happens.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qFgE6sd2PysPhS46" /></figure><p>It’s time to see the logs of the Karpenter Controller. I use the</p><p>kubectl logs -f -n karpenter $(kubectl get pods -n karpenter -l karpenter=controller -o name)</p><p>command for this. Here is the output.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*liJlLOSQxGeWe5WP" /></figure><p>Let me explain what is happening in this output. First, Karpenter detects there are some unschedulable pods in the cluster and triggers the node provisioning action. It reads some information from AWS like EC2 Instance types with amd64 architecture in the specified region, subnets, and security groups with the tag kubernetes.io/cluster/karpenter-cluster.</p><p>Next, Karpenter excludes some instance types because it detects that my workload will not fit into those instances. It decides to launch 1 instance for 10 pods from the listed instance type options. That means I won’t under-provision or over-provision anything in my AWS account. That’s one of the golden rules in Cost Optimization when using Public Cloud Providers and Karpenter does it for me. Then Karpenter creates a Launch Template for the right instance and launches it.</p><p>Finally, Karpenter schedules the pods into the newly launched EC2 instance and starts waiting for unschedulable pods.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JFZO2GEPn53leMU8" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3abpQ5AYvJWsyudG" /></figure><p>As you can see, the node is added to the cluster. It is not in a Node Group and I didn’t have to configure any Node Groups before deploying the application for it. Also, I didn’t have to configure the instance type or anything related to instance configuration. That saves a lot of time.</p><p>Perfect! Now I’m moving on to another Provisioner.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1npxuwz4c2UWd7dP" /></figure><p>This time I’ve created a Provisioner for arm64 architecture. Let me deploy a new application for this provisioner.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*l2qkScSCmtWo6RqZ" /></figure><p>I’m going to scale this application from 0 to 10.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DNryibC-YmXpocij" /></figure><p>Let’s see the logs again.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*aQj0w8-s6t1cTZIX" /></figure><p>Starting from line 3, Karpenter detects the scaling of the application and starts provisioning a node with ARM processor. It again excludes the tiny instance types, creates another Launch Template for this node, launches the instance, and schedules the pods into that node.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*j1cPRFpqqf-k2M58" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*sYKSbkyHPvWNnWi4" /></figure><p>Again, I didn’t have to configure anything prior to deploying the application except creating the Provisioner.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/862/0*5_3wU5RxjbjggUVK" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0e1oWzAae630g-oL" /></figure><p>Like I’ve mentioned before, Karpenter can also provision Spot instances. I’m going to follow the same procedures as before. Create a Provisioner for Spot instances, Deploy an application with the right Node Selector configuration, and scale the deployment from 0 to 5.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dJH2kYWO3IYKKuix" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7WsfqThc8EcNHtdW" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*C74SNBDZkj0S2DJZ" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*saLRtGG8O0e_DHov" /></figure><p>As you can see, Karpenter does its job and launches the Spot instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Vl4sjAS3hm_XG4ft" /></figure><p>You can see the node architecture details and instance type details with this command:</p><p>kubectl get no -L node.kubernetes.io/instance-type,kubernetes.io/arch,karpenter.sh/capacity-type</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*giH1ry4TlOJ6z-ga" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1WODBoXaJhu5oWO2" /></figure><p>When I look at the instance details, I can see that the last created node is actually a Spot instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rtJ_Z3cJoXmYEk1o" /></figure><p>Finally, let me delete the deployments and see how Karpenter handles that. As you’ve already seen, my Provisioner configurations have the ttlSecondsAfterEmpty</p><p>parameter set to 30. With this configuration parameter, Karpenter adds the TTL (Time to Live) to nodes, Drain the nodes, and after TTL period safely removes the nodes. When I run the k get nodes command, I can see the nodes are in Scheduling Disabled status.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*tv1xd65gDsMY4b1r" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*X9dxgt87ozfP6DUl" /></figure><p>The process can be seen from the logs output screenshot above.</p><h3>Conclusion</h3><p>The Karpenter project is in the early stages right now. But if you are running your Kubernetes clusters on AWS and tired of configuring different Node Groups for every workload that needs something different or managing the configuration of Cluster Autoscaler, you can give Karpenter a try. It is simple, efficient and promising.</p><p><em>Originally published at </em><a href="https://www.kloia.com/blog/karpenter-cluster-autoscaler"><em>https://www.kloia.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=76d7f7ec0d0e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/kloia/karpenter-cluster-autoscaler-76d7f7ec0d0e">Karpenter Cluster Autoscaler</a> was originally published in <a href="https://medium.com/kloia">kloia</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>