<?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 Cluster.dev on Medium]]></title>
        <description><![CDATA[Stories by Cluster.dev on Medium]]></description>
        <link>https://medium.com/@cluster.dev?source=rss-e69ec49fc0c0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*93iMVnEQjmBKFbB5KwYG8w.png</url>
            <title>Stories by Cluster.dev on Medium</title>
            <link>https://medium.com/@cluster.dev?source=rss-e69ec49fc0c0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 21:36:02 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@cluster.dev/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[Addressing the challenges of software distribution with cloud installers]]></title>
            <link>https://medium.com/@cluster.dev/addressing-the-challenges-of-software-distribution-with-cloud-installers-6d317d116779?source=rss-e69ec49fc0c0------2</link>
            <guid isPermaLink="false">https://medium.com/p/6d317d116779</guid>
            <dc:creator><![CDATA[Cluster.dev]]></dc:creator>
            <pubDate>Fri, 24 May 2024 09:35:21 GMT</pubDate>
            <atom:updated>2024-05-24T09:35:21.425Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*MIrVTNtpQ9gNoi3LCARCPQ.png" /></figure><p>Software distribution is the process of delivering software to a designated environment.</p><p>Overall, there are three key consumption points where software artifacts need to be promptly and securely delivered to after development:</p><ul><li>Internal repositories: distribution to developers and CI servers across the globe for ongoing development and testing.</li><li>External repositories: for use by the developer ecosystem, partners, and customers, such as drivers, plugins, OSS components, and more.</li><li>Machines: runtime environments and infrastructure endpoints where applications are deployed.</li></ul><p>In this blog post, we’ll focus on the second aspect, specifically addressing the development and delivery of SaaS products to customer-managed environments.</p><h3>What makes SaaS vendors pursue customer installs</h3><p>A <a href="https://www.replicated.com/state-of-the-industry-for-software-distribution-download-the-report">survey conducted by Replicated</a> revealed that installing SaaS software into customer-managed environments remains an in demand option among security-conscious clients. Additionally, it showed to be profitable, with 79% of respondents reporting higher revenue generation from such customers compared to a general SaaS offering.</p><p>Most frequently, companies prioritizing data privacy, network security, and regulatory compliance operate within fintech, healthcare, and government sectors. These enterprise-grade customers can afford to pay premium prices to get these qualities and have the flexibility to run the software wherever they choose, whether in air-gapped environments or on their preferred cloud platforms.</p><p>The consistent demand for such solutions makes it a good business for software companies who are eager to expand their service offerings with customer environment installation options. However, certain difficulties associated with this distribution model may deter vendors from pursuing software development for customer environments. Let’s delve into some of these challenges.</p><h3>Challenges of building software for customer-managed environments</h3><h4>Customer support on the stage of initial installation and upgrade</h4><p>Complex installations with numerous configurations and dependencies are among the main factors that can potentially delay deployment on the customer side. At the same time, vendors are concerned with providing a fast and seamless start for their customers, to ensure convenience for end users while reducing demands on their support teams.</p><h4>Integration to the customer’s environment</h4><p>This could pose significant challenges during the initial installation phase, often due to unforeseen compatibility issues. According to Replicated, compatibility, or lack of it, is the primary reason for vendors being deterred from developing software for customer-managed environments. Additionally, software often requires further customization to align with the customer’s business logic, adding complexity to the adoption process and diverting the vendor’s developer resources to address these issues.</p><h4>Support of several versions and the release lag</h4><p>Replicated’s survey also showed that features for customer-managed environment software typically lag behind their comparable SaaS offerings by an average of 3 weeks. Vendors prioritize upgrades to their main SaaS offering, as it is utilized by the majority of their clients. Furthermore, customers may delay updating to the latest version due to the complexities associated with the upgrade process.</p><h4>Development and testing for different installation options</h4><p>The solution design and its testing for different runtimes (operating systems, containers, virtual machines, bare metal, etc.) remains one of the biggest reported challenges of building software for customer-managed environments.</p><h3>Challenges of distributing software to customer-managed environments</h3><h4>Lack of advanced DevOps skills</h4><p>Once developed, the product has to be delivered to end-users. Software vendors usually distribute their products as installation packages such as binary releases, Docker images, or Helm charts. As for the infrastructure requirements, they are at most described in documentation or provided as a sample of infrastructure code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KNzqOrpmohRCeLc0qdUMgg.png" /><figcaption>Software distribution scenarios</figcaption></figure><p>Matching cloud prerequisites that are required for deploying provided installation packages could appear too complex for customers whose teams lack DevOps skills in AWS, GCP or Azure.</p><h4>Distributing across various tools and cloud platforms</h4><p>Distributing software across a diverse range of tools and cloud platforms, such as different Kubernetes distributions, operating systems, and cloud platforms with their unique services, presents its own challenges. These environments have specific configurations, dependencies, and compatibility requirements necessitating the creation of individual installation protocols for every potential environment combination, which is highly inefficient.</p><h3>How cloud installers can help</h3><p>Cloud installers or installation scripts are designed to facilitate the software deployment and setup in a cloud. Their aim is to reduce the complexity of initial installation, streamlining the user journey in adopting a software.</p><p>Let’s explore how <a href="https://cluster.dev/">Cluster.dev</a>, a technology of infrastructure templating developed by <a href="https://shalb.com/">SHALB</a>, facilitates the development and deployment of SaaS software to customer-managed environments.</p><p>Cluster.dev bundles the software code with a preconfigured template, supplementing the distribution process with all prerequisites required to bootstrap an infrastructure in a customer’s cloud account.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gdmSdS6qTq68FcOdpOG6oQ.png" /><figcaption>The Cluster.dev installer diagram</figcaption></figure><p>By maintaining a shared state between different components, Cluster.dev can define the sequence of their launch within an infrastructure template, enabling the installation of the entire stack with a single button push in the WebUI or a one-shot CLI command.</p><p>Dealing with compatibility issues becomes easier as Cluster.dev allows you to pin component versions within a template’s code base, ensuring harmonious performance of different technologies. The Cluster.dev’s templates are highly customizable, which enables seamless integration with even the most complex customer systems.</p><p>The challenge of testing for different installation options often stems from the difficulty in provisioning customer-specific environments for compatibility testing. As an infrastructure templating engine, Cluster.dev automates the launch of these environments, enabling effective testing of infrastructure changes and checking the interoperability of system components.</p><h3>Conclusion</h3><p>The challenges SaaS vendors face when developing a customer-managed environment version of their software can potentially outweigh the benefits. This creates a market gap, leaving the demands of customers in sectors like government, finance, and healthcare unmet. The use of cloud installers helps fill this gap by facilitating installations in the environments of the customers’ choice.</p><p>The Cluster.dev cloud installer is designed to address the challenges of SaaS companies building software for customer-managed environments. The installer supports installation on any cloud platform or on-premises by employing templating and codifying best practices in deployment and Day 2 operations.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6d317d116779" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ChatGPT clone in 30 minutes on AWS Kubernetes]]></title>
            <link>https://medium.com/@cluster.dev/kubernetes-infrastructure-for-hugging-face-models-and-chat-with-cluster-dev-580050c29db5?source=rss-e69ec49fc0c0------2</link>
            <guid isPermaLink="false">https://medium.com/p/580050c29db5</guid>
            <dc:creator><![CDATA[Cluster.dev]]></dc:creator>
            <pubDate>Thu, 21 Dec 2023 10:24:56 GMT</pubDate>
            <atom:updated>2023-12-21T10:43:06.701Z</atom:updated>
            <content:encoded><![CDATA[<p>In this blog post I will demonstrate how employing <a href="https://cluster.dev/">Cluster.dev</a> can streamline launching one of the Hugging Face LLMs with chat on AWS cloud, on top of a Kubernetes cluster, and make it production-ready.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5yRXsIHnMwvYxlR4JWeUQQ.png" /></figure><h3>Hugging Face TGI and Chat-UI</h3><p>In addition to models, datasets, and Python libraries, Hugging Face also provides Docker containers for local inference, including projects like <a href="https://github.com/huggingface/text-generation-inference/">Text Generation Inference</a> (a Docker container to serve models) and <a href="https://github.com/huggingface/chat-ui/">Chat-UI</a> (a Docker image for interactive chatting with models, akin to ChatGPT’s interface).</p><p>While this is enough for local deployment and testing, deploying it quickly to Kubernetes would take considerable effort and a lot of configuration.</p><p>For that reason, we decided to simplify this process for users who want to deploy LLMs in their cloud accounts without struggling with intricate infrastructure development and management.</p><h3>Kubernetes, Helm, Terraform, and Cluster.dev</h3><p>Data scientists commonly utilize Python for testing, fine-tuning, and serving models. Yet, when it comes to production, DevOps teams need to integrate this into the infrastructure code. Notably, Kubernetes offers around 20% better GPU node costs compared to SageMaker, with more flexible scalability. Terraform is often employed for provisioning production infrastructures, coupled with Helm for deploying software to Kubernetes.</p><p>The Cluster.dev’s open-source framework has been designed specifically for the scenarios where you need to deploy comprehensive infrastructures and software with minimal commands and documentation. Think of it as the Terraform and Helm equivalent of InstallShield (next-&gt;next-&gt;install), enabling the installation of any software on your cloud accounts. Further details are available at <a href="https://docs.cluster.dev/">docs.cluster.dev</a>.</p><h3>Quick Start on EKS</h3><p>While we’ll demonstrate here the workflow using Amazon AWS cloud and managed EKS, it can be adapted for any other cloud provider and Kubernetes version.</p><h4>Prerequisites</h4><ul><li>AWS cloud account credentials.</li><li><a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-resource-limits.html#request-increase">AWS Quota</a> change requested for g5 or other desired types of GPU instances.</li><li><a href="https://docs.cluster.dev/installation-upgrade/">Cluster.dev</a> and <a href="https://developer.hashicorp.com/terraform/install">Terraform</a> installed.</li><li>Select a Hugging Face model with .safetensors weights from Hub. Alternatively, you can upload the model to an S3 bucket; see the example in <a href="https://github.com/shalb/cdev-examples/blob/main/aws/eks-model/bootstrap.ipynb">bootstrap.ipynb</a>.</li><li>Route53 DNS zone (optional).</li></ul><p>Create an S3 Bucket for storing state files:</p><pre>aws s3 mb s3://cdev-states</pre><p>Clone the repository with the example:</p><pre>git clone https://github.com/shalb/cdev-examples/<br>cd cdev-examples/aws/eks-model/cluster.dev/</pre><h4>Edit Configuration files</h4><p>project.yaml — serves as the primary configuration for the project, defining essential global variables like organization, region, state bucket name, and more. It also facilitates the setting of global environment variables.</p><p>backend.yaml — configures the backend for Cluster.dev states, including Terraform states, and relies on variables specified in project.yaml.</p><p>stack-eks.yaml— outlines the AWS infrastructure configuration, including VPC, domains, and EKS (Kubernetes) settings. Detailed information can be found in the <a href="https://docs.cluster.dev/examples-aws-eks/">Stack documentation</a>.</p><p>The most important part here is the configuration of your GPU nodes. Specify their capacity_type (ON_DEMAND, SPOT), instance types, and autoscaling settings (min/max/desired). Additionally, set disk size and node labels if required. The key settings to configure next are:</p><pre>  cluster_name: k8s-model # change this to your cluster name<br>  domain: cluster.dev # if you leave this domain it would be auto-delegated with the zone *.cluster_name.cluster.dev<br>  eks_managed_node_groups:<br>    gpu-nodes:<br>      name: ondemand-gpu-nodes<br>      capacity_type: ON_DEMAND<br>      block_device_mappings:<br>        xvda:<br>          device_name: &quot;/dev/xvda&quot;<br>          ebs:<br>            volume_size: 120<br>            volume_type: &quot;gp3&quot;<br>            delete_on_termination: true<br>      instance_types:<br>        - &quot;g5.xlarge&quot;<br>      labels:<br>        gpu-type: &quot;a10g&quot;<br>      max_size: 1<br>      desired_size: 1<br>      min_size: 0</pre><p>You can create additional node groups by adding similar blocks to this YAML. Refer to the complete list of available settings in the corresponding <a href="https://github.com/terraform-aws-modules/terraform-aws-eks/blob/master/examples/eks_managed_node_group/main.tf#L96">Terraform module</a>.</p><p>stack-model.yaml — describes the HF model Stack, referencing the model stack template in the model-templatefolder and includes the installation of the necessary Nvidia drivers.</p><p>The model stack primarily utilizes values from the <a href="https://github.com/shalb/charts/tree/main/huggingface-model">huggingface-model Helm chart</a>, which we have prepared and continue to develop. Check the default <a href="https://github.com/shalb/charts/blob/main/huggingface-model/values.yaml">values.yaml</a> for a comprehensive list of available chart options. Here are the main configurations you need to adjust:</p><pre>  chart:<br>    model:<br>      organization: &quot;HuggingFaceH4&quot;<br>      name: &quot;zephyr-7b-beta&quot;<br>    init:<br>      s3:<br>        enabled: false # if set to false the model would be cloned directly from HF git space<br>        bucketURL: s3://k8s-model-zephyr/llm/deployment/zephyr-7b-beta  # see ../bootstrap.ipynb on how to upload model<br>    huggingface:<br>      args:<br>        - &quot;--max-total-tokens&quot;<br>        - &quot;4048&quot;<br>        #- --quantize<br>        #- &quot;awq&quot;<br>    replicaCount: 1<br>    persistence:<br>      accessModes:<br>      - ReadWriteOnce<br>      storageClassName: gp2<br>      storage: 100Gi<br>    resources:<br>      requests:<br>        cpu: &quot;2&quot;<br>        memory: &quot;8Gi&quot;<br>      limits:<br>        nvidia.com/gpu: 1<br>    chat:<br>      enabled: true</pre><h4>Deploy Stacks</h4><p>After finishing the setup, you can deploy everything with just one command:</p><pre>cdev apply</pre><p>The list of resources to be created:</p><pre>Plan results:<br>+----------------------------+<br>|      WILL BE DEPLOYED      |<br>+----------------------------+<br>| cluster.route53            |<br>| cluster.vpc                |<br>| cluster.eks                |<br>| cluster.eks-addons         |<br>| cluster.kubeconfig         |<br>| cluster.outputs            |<br>| model.nvidia-device-plugin |<br>| model.model                |<br>| model.outputs              |<br>+----------------------------+</pre><p>The whole process takes around 30 minutes, check this video to get an idea:</p><p><a href="https://asciinema.org/a/622011">Deploy Huggingface model to Kubernetes with Cluster.dev</a></p><h3>Working with Infrastructure</h3><p>Let’s consider some tasks that we can perform on top of this stack.</p><h4>Interacting with Kubernetes</h4><p>The kubeconfig file that you get after deploying the stack will enable you to authorize to the cluster, check workloads, logs, etc:</p><pre># First we need to export KUBECONFIG to use kubectl<br>export KUBECONFIG=`pwd`/kubeconfig<br># Then we can examine workloads deployed in the `default` namespace, since we have defined it in the stack-model.yaml<br>kubectl get pod<br># To get logs from model startup, check if the model is loaded without errors<br>kubectl logs -f &lt;output model pod name from kubectl get pod&gt;<br># To list services (should be model, chat and mongo if chat is enabled)<br>kubectl get svc<br># Then you can port-forward the service to your host<br>kubectl port-forward svc/&lt;model-output from above&gt;  8080:8080<br># Now you can chat with your model<br>curl 127.0.0.1:8080/generate \<br>    -X POST \<br>    -d &#39;{&quot;inputs&quot;:&quot;Continue funny story: John decide to stick finger into outlet&quot;,&quot;parameters&quot;:{&quot;max_new_tokens&quot;:1000}}&#39; \<br>    -H &#39;Content-Type: application/json&#39;</pre><h4>Changing node size and type</h4><p>Consider a scenario where you have a large model and need to serve it with substantial instances, preferably using cost-effective spot instances. To achieve this, you simply need to change the type of the node group:</p><pre>    gpu-nodes:<br>      name: spot-gpu-nodes<br>      capacity_type: SPOT<br>      block_device_mappings:<br>        xvda:<br>          device_name: &quot;/dev/xvda&quot;<br>          ebs:<br>            volume_size: 120<br>            volume_type: &quot;gp3&quot;<br>            delete_on_termination: true<br>      instance_types:<br>        - &quot;g5.12xlarge&quot;<br>      labels:<br>        gpu-type: &quot;a10g&quot;<br>      max_size: 1<br>      desired_size: 1<br>      min_size: 0</pre><p>After making changes, apply them by running cdev apply.</p><p>Keep in mind that spot instances might not always be available in the region. If the spot request cannot be fulfilled, check your AWS Console under EC2 -&gt; Auto Scaling groups -&gt; eks-spot-gpu-nodes -&gt; Activity. If it fails, consider changing to ON_DEMANDor adjust instance_types in the manifest, then rerun cdev apply.</p><h4>Changing the model</h4><p>To change the model, just edit its name and organization. Then apply the changes by running cdev apply:</p><pre>    model:<br>      organization: &quot;WizardLM&quot;<br>      name: &quot;WizardCoder-15B-V1.0&quot;</pre><h4>Enabling Chat-UI</h4><p>To activate Chat-UI, set chart.chat.enable:true. This will provide a service that can be port-forwarded and accessed from the browser. For external access, include ingress configuration, as demonstrated in the sample:</p><pre>    chat:<br>      enabled: true<br>      modelConfig:<br>      extraEnvVars:<br>        - name: PUBLIC_ORIGIN<br>          value: &quot;http://localhost:8080&quot;<br>      ingress:<br>        enabled: true<br>        annotations:<br>          cert-manager.io/cluster-issuer: &quot;letsencrypt-prod&quot;<br>        hosts:<br>          - host: chat.k8s-model.cluster.dev<br>            paths:<br>              - path: /<br>                pathType: Prefix<br>        tls:<br>          - hosts:<br>              - chat.k8s-model.cluster.dev<br>            secretName: huggingface-model-chat</pre><p>If you are using the cluster.dev domain with your project prefix (please make sure that it is unique), the DNS zone will be configured automatically. HTTPS certificates for the domain will also be generated automatically. To monitor the progress, use the command: kubectl describe certificaterequests.cert-manager.io</p><p>If you want to expose the API for your model, configure the Ingress in the corresponding model section.</p><h4>Monitoring and Metrics</h4><p>Instructions for setting up Prometheus and Grafana for monitoring can be found in <a href="https://github.com/shalb/cdev-examples/blob/main/aws/eks-model/bootstrap.ipynb">bootstrap.ipynb</a>. We are planning to release a new stack template with monitoring enabled through a single option.</p><p>In this Loom video you can see the configuration for Grafana:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.loom.com%2Fembed%2F836de3be322a4d51b7baf628d1ed9801&amp;display_name=Loom&amp;url=https%3A%2F%2Fwww.loom.com%2Fshare%2F836de3be322a4d51b7baf628d1ed9801&amp;image=https%3A%2F%2Fcdn.loom.com%2Fsessions%2Fthumbnails%2F836de3be322a4d51b7baf628d1ed9801-00001.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=loom" width="790" height="592" frameborder="0" scrolling="no"><a href="https://medium.com/media/94f4279a120b5cb7d527872eeaae355a/href">https://medium.com/media/94f4279a120b5cb7d527872eeaae355a/href</a></iframe><h3>Questions, Help, and Feature Requests</h3><p>Feel free to start a <a href="https://github.com/shalb/cdev-examples/discussions">discussion</a> in our GitHub repository.</p><h3>Summary</h3><p>There are numerous methods to run HF models. This article describes a scenario of launching an LLM with chat on AWS cloud, using Cluster.dev as an infrastructure installer. We believe it will be particularly useful for well-versed Kubernetes users who want to swiftly deploy their version of a ChatGPT-like model for their organization using the IaC approach.</p><p><em>Thanks!<br></em><a href="http://inkedin.com/in/voatsap/"><em>Volodymyr Tsap</em></a><em>,<br>CTO </em><a href="https://cluster.dev/"><em>Cluster.dev</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=580050c29db5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[K3s cluster deployment in AWS with Cluster.dev]]></title>
            <link>https://medium.com/@cluster.dev/k3s-cluster-deployment-in-aws-with-cluster-dev-718f823bb10c?source=rss-e69ec49fc0c0------2</link>
            <guid isPermaLink="false">https://medium.com/p/718f823bb10c</guid>
            <category><![CDATA[platform-engineering]]></category>
            <category><![CDATA[k3d]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[terraform]]></category>
            <dc:creator><![CDATA[Cluster.dev]]></dc:creator>
            <pubDate>Tue, 31 Oct 2023 11:36:16 GMT</pubDate>
            <atom:updated>2023-10-31T11:36:16.039Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article we would go through the process of creating production ready k3s cluster that could be deployed in single node or in multi-node auto-scaling configuration.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HUgnIFiu3GKo_SF6S2-Ubg.png" /></figure><p>K3s cluster would be also configured with addons:<br><a href="https://github.com/deitch/aws-asg-roller">aws-asg-roller</a> — to manage auto-scaling groups updates.<br><a href="https://github.com/kubernetes-sigs/aws-ebs-csi-driver">aws-ebs-csi-driver</a> — to work with external persistent volumes.<br><a href="https://github.com/rancher/local-path-provisioner">local-path-provisioner</a> — to create volumes on the EC2 instances.<br><a href="https://github.com/kubernetes/ingress-nginx">ingress-nginx</a> — to serve ingress objects instead of default traefic.<br>In case you have a DNS Zone(domain) configured in Route53:<br><a href="https://github.com/kubernetes-sigs/external-dns">external-dns</a> — to manage zones from Ingress objects.<br><a href="https://github.com/cert-manager/cert-manager">cert-manager</a> — to generate LetsEncrypt Certificates.</p><p>All required AWS resources like: VPC(you can define own), Load Balancer, IAM roles and policies, Security Groups and other would be created.</p><h3>What is K3s?</h3><p><a href="https://k3s.io/">k3s</a> is a lightweight, certified Kubernetes distribution designed for resource-constrained environments and edge computing. It was developed by Rancher Labs and is optimized to use less memory and disk space, making it suitable for IoT devices, small clusters, CI/CD systems, and other scenarios where a full-fledged Kubernetes installation might be overkill. k3s packages all the required components into a single binary, removing extraneous modules to reduce its footprint, and comes with a simple installation process.</p><h3>What is Cluster.dev?</h3><p><a href="https://docs.cluster.dev/">Cluster.dev</a> is an advanced cloud-native platform designed to streamline the deployment and management of infrastructure-as-code (IaC) across various cloud providers.<br>Leveraging modern IaC tools like Terraform, Helm, and Kubernetes, Cluster.dev abstracts away the intricacies of cloud configurations, ensuring consistent, reproducible, and scalable deployments.</p><p>Key features include:<br>- <strong>Multi-cloud Support:</strong> Easily deploy resources on AWS, Azure, GCP, and more, without getting bogged down in provider-specific details.<br>- <strong>Kubernetes Integration</strong>: Rapidly bootstrap both managed Kubernetes services like AWS-EKS and lightweight distributions like K3s.<br>- <strong>Module-based Architecture</strong>: Utilize pre-built modules for common tasks such as deploying static websites or setting up monitoring with Prometheus.<br>- <strong>Automation &amp; CI/CD Ready</strong>: Seamlessly integrate with existing CI/CD and GitOps pipelines, enhancing automation and reducing manual intervention.</p><h3>Prerequisites</h3><p>Detailed configuration of prerequisites and cloud account could be found in official <a href="https://docs.cluster.dev/examples-aws-k3s/#prerequisites">documentation</a>.</p><ol><li>Terraform version 1.4+</li><li>AWS account/<a href="https://docs.cluster.dev/examples-aws-k3s/#install-aws-client">AWS CLI</a> installed and configured access.</li><li><a href="https://docs.cluster.dev/examples-aws-k3s/#create-s3-bucket">AWS S3 bucket</a> for storing states.</li><li>kubectl installed.</li><li><a href="https://docs.cluster.dev/installation-upgrade/">Cluster.dev client installed</a>.</li><li>(Optional) DNS zone in AWS account.</li></ol><h3>Project configuration</h3><p>Create locally a project directory, cd into it and execute the command:</p><pre>[~/tmpk3s]$ cdev project create https://github.com/shalb/cdev-aws-k3s                                <br>09:33:22 [INFO] Creating: kuard.yaml     <br>09:33:22 [INFO] Creating: kuard.yaml     <br>09:33:22 [INFO] Creating: backend.yaml   <br>09:33:22 [INFO] Creating: demo-app.yaml  <br>09:33:22 [INFO] Creating: demo-infra.yaml  # Stack describing infrastructure<br>09:33:22 [INFO] Creating: project.yaml   </pre><p>This will create a new project.<br>Edit variables in the example’s files:</p><p><strong><em>project.yaml </em></strong>— main project config. Sets common global variables for current project such as organization, region, state bucket name etc.<br><strong><em>backend.yaml </em></strong>— configures backend for Cluster.dev states (including Terraform states). Uses variables from <strong><em>project.yaml</em></strong>. See <a href="https://docs.cluster.dev/structure-backend/">backend docs</a>.<br><strong><em>demo-infra.yaml</em></strong> — describes k3s stack configuration.<br>Also there would be a <strong><em>sample-application-template </em></strong>and<strong><em> demo-app.yaml</em></strong> files describing and example on deployment of Kubernetes sample application.</p><p>Lets check the sample of <strong><em>demo-infra.yaml</em></strong>:</p><pre>name: k3s-demo<br>template: https://github.com/shalb/cdev-aws-k3s?ref=main<br>kind: Stack<br>backend: aws-backend<br>variables:<br>  cluster_name: cdev-k3s-demo<br>  bucket: {{ .project.variables.state_bucket_name }}<br>  region: {{ .project.variables.region }}<br>  organization: {{ .project.variables.organization }}<br>  domain: {{ .project.variables.domain }}<br>  instance_type: &quot;t3.medium&quot;<br>  k3s_version: &quot;v1.28.2+k3s1&quot;<br>  env: &quot;demo&quot;<br>  public_key: &quot;ssh-rsa 3mnUUoUrclNkr demo&quot; # Change this.<br>  public_key_name: demo<br>  master_node_count: 1<br>  worker_node_groups:<br>    - name: &quot;node_pool&quot;<br>      min_size: 2<br>      max_size: 3<br>      instance_type: &quot;t3.medium&quot;</pre><p>As you can see there we define the location of <a href="https://github.com/shalb/cdev-aws-k3s/blob/main/aws-k3s.yaml">StackTemplate</a> on GitHub with tag or branch pinned. You can also fork the StackTemplate or put it locally and edit it adding any addons you would need in your cluster(like ArgoCD/Flux, etc..)<br>In Stack file you can set the <a href="https://docs.cluster.dev/examples-aws-k3s/#dns-zone">DNS zone domain</a> (if you have one in Route53 account).<br>Set the version of <a href="https://github.com/k3s-io/k3s/releases">k3s release</a>. <br>Don’t forget to change a public key that would be deployed to nodes</p><p>And configure the required set of master and worker nodes sizing. It would create a dedicated EC2 Auto-scaling group per each node pool.</p><h3>Deployment of K3s project</h3><p>After the configuration of all required setting you can run cdev plan/apply commands to check and apply whole stack in one shot.</p><pre>[~/tmpk3s]$ cdev plan<br>Plan results:<br>+----------------------------------+<br>|         WILL BE DEPLOYED         |<br>+----------------------------------+<br>| k3s-demo.aws_key_pair            |<br>| k3s-demo.route53                 |<br>| k3s-demo.vpc                     |<br>| k3s-demo.iam-policy-external-dns |<br>| k3s-demo.k3s                     |<br>| k3s-demo.kubeconfig              |<br>| k3s-demo.ingress-nginx           |<br>| k3s-demo.external-dns            |<br>| k3s-demo.cert-manager            |<br>| k3s-demo.outputs                 |<br>| k3s-demo.cert-manager-issuer     |<br>| k3s-demo-app.kuard               |<br>+----------------------------------+</pre><p>Here is the sample output for cdev apply:</p><pre>[~/tmpk3s]$ cdev apply<br>10:03:52 [INFO] Applying unit &#39;k3s-demo.route53&#39;:<br>10:03:52 [INFO] Applying unit &#39;k3s-demo.iam-policy-external-dns&#39;:<br>10:03:52 [INFO] Applying unit &#39;k3s-demo.aws_key_pair&#39;:<br>10:03:52 [INFO] [k3s-demo][route53][init] In progress...<br>10:03:52 [INFO] [k3s-demo][route53][init] executing in progress... 0s     <br>10:03:57 [INFO] [k3s-demo][route53][init] Success<br>10:03:57 [INFO] [k3s-demo][route53][apply] In progress...<br>...    <br>10:04:22 [INFO] [k3s-demo][route53][apply] executing in progress... 25s    <br>10:04:23 [INFO] [k3s-demo][iam-policy-external-dns][retrieving outputs] Success<br>10:04:23 [INFO] Applying unit &#39;k3s-demo.vpc&#39;:<br>10:04:23 [INFO] [k3s-demo][vpc][init] In progress...<br>10:04:23 [INFO] [k3s-demo][vpc][init] executing in progress... 0s     <br>10:04:25 [INFO] [k3s-demo][aws_key_pair][apply] Success<br>...<br>10:04:30 [INFO] [k3s-demo][aws_key_pair][retrieving outputs] Success<br>10:04:30 [INFO] [k3s-demo][vpc][init] Success<br>10:04:30 [INFO] [k3s-demo][vpc][apply] In progress...<br>10:04:30 [INFO] [k3s-demo][vpc][apply] executing in progress... 0s     <br>10:04:32 [INFO] [k3s-demo][route53][apply] executing in progress... 35s    </pre><p>Cluster.dev detect dependencies between units and build effective execution graph that applies Terraform, Helm and Kubernetes units in required order, passing values between units during execution.</p><p>After execution you will get outputs:</p><pre>10:25:57 [INFO] Printer: &#39;k3s-demo.outputs&#39;, Output:<br>k3s_version = v1.28.2+k3s1<br>kubeconfig = /tmp/kubeconfig_cdev-k3s-demo<br>region = eu-central-1<br>cluster_name = cdev-k3s-demo</pre><p>And you can use this kubeconfig and inspect your cluster:</p><pre>[~/tmpk3s]$ export KUBECONFIG=/tmp/kubeconfig_cdev-k3s-demo<br>[~/tmpk3s]$ kubectl get nodes<br>NAME                                           STATUS   ROLES                       AGE   VERSION<br>ip-10-8-0-48.eu-central-1.compute.internal     Ready    &lt;none&gt;                      26m   v1.28.2+k3s1<br>ip-10-8-11-142.eu-central-1.compute.internal   Ready    control-plane,etcd,master   27m   v1.28.2+k3s1<br>ip-10-8-4-183.eu-central-1.compute.internal    Ready    &lt;none&gt;                      26m   v1.28.2+k3s1<br><br>[~/tmpk3s]$ kubectl get all -A<br>NAMESPACE       NAME                                            READY   STATUS    RESTARTS   AGE<br>cert-manager    pod/cert-manager-56b95dfb77-xn9xx               1/1     Running   0          59s<br>cert-manager    pod/cert-manager-cainjector-7f75fcc746-brk45    1/1     Running   0          59s<br>cert-manager    pod/cert-manager-webhook-7f9dc7f889-ccbbt       1/1     Running   0          59s<br>default         pod/kuard-deployment-5bb67b58b7-trprg           1/1     Running   0          30s<br>external-dns    pod/external-dns-5cdc5f687-5zbxw                1/1     Running   0          48s<br>ingress-nginx   pod/ingress-nginx-controller-86dbc68954-ld6rs   1/1     Running   0          63s<br>kube-system     pod/aws-asg-roller-6c95885f4-j54ws              1/1     Running   0          12m<br>kube-system     pod/aws-cloud-controller-manager-ztqm2          1/1     Running   0          12m<br>kube-system     pod/coredns-6799fbcd5-fztnn                     1/1     Running   0          13m<br>kube-system     pod/ebs-csi-controller-846b59c468-dxzn5         5/5     Running   0          12m<br>kube-system     pod/ebs-csi-node-5h7nw                          3/3     Running   0          12m<br>kube-system     pod/local-path-provisioner-84db5d44d9-bxb5k     1/1     Running   0          13m<br>kube-system     pod/metrics-server-67c658944b-qlpt7             1/1     Running   0          13m</pre><p>To destroy K3s cluster and AWS resources you can use one command:</p><pre>[~/tmpk3s]$ cdev destroy<br>Plan results:<br>+----------------------------------+<br>|        WILL BE DESTROYED         |<br>+----------------------------------+<br>| k3s-demo-app.kuard               |<br>| k3s-demo.external-dns            |<br>| k3s-demo.ingress-nginx           |<br>| k3s-demo.cert-manager-issuer     |<br>| k3s-demo.outputs                 |<br>| k3s-demo.cert-manager            |<br>| k3s-demo.kubeconfig              |<br>| k3s-demo.k3s                     |<br>| k3s-demo.iam-policy-external-dns |<br>| k3s-demo.vpc                     |<br>| k3s-demo.aws_key_pair            |<br>| k3s-demo.route53                 |<br>+----------------------------------+<br>Continue?(yes/no) [no]: yes<br>10:51:40 [INFO] Destroying...            <br>10:51:40 [INFO] Destroying unit &#39;k3s-demo-app.kuard&#39;<br>10:51:43 [INFO] [k3s-demo-app][kuard][init] In progress...<br>10:51:43 [INFO] [k3s-demo-app][kuard][init] executing in progress... 0s     <br>10:51:45 [INFO] [k3s-demo-app][kuard][init] Success<br>10:51:45 [INFO] [k3s-demo][kubeconfig][init] In progress...<br>...</pre><h3>Summary</h3><p>In this article we explore easy way to deploying production ready infrastructure in AWS for k3s with cluster.dev. <br>It takes less then 20 minutes to get it all set, enshuring that whole infrastructure is codified(IaC). <br>Next you can explore by editing StackTemplates, launching single node clusters for testing purposes, or extend it with own set of addons or cloud resources.<br>Futher you can check our documentation: <a href="https://docs.cluster.dev/">docs.cluster.dev</a> and create own stacks on any cloud or even create own installed for your software.</p><p><em>Thanks!<br></em><a href="http://inkedin.com/in/voatsap/"><em>Volodymyr Tsap</em></a><em>,<br>CTO </em><a href="https://cluster.dev/"><em>Cluster.dev</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=718f823bb10c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GitOps for Terraform and Helm with Cluster.dev]]></title>
            <link>https://medium.com/@cluster.dev/gitops-for-terraform-and-helm-with-cluster-dev-f605c9859f2?source=rss-e69ec49fc0c0------2</link>
            <guid isPermaLink="false">https://medium.com/p/f605c9859f2</guid>
            <category><![CDATA[gitops]]></category>
            <category><![CDATA[platform-engineering]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[terraform-modules]]></category>
            <category><![CDATA[helm]]></category>
            <dc:creator><![CDATA[Cluster.dev]]></dc:creator>
            <pubDate>Wed, 30 Aug 2023 12:24:20 GMT</pubDate>
            <atom:updated>2023-10-11T09:35:50.922Z</atom:updated>
            <content:encoded><![CDATA[<p>If you’re looking to establish a GitOps flow for your Terraform Modules and Helm charts, <a href="https://cluster.dev/">Cluster.dev</a> might be exactly what you need.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6OxMlWgIL-gM0rj5qXewIA.png" /></figure><h3>Understanding GitOps</h3><ul><li>All configuration and infrastructure code are stored within Git.</li><li>Modifications to the configuration in Git initiate a reconciliation process, applying the changes.</li></ul><p>With cluster.dev, you’re always maintaining your entire configuration in Git.</p><p>Let’s delve into an example infrastructure repository: <a href="https://github.com/shalb/cdev-aws-eks">https://github.com/shalb/cdev-aws-eks</a></p><h3>Unit Versioning in StackTemplate</h3><p>A <a href="https://docs.cluster.dev/stack-templates-overview/">stack template</a> is a yaml file that tells Cluster.dev which units to run and how. It is a core Cluster.dev resource that makes for its flexibility. Stack templates use Go template language to allow you customize and select the units you want to run.</p><p>Here, <a href="https://github.com/shalb/cdev-aws-eks/blob/main/template.yaml">/template.yaml</a> contains links for each module, whether it&#39;s Terraform or a Helm chart.</p><pre>units:<br>  - name: route53<br>    type: tfmodule<br>    source: github.com/shalb/cluster.dev-domain?ref=v0.1.0 # refering git repo of the module with the version<br><br><br>  - name: vpc<br>    type: tfmodule<br>    providers: *provider_aws<br>    source: terraform-aws-modules/vpc/aws  # refering module in terraform registry and its version<br>    version: &quot;5.1.1&quot;        </pre><p>To upgrade a module within the template, simply alter the tag. Of course, testing with a development branch is recommended.</p><h3>Versioning the Resulting Infrastructure — The Stack</h3><p>The next layer of versioning occurs at the <a href="https://docs.cluster.dev/structure-stack/">Stack </a>level. This object dictates which StackTemplate to utilize and incorporates all essential variables for this stack.</p><p>Consider the following from <a href="https://github.com/shalb/cdev-aws-eks/blob/main/examples/stack-eks.yaml">https://github.com/shalb/cdev-aws-eks/blob/main/examples/stack-eks.yaml</a>:</p><pre>name: cluster<br>template: &quot;https://github.com/shalb/cdev-aws-eks?ref=main&quot; # The version of StackTemplate pinned to a specific stack<br>kind: Stack<br>backend: aws-backend<br>cliVersion: &quot;&gt;= 0.7.14&quot;<br>variables:<br>  region: {{ .project.variables.region }}</pre><p>Git Tags and branches in the stack can be utilized to maintain and update versions of StackTemplates.</p><h3>Upgrading Your Infrastructure</h3><p>Imagine you need to update a Terraform module in your production setup.</p><ol><li>Update the module version in the StackTemplate:</li></ol><pre>- name: route53<br>  type: tfmodule<br>  source: github.com/shalb/cluster.dev-domain?ref=v0.2.0 # Update the module&#39;s version here</pre><p>2. Given this alteration affects your infrastructure’s module, release a new tag for the StackTemplate in Git, then modify the tag inside the Stack:</p><pre>name: cluster<br>template: &quot;https://github.com/shalb/cdev-aws-eks?ref=1.2.3&quot; # Adjust the StackTemplate&#39;s version</pre><p>Done! Your infrastructure code now has a set pinned layout for infrastructure components, all maintained within Git.</p><h3>GitOps Reconciliation</h3><p>Cluster.dev, capable of initiating an entire infrastructure, is ideal for GitOps reconciliation. However, changes to the infrastructure can be critical, necessitating previews of planned modifications. We recommend instituting PR/MR process to review and sanction changes.</p><p>Here’s the typical process:</p><ol><li>An engineer modifies the Stack version, creating a Pull Request for the main branch.</li><li>This automatically activates the cluster.dev (cdev plan) command, enabling the user to scrutinize proposed infrastructure modifications.</li><li>Once the PR gets the green light, the merging process kickstarts a new pipeline, using the cluster.dev (cdev apply) command to effectively instate all changes.</li></ol><p>Consequently, Cluster.dev reconciles changes in various components, be they Terraform modules or Helm charts.</p><h3>GitHub Workflow Example</h3><p>Imagine storing your cluster.dev configurations (stack yamls) inside a Git repository under the .cluster.dev/dev-project/ folder.</p><p>For each project (e.g., dev or production infrastructure), create a distinct GitHub workflow file: .github/workflows/dev-project.yaml.</p><pre>name: Cluster.dev for dev-project<br><br>on:<br>  push:<br>    branches:<br>      - &#39;cluster.dev-*&#39;<br>      - main<br>    paths:<br>      - &#39;.cluster.dev/dev-project/**&#39;<br>  pull_request:<br>    branches:<br>      - main<br>    paths:<br>      - &#39;.cluster.dev/dev-project/**&#39;<br><br>jobs:<br>  plan:<br>    if: github.event_name == &#39;pull_request&#39;<br>    runs-on: ubuntu-latest<br>    container: clusterdev/cluster.dev:v0.7.18<br>    steps:<br>    - name: Check out code<br>      uses: actions/checkout@v3<br><br>    - name: Run ClusterDev Plan<br>      run: |<br>        cd .cluster.dev/10-project<br>        aws s3 mb s3://cdev-state || true # create or reuse state bucket<br>        cdev plan<br>      env:<br>        AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}<br>        AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}<br>        AWS_DEFAULT_REGION: eu-central-1<br>  apply:<br>    if: github.event_name == &#39;push&#39; &amp;&amp; contains(github.ref, &#39;refs/heads/main&#39;)  # Runs only on push to main branch<br>    runs-on: ubuntu-latest<br>    container: clusterdev/cluster.dev:v0.7.18<br>    steps:<br>    - name: Check out code<br>      uses: actions/checkout@v3<br><br>    - name: Run ClusterDev Apply<br>      run: |<br>        cd .cluster.dev/dev-project<br>        cdev apply --force<br>      env:<br>        AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}<br>        AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}<br>        AWS_DEFAULT_REGION: eu-central-1</pre><p>In this example, we employ a <a href="https://hub.docker.com/r/clusterdev/cluster.dev">cluster.dev container</a> from DockerHub. The two jobs are:</p><ul><li>plan: Generates a plan for a PR or a specific branch commit.</li><li>apply: Enacts the configuration and reconciles changes, with --force enabling non-interactive mode.</li></ul><p>This approach is highly adaptable, suitable for various CI/CD systems like GitLab or Jenkins.</p><h3>Demo</h3><p>You can play around with GitOps pipelines that would be generated into your repository and deploy cluster using this link <a href="https://aws-eks.dev.cluster.dev/">EKS Cluster creation demo</a>.</p><h3>In Conclusion</h3><p>Through this guide, we’ve seen how Cluster.dev facilitates the GitOps approach, enabling seamless integration, versioning, and reconciliation of infrastructure components.</p><p><em>Thanks!<br></em><a href="http://inkedin.com/in/voatsap/"><em>Volodymyr Tsap</em></a><em>,<br>CTO </em><a href="https://cluster.dev/"><em>Cluster.dev</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f605c9859f2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building UI for DevOps operations with Cluster.dev and Streamlit — part 2. Adding ChatGPT]]></title>
            <link>https://medium.com/@cluster.dev/building-ui-for-devops-operations-with-cluster-dev-and-streamlit-part-2-adding-chatgpt-84c6f7de9684?source=rss-e69ec49fc0c0------2</link>
            <guid isPermaLink="false">https://medium.com/p/84c6f7de9684</guid>
            <category><![CDATA[streamlit]]></category>
            <category><![CDATA[chatgpt]]></category>
            <category><![CDATA[platform-engineering]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Cluster.dev]]></dc:creator>
            <pubDate>Sat, 26 Aug 2023 11:34:08 GMT</pubDate>
            <atom:updated>2023-08-26T11:38:18.159Z</atom:updated>
            <content:encoded><![CDATA[<h3>Building UI for DevOps operations with Cluster.dev and Streamlit — part 2. Adding ChatGPT</h3><p>In <a href="https://medium.com/@cluster.dev/building-ui-for-devops-operations-with-cluster-dev-and-streamlit-5c0a5548cfc5">previous part</a> we have formalized required workflow. In this part we would start to build our UI for Cluster.dev with ChatGPT.</p><h3>Visualize workflow using ChatGPT and Diagrams as Code</h3><p>But before we start I’d like to share some hack that I’m using during any new project creation. My goal is to create some visualization on required process and for that I would use ChatGPT and <a href="https://diagrams.mingrammer.com/">Mingrammer Diagrams</a> which is a super cool project where you can describe diagrams as a Python code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-UKfRjomsrhaS4dDK0h_NQ.png" /><figcaption>ChatGPT promt to create Python code to visualize project</figcaption></figure><p>ChatGPT returns me a quite nice code:</p><pre>from diagrams import Diagram<br>from diagrams.c4 import Person, Container, Database, System, Relationship<br><br># Graph and Node attributes for customization<br>graph_attr = {<br>    &quot;splines&quot;: &quot;ortho&quot;,  # Orthogonal edges for vertical alignment<br>    &quot;rankdir&quot;: &quot;TB&quot;,    # Top to Bottom direction<br>    &quot;fontsize&quot;: &quot;16&quot;,<br>    &quot;bgcolor&quot;: &quot;black&quot;,<br>    &quot;fontcolor&quot;: &quot;white&quot;<br>}<br><br>with Diagram(&quot;Cluster Configuration and Deployment&quot;, show=False, graph_attr=graph_attr, node_attr=node_attr):<br>    user = Person(&quot;User&quot;, &quot;End-users customizing their cluster through the UI&quot;)<br><br>    # Containers<br>    ui_selection = Container(&quot;UI Selection&quot;, &quot;Select node size, region, domain, addons, etc.&quot;)<br>    repo_credentials = Container(&quot;Repository &amp; Credentials&quot;, &quot;Specify repository and provide AWS credentials&quot;)<br>    secure_aws_credentials = Container(&quot;Secure AWS Credentials&quot;, &quot;Store AWS credentials in GitHub&#39;s secret storage&quot;)<br>    dynamic_yaml_generation = Container(&quot;Dynamic YAML Generation&quot;, &quot;Generate YAML files based on user input&quot;)<br>    initiate_pr = Container(&quot;Initiate Pull Request&quot;, &quot;Create PR and trigger Plan step&quot;)<br>    review_merge = Container(&quot;Review &amp; Merge&quot;, &quot;Review PR details and merge to execute cdev apply&quot;)<br><br>    # Database<br>    github_secret_storage = Database(&quot;GitHub Secret Storage&quot;, &quot;Store AWS credentials securely&quot;)<br>    repository = Database(&quot;Repository&quot;, &quot;Store YAML and workflow files, initiate PRs&quot;)<br><br>    # Systems<br>    github = System(&quot;GitHub&quot;, &quot;Manage workflow, PRs, and secret storage&quot;)<br>    aws = System(&quot;AWS&quot;, &quot;Cloud provider for Kubernetes cluster&quot;)<br>    terraform_helm = System(&quot;Cluster.dev&quot;, &quot;Tools for bootstrapping the cluster&quot;)<br><br>    # Relationships<br>    user &gt;&gt; ui_selection<br>    ui_selection &gt;&gt; repo_credentials<br>    repo_credentials &gt;&gt; secure_aws_credentials<br>    secure_aws_credentials &gt;&gt; dynamic_yaml_generation<br>    dynamic_yaml_generation &gt;&gt; initiate_pr<br>    initiate_pr &gt;&gt; review_merge<br>    review_merge &gt;&gt; terraform_helm &gt;&gt; aws<br>    secure_aws_credentials &gt;&gt; github_secret_storage<br>    dynamic_yaml_generation &gt;&gt; repository</pre><p>That could be visualized to graph like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6khBrls2q20adqOe9NXq0Q.png" /><figcaption>Flow Diagram generated as a code by ChatGPT</figcaption></figure><p>Quite messy, but this could manually edited. It’s enough to keep in mind whole process that we need to codify and map to UI.</p><h3>Building our first Streamlit app</h3><p>To install Streamlit you need Python (for this article I’m using version 3.10.12) and to install Streamlit you need just to run: <strong><em>pip install streamlit.</em></strong></p><p>So lets create our first Streamlit app which would generate a <a href="https://docs.cluster.dev/structure-project/">Cluster.dev project.yaml</a></p><pre>import streamlit as st<br>import yaml<br><br>def generate_project_yaml():<br><br>    regions = [<br>        &quot;us-east-1&quot;, &quot;us-east-2&quot;, &quot;us-west-1&quot;, &quot;us-west-2&quot;,<br>        &quot;af-south-1&quot;, &quot;ap-east-1&quot;, &quot;ap-south-1&quot;, &quot;ap-northeast-1&quot;,<br>        &quot;ap-northeast-2&quot;, &quot;ap-northeast-3&quot;, &quot;ap-southeast-1&quot;, &quot;ap-southeast-2&quot;,<br>        &quot;ca-central-1&quot;, &quot;eu-central-1&quot;, &quot;eu-west-1&quot;, &quot;eu-west-2&quot;,<br>        &quot;eu-west-3&quot;, &quot;eu-north-1&quot;, &quot;eu-south-1&quot;, &quot;me-south-1&quot;,<br>        &quot;sa-east-1&quot;<br>    ]<br><br>    project_yaml = {<br>        &quot;name&quot;:  st.text_input(&quot;Name&quot;, &quot;my-project&quot;),<br>        &quot;kind&quot;: &quot;Project&quot;,<br>        &quot;backend&quot;: &quot;aws-backend&quot;,<br>        &quot;variables&quot;: {<br>            &quot;organization&quot;: st.text_input(&quot;Organization&quot;, &quot;my-company&quot;),<br>            &quot;region&quot;: st.selectbox(&quot;Region&quot;, regions, index=regions.index(&quot;eu-central-1&quot;)),<br>            &quot;state_bucket_name&quot;: st.text_input(&quot;State Bucket Name&quot;, &quot;cdev-state&quot;),<br>        },<br>    }<br>    return yaml.dump(project_yaml)<br><br>project_yaml_content = generate_project_yaml()<br>st.subheader(&quot;Project YAML&quot;)<br>st.code(project_yaml_content, language=&quot;yaml&quot;)</pre><p>And to run our app simply launch the Python file:</p><pre>streamlit run cdev-ui.py<br><br>  You can now view your Streamlit app in your browser.<br><br>  Network URL: http://127.0.0.1:8501<br>  External URL: http://127.0.0.1:8501</pre><p>So opening the browser link you will get the resulting UI with selections, you can change any values and you will see that code block with resulting yaml would be updated:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WBfVEH82FguvTwx7gr1yIA.png" /><figcaption>Generating YAML with Streamlit code</figcaption></figure><p>In this example I have used streamlit components: <br><a href="https://docs.streamlit.io/library/api-reference/widgets/st.text_input">st.text_input</a> for Name, Organization and State Bucket name,<br><a href="https://docs.streamlit.io/library/api-reference/widgets/st.selectbox">st.selectbox</a> for Region selection with pre-populated list,<br>and <a href="https://docs.streamlit.io/library/api-reference/text/st.code">st.code</a> to display resulting YAML.<br>So with so minor effort your are able to build own UI with just few lines of code.</p><h3>Advanced example of building UI</h3><p>Now lets try more advanced sample, we’ll generate a <a href="https://docs.cluster.dev/structure-stack/">Cluster.dev stack.yaml</a><br>Since some values we need to obtain from the project.yaml generated we would create a function <strong><em>generate_stack_eks_yaml(project_yaml).</em></strong></p><p>Before doing that we need to investigate what there could be potential options for that. To do this lets examine an example stack yaml:</p><pre>name: cluster<br>template: &quot;https://github.com/shalb/cdev-aws-eks?ref=main&quot;<br>kind: Stack<br>backend: aws-backend<br>cliVersion: &quot;&gt;= 0.7.14&quot;<br>variables:<br>  region: {{ .project.variables.region }}<br>  organization: {{ .project.variables.organization }}<br>  cluster_name: demo<br>  domain: cluster.dev<br>  eks_version: &quot;1.27&quot;<br>  environment: &quot;demo-env&quot;<br>  eks_addons:<br>    enable_argocd: true<br>    enable_nginx: true<br>    enable_external_secrets: true<br>    enable_cluster_autoscaler: true<br>    enable_aws_lb_controller: true<br>    enable_external_dns: true<br>    enable_cert_manager: true<br>    enable_efs: false<br>    enable_cert_manager_http_issuers: true<br>    enable_metrics_server: true<br>    enable_reloader: true<br>  eks_managed_node_groups:<br>    workers:<br>      capacity_type: SPOT<br>      desired_size: 2<br>      disk_size: 80<br>      force_update_version: true<br>      instance_types:<br>        - &quot;t3.xlarge&quot;<br>        - &quot;t3a.xlarge&quot;<br>        - &quot;m5.xlarge&quot;<br>      labels: {}<br>      max_size: 3<br>      min_size: 2<br>      name: spot-workers<br>      subnet_ids: {{ remoteState &quot;cluster.vpc.private_subnets&quot; }}<br>      taints: []<br>      update_config:<br>        max_unavailable: 1<br>      iam_role_additional_policies:<br>        ebspolicy: &quot;arn:aws:iam::aws:policy/service-role/AmazonEBSCSIDriverPolicy&quot;</pre><p>We see there are a static values, like template and kind, and also there could be inherited from the project values. Also we have a dynamic block for addons (eks_addons:) that could have multiple values and the configuration for node group(eks_managed_node_groups:) that is quite complex and could host different parameters like min/desired/max size, for spot instances there could be plenty instance types, also we can allow user to attch some policies to that node groups, etc…</p><p>So building UI for all of this looks time consuming. But I have used ChatGPT to help, by asking to generate a Streamlit Python code that would cover generating Cluster.dev stack.yaml:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RxgIHPB5WbZbX2rzR9G5Hw.png" /><figcaption>ChatGPT promt to build an streamlit UI for cluster.dev stack</figcaption></figure><p>So ChatGPT actually after examine <a href="https://docs.cluster.dev/">Cluster.dev documentation</a> and example stack configuration has generated a fully working code I could use in my UI. Definitely I would need to review it and make some adjustment, but the speed of codifying was amazing.</p><p>The resulting function looks like this:</p><pre>def generate_stack_eks_yaml(project_yaml):<br>    st.subheader(&quot;Configuration for EKS&quot;)<br><br>    project = yaml.safe_load(project_yaml)<br><br>    create_vpc = st.checkbox(&quot;Create VPC&quot;, value=True)<br><br>    vpc_config = None<br>    if not create_vpc:<br>        vpc_id = st.text_input(&quot;VPC ID&quot;)<br>        public_subnets = st.text_area(&quot;Public Subnets (comma-separated)&quot;).split(&quot;,&quot;)<br>        private_subnets = st.text_area(&quot;Private Subnets (comma-separated)&quot;).split(&quot;,&quot;)<br>        database_subnets = st.text_area(&quot;Database Subnets (comma-separated)&quot;).split(&quot;,&quot;)<br>        vpc_config = {<br>            &quot;vpc_id&quot;: vpc_id,<br>            &quot;public_subnets&quot;: public_subnets,<br>            &quot;private_subnets&quot;: private_subnets,<br>            &quot;database_subnets&quot;: database_subnets,<br>        }<br><br>    cluster_name = st.text_input(&quot;Cluster Name&quot;, &quot;demo&quot;)<br>    domain = st.text_input(&quot;Domain Name&quot;, &quot;cluster.dev&quot;)<br><br>    eks_version = st.selectbox(&quot;EKS Version&quot;, [&quot;1.27&quot;, &quot;1.26&quot;, &quot;1.25&quot;])<br>    instance_types = st.multiselect(<br>        &quot;Instance Types&quot;,<br>        [<br>            &quot;t3.xlarge&quot;, &quot;t3a.xlarge&quot;, &quot;m5.xlarge&quot;, &quot;m5n.xlarge&quot;,<br>            &quot;t3.medium&quot;, &quot;t3.large&quot;, &quot;m6i.large&quot;, &quot;m5.large&quot;,<br>            &quot;m5n.large&quot;, &quot;t3a.medium&quot;, &quot;t3a.large&quot;, &quot;m6a.large&quot;,<br>            &quot;m5a.large&quot;<br>        ],<br>        default=[&quot;t3.xlarge&quot;, &quot;m5.xlarge&quot;]<br>    )<br>    min_size = st.slider(&quot;Min Size&quot;, min_value=1, max_value=10, value=2)<br>    max_size = st.slider(&quot;Max Size&quot;, min_value=min_size, max_value=10, value=3)<br><br>    stack_eks_yaml = {<br>        &quot;name&quot;: &quot;cluster&quot;,<br>        &quot;template&quot;: &quot;https://github.com/shalb/cdev-aws-eks?ref=main&quot;,<br>        &quot;kind&quot;: &quot;Stack&quot;,<br>        &quot;backend&quot;: &quot;aws-backend&quot;,<br>        &quot;cliVersion&quot;: &quot;&gt;= 0.7.14&quot;,<br>        &quot;variables&quot;: {<br>            &quot;region&quot;: project[&quot;variables&quot;][&quot;region&quot;],<br>            &quot;organization&quot;: project[&quot;variables&quot;][&quot;organization&quot;],<br>            &quot;cluster_name&quot;: cluster_name,<br>            &quot;domain&quot;: domain,<br>            &quot;eks_version&quot;: eks_version,<br>            &quot;environment&quot;: &quot;demo-env&quot;,<br>            &quot;eks_managed_node_groups&quot;: {<br>                &quot;workers&quot;: {<br>                    &quot;capacity_type&quot;: &quot;SPOT&quot;,<br>                    &quot;desired_size&quot;: 2,<br>                    &quot;disk_size&quot;: 80,<br>                    &quot;force_update_version&quot;: True,<br>                    &quot;instance_types&quot;: instance_types,<br>                    &quot;labels&quot;: {},<br>                    &quot;max_size&quot;: max_size,<br>                    &quot;min_size&quot;: min_size,<br>                    &quot;name&quot;: &quot;spot-workers&quot;,<br>                    &quot;subnet_ids&quot;: &#39;{{ remoteState &quot;cluster.vpc.private_subnets&quot; }}&#39;,<br>                    &quot;taints&quot;: [],<br>                    &quot;update_config&quot;: {<br>                        &quot;max_unavailable&quot;: 1<br>                    },<br>                    &quot;iam_role_additional_policies&quot;: {<br>                        &quot;ebspolicy&quot;: &quot;arn:aws:iam::aws:policy/service-role/AmazonEBSCSIDriverPolicy&quot;<br>                    },<br>                }<br>            },<br>        }<br>    }<br>    eks_addons_list = [<br>        (&quot;ArgoCD&quot;, True),<br>        (&quot;NGINX&quot;, True),<br>        (&quot;External Secrets&quot;, True),<br>        (&quot;Cluster Autoscaler&quot;, True),<br>        (&quot;AWS LB Controller&quot;, True),<br>        (&quot;External DNS&quot;, True),<br>        (&quot;Cert Manager&quot;, True),<br>        (&quot;EFS&quot;, False),<br>        (&quot;Cert Manager HTTP Issuers&quot;, False),<br>        (&quot;Metrics Server&quot;, True),<br>        (&quot;Reloader&quot;, True)<br>    ]<br><br>    selected_addons = st.multiselect(<br>        &quot;Select EKS Addons&quot;,<br>        options=[name for name, _ in eks_addons_list],<br>        default=[name for name, state in eks_addons_list if state]<br>    )<br>    eks_addons = {f&quot;enable_{name.lower().replace(&#39; &#39;, &#39;_&#39;)}&quot;: (name in selected_addons) for name, _ in eks_addons_list}<br>    stack_eks_yaml[&quot;variables&quot;][&quot;eks_addons&quot;] = eks_addons<br><br>    if not create_vpc:<br>        stack_eks_yaml[&quot;variables&quot;].update(vpc_config)<br><br>    return yaml.dump(stack_eks_yaml)</pre><p>To integrate this in to existing sample just add similar function invocation as we have for project.yaml:</p><pre>stack_eks_yaml_content = generate_stack_eks_yaml(project_yaml_content)<br>st.subheader(&quot;Stack EKS YAML&quot;)<br>st.code(stack_eks_yaml_content, language=&quot;yaml&quot;)</pre><p>Resulting interface now looks like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LxcmyRkEmubIlqZQ3uogSw.png" /><figcaption>AWS EKS Cluster.dev Stack configuration</figcaption></figure><h3>Summary</h3><p>At this Part 2 article:<br>1. We discovered how to build a diagrams as a code with help of ChatGPT.<br>2. Launched our first Streamlit app.<br>3. Discovered how to build UI interface for <a href="https://cluster.dev/">Cluster.dev</a> with ChatGPT and Streamlit. <br>In next parts we would push our code to GitHub repository and trigger GH Actions.</p><p>In meanwhile you can check the ready to use <a href="https://aws-eks.dev.cluster.dev/">EKS Cluster creation demo</a>.<br>And if you interested to dig into UI code, <a href="https://github.com/shalb/cdev-aws-eks/tree/main/.cdev-metadata/streamlit">check it in template repository</a>.</p><p><em>Thanks!<br></em><a href="http://inkedin.com/in/voatsap/"><em>Volodymyr Tsap</em></a><em>,<br>CTO </em><a href="https://cluster.dev/"><em>Cluster.dev</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=84c6f7de9684" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building UI for DevOps operations with Cluster.dev and Streamlit]]></title>
            <link>https://medium.com/@cluster.dev/building-ui-for-devops-operations-with-cluster-dev-and-streamlit-5c0a5548cfc5?source=rss-e69ec49fc0c0------2</link>
            <guid isPermaLink="false">https://medium.com/p/5c0a5548cfc5</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[streamlit]]></category>
            <category><![CDATA[github-actions]]></category>
            <category><![CDATA[platform-engineering]]></category>
            <category><![CDATA[terraform]]></category>
            <dc:creator><![CDATA[Cluster.dev]]></dc:creator>
            <pubDate>Tue, 22 Aug 2023 14:50:02 GMT</pubDate>
            <atom:updated>2023-08-22T14:50:02.990Z</atom:updated>
            <content:encoded><![CDATA[<p>In the modern tech landscape, the “Platform Engineering” pattern emerges as a beacon of efficiency. Its primary goal? To streamline infrastructure operations, offering a product-like experience for Developers, QA professionals, and other engineers. With this approach, tasks such as launching environments, deploying services, conducting tests, and more become seamless.</p><p>Central to this transformation is the use of a unified CI/CD system. Now, most interactions can be executed by simply committing to Git repositories and initiating jobs. However, the traditional experience of using Git and managing tasks via the command line can feel somewhat lacking for end-users.</p><p>Enter a more intuitive approach: Imagine defining variables through drop-down menus, adjusting settings with sliders, and selecting multiple options with a simple click of the mouse. This not only enhances user experience but also aligns with the intuitive nature of modern interfaces.</p><h3>Example Task</h3><p>Let’s imagine we need to provide some interface that allows the product team to bootstrap EKS Kubernetes cluster in AWS Cloud with a set of preconfigured addons, domains, network policies, logging and monitoring and other. We need to cover everything as a code and allow users to change only required settings, like cluster size, node scaling, domain, project name in UI. It should be bootstrapped just with one click!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BrkxPX51j1IUzKQvoHNNvQ.png" /><figcaption>An example interface we are building</figcaption></figure><h3>Selecting the UI Framework — Streamlit</h3><p>There are plenty of options on how you can build a UI with a framework like Backstage or commercial platform providers, but from my standpoint it looks overwhelming. I’d like to find a solution that could be easily scripted, tested and could be launched standalone. From all options I have selected <a href="https://streamlit.io/">Streamlit</a>.</p><p>Streamlit is an open-source Python library that allows developers to create web applications for data science and machine learning with minimal effort. It’s designed to help Python developers and data scientists turn data scripts into shareable web applications without requiring any knowledge of web development.</p><h4><strong>Key Features:</strong></h4><p><strong>Python-centric UI Development</strong>: Streamlit is built for Python developers. You can create a full-fledged web application using just Python, without the need for HTML, CSS, or JavaScript.</p><p><strong>Quick Launch</strong>: With a simple command (streamlit run your_script.py), your Streamlit app is up and running in your browser.</p><p><strong>Hot-reloading</strong>: Streamlit apps automatically update as you modify your script, making it easy to see changes in real-time without manually refreshing the browser.</p><p><strong>Quick Prototyping</strong>: Streamlit’s intuitive API and interactive widgets allow for rapid prototyping and experimentation. You can quickly iterate on your app design and functionality.</p><p>So it looks like the best candidate for creating DevOps UI.</p><h3>Selecting Infrastructure Framework — Cluster.dev</h3><p>DevOps tasks for infrastructure development can be succinctly described as “technology integrations.” This means we have a plethora of modules and libraries, and we need to integrate them to deliver high-level abstractions to users who prefer not to delve into the underlying tech.</p><p>Given that everything should be codified, we typically use popular technologies like Terraform, Helm, Kubernetes, and perhaps the most versatile tool — shell scripting :) To maximize efficiency, we won’t craft infrastructure code from scratch. Instead, we’ll leverage public open-source patterns for infrastructure (such as Terraform modules) and for addons and software deployment (like Helm charts).</p><p><a href="https://docs.cluster.dev/">Cluster.dev</a> is a framework (and I’m one of its developers) that can seamlessly combine various high-level open-source technologies, like Terraform Modules and Helm Charts, into the StackTemplate.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bASSvv_u6BzD5Dk0XgxuRw.png" /><figcaption>Sample StackTemplate with Terraform Modules, Helm Charts and Shell Scripts</figcaption></figure><p>The StackTemplate is a static object that can be maintained in a repository with its distinct lifecycle. This allows for easy testing, upgrading of components, and setting default values. For reference, check out this example StackTemplate relevant to our task: <a href="https://github.com/shalb/cdev-aws-eks/blob/main/template.yaml">StackTemplate Example</a>.</p><p>All that’s left is to specify the variables necessary for this StackTemplate to initialize the infrastructure. This can be achieved with a straightforward YAML file (referred to as the Stack object in Cluster.dev). Given its simplicity, it’s an excellent foundation for building a user interface on top.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d0zVR0nrzDuu7c-p93Myyw.png" /><figcaption>Sample for Cluster.dev Stack yaml</figcaption></figure><p>Another cool point is that ChatGPT could easily create UI components with Streamit providing Python code for generating components like switches, sliders, multi-selects, etc…<br>I just dropped an example YAML — and It provides me with ready to use UI code!</p><h3>Selecting Execution Environment — GitHub Actions</h3><p>Now we have chosen the UI and Infrastructure frameworks. But we need some storage for configurations and executors that could execute the resulting code. Following the best GitOps practices we would rely on the CI/CD system and in our case I have chosen a GitHub Actions, since it widely operated, Workflow syntax could be easily generated and distributed.</p><h3>User Scenario for Cluster Configuration and Deployment</h3><p>Before we starting our project its a good practice to create a walkthrough the process and indicate the steps needs to be completed. Here was my list:</p><p><strong>UI Selection:</strong> Users have the flexibility to customize their cluster through the UI. They can select essential parameters such as node size, region, domain, addons, and other specific requirements.</p><p><strong>Repository &amp; Credentials:</strong> Users specify their repository and provide an access token for it. Additionally, they need to furnish credentials for their AWS account.</p><p><strong>Secure AWS Credentials:</strong> The system ensures the security of user data by storing AWS credentials in GitHub’s secret storage.</p><p><strong>Dynamic YAML Generation:</strong> Based on the user’s input, the system dynamically generates the necessary YAML files. These, along with GitHub workflow files, are then pushed to the specified repository.</p><p><strong>Initiate Pull Request:</strong> A Pull Request (PR) is automatically created. Following this, GitHub initiates a workflow that triggers the Plan step. This step involves creating an S3 bucket for Terraform (TF) and cluster.dev states. It also tests and provides an output preview of the planned cluster and associated resources set to be created.</p><p><strong>Review &amp; Merge:</strong> Users can review the details in the PR. Once they’re satisfied and merge it, GitHub executes the cdev apply. This command activates Terraform, Helm, and other units, bootstrapping the cluster into action.</p><h3>Summary</h3><p>At this part one we covered the task and list of technologies and steps to implement required UI and functionality. In the next chapters we can deep dive into technical implementation.</p><p>In meanwhile you can check the ready to use <a href="https://aws-eks.dev.cluster.dev/">EKS Cluster creation demo</a>.<br>And if you interested to dig into UI code, <a href="https://github.com/shalb/cdev-aws-eks/tree/main/.cdev-metadata/streamlit">check it in template repository</a>.</p><p><em>Thanks!<br></em><a href="http://inkedin.com/in/voatsap/"><em>Volodymyr Tsap</em></a><em>,<br>CTO </em><a href="https://cluster.dev/"><em>Cluster.dev</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5c0a5548cfc5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploying Prometheus Monitoring Stack with Cluster.dev]]></title>
            <link>https://medium.com/@cluster.dev/cluster-dev-monitoring-examples-d5e57b68619c?source=rss-e69ec49fc0c0------2</link>
            <guid isPermaLink="false">https://medium.com/p/d5e57b68619c</guid>
            <category><![CDATA[monitoring]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[cloud-devops]]></category>
            <category><![CDATA[terraform]]></category>
            <dc:creator><![CDATA[Cluster.dev]]></dc:creator>
            <pubDate>Mon, 16 May 2022 13:13:09 GMT</pubDate>
            <atom:updated>2022-06-22T10:23:03.067Z</atom:updated>
            <content:encoded><![CDATA[<p>05 MAY 2022</p><p><em>The code and the text prepared by </em><a href="https://github.com/gelo22"><em>Oleksii Kurinnyi</em></a><em>, a monitoring engineer at </em><a href="https://www.shalb.com/"><em>SHALB</em></a><em>.</em></p><p><a href="https://cluster.dev/">Cluster.dev</a> is a tool designed to template infrastructure patterns (stacks). It operates with a number of prepared stack templates to launch and provision Kubernetes clusters in the preferred cloud.</p><p>In this article we will use and modify the <a href="https://github.com/shalb/cdev-aws-k3s">basic AWS-K3s Cluster.dev template</a> to deploy the Prometheus monitoring stack to a cluster. As a result we will have a <a href="https://rancher.com/docs/k3s/latest/en/">K3s cluster</a> in AWS with a set of required controllers (Ingress, cert-manager, Argo CD) and installed <a href="https://github.com/prometheus-community/helm-charts/tree/kube-prometheus-stack-35.0.3/charts/kube-prometheus-stack">kube-prometheus</a> stack. The code samples are available in the <a href="https://github.com/shalb/monitoring-examples/tree/main/cdev/monitoring-cluster-blog">GitHub repository</a>.</p><h3><strong>Requirements</strong></h3><p>Operational System. We should have some client host with <a href="https://releases.ubuntu.com/20.04/">Ubuntu 20.04</a> to use this manual without any customization.</p><p>Docker. We should install <a href="https://docs.docker.com/engine/install/ubuntu/">Docker</a> to the client host.</p><p>AWS account. Log in into existing AWS account or <a href="https://aws.amazon.com/ru/premiumsupport/knowledge-center/create-and-activate-aws-account/">register a new one</a>. <a href="https://docs.aws.amazon.com/awsconsolehelpdocs/latest/gsg/select-region.html">Select</a> an AWS <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html#concepts-available-regions">region</a> in order to deploy the cluster in that region. Add a <a href="https://docs.aws.amazon.com/general/latest/gr/aws-sec-cred-types.html#access-keys-and-secret-access-keys">programmatic access key</a> for a new or existing user. Note that it should be an <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id_users_create.html">IAM user</a> with granted administrative permissions. Open bash terminal on the client host. Get an example environment file env to set our AWS credentials:</p><pre>curl <a href="https://raw.githubusercontent.com/shalb/monitoring-examples/main/cdev/monitoring-cluster-blog/env">https://raw.githubusercontent.com/shalb/monitoring-examples/main/cdev/monitoring-cluster-blog/env</a> &gt; env</pre><p>Add the programmatic access key to the environment file env:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/269/1*6raVnbT50hou_XvxOvpusQ.png" /></figure><h3>Create and deploy the project</h3><h4>Get example code</h4><pre>mkdir -p cdev &amp;&amp; mv env cdev/ &amp;&amp; cd cdev &amp;&amp; chmod 777 ./<br>alias cdev=&#39;docker run -it -v $(pwd):/workspace/cluster-dev --env-file=env clusterdev/cluster.dev:v0.6.3&#39;<br>cdev project create <a href="https://github.com/shalb/cdev-aws-k3s?ref=v0.3.0">https://github.com/shalb/cdev-aws-k3s?ref=v0.3.0</a><br>curl <a href="https://raw.githubusercontent.com/shalb/monitoring-examples/main/cdev/monitoring-cluster-blog/stack.yaml">https://raw.githubusercontent.com/shalb/monitoring-examples/main/cdev/monitoring-cluster-blog/stack.yaml</a> &gt; stack.yaml<br>curl <a href="https://raw.githubusercontent.com/shalb/monitoring-examples/main/cdev/monitoring-cluster-blog/project.yaml">https://raw.githubusercontent.com/shalb/monitoring-examples/main/cdev/monitoring-cluster-blog/project.yaml</a> &gt; project.yaml<br>curl <a href="https://raw.githubusercontent.com/shalb/monitoring-examples/main/cdev/monitoring-cluster-blog/monitoring.yaml">https://raw.githubusercontent.com/shalb/monitoring-examples/main/cdev/monitoring-cluster-blog/monitoring.yaml</a> &gt; monitoring.yaml</pre><h4>Create S3 bucket to store the project state</h4><p>Go to AWS S3 and <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/create-bucket-overview.html">create a new bucket</a>. Replace the value of state_bucket_name key in config file project.yaml by the name of the created bucket:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1015/1*g14VNXT3z5oIUBf_bJJm2A.png" /></figure><h4>Customize project settings</h4><p>We shall set all the settings needed for our project in the project.yaml config file. We should customize all the variables that have # example comment in the end of the line.</p><p><em>Select AWS Region</em></p><p>We should replace the value of region key in config file project.yaml by our region.</p><p><em>Set unique cluster name</em></p><p>By default we shall use cluster.dev domain as a root domain for cluster <a href="https://kubernetes.github.io/ingress-nginx/">ingresses</a>. We should replace the value of cluster_name key by a unique string in config file project.yaml, because the default ingress will use it in resulting DNS name.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1015/1*EFqMA1b8QQ_N4qxeH9X3XQ.png" /></figure><p>This command may help us to generate a random name and check whether it is in use:</p><pre>CLUSTER_NAME=$(echo &quot;$(tr -dc a-z0-9 &lt;/dev/urandom | head -c 5)&quot;) <br>dig argocd.${CLUSTER_NAME}.cluster.dev | grep -q &quot;^${CLUSTER_NAME}&quot; || echo &quot;OK to use cluster_name: ${CLUSTER_NAME}&quot;</pre><p>If the cluster name is available we should see the message OK to use cluster_name: ...</p><p><em>Set SSH keys</em></p><p>We should have access to cluster nodes via SSH. To add the existing SSH key we should replace the value of public_key key in config file project.yaml. If we have no SSH key, then we should <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/create-key-pairs.html">create it</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1015/1*fWqtupNU7G8LNIMdekbMKg.png" /></figure><p><em>Set Argo CD password</em></p><p>In our project we shall use <a href="https://argo-cd.readthedocs.io/en/stable/">Argo CD</a> to deploy our applications to the cluster. To secure Argo CD we should replace the value of argocd_server_admin_password key by a unique password in config file project.yaml. The default value is a bcrypted password string.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1015/1*le63-Z7D9vgolwW38BJESQ.png" /></figure><p>To encrypt our custom password we may use an <a href="https://www.browserling.com/tools/bcrypt">online tool</a> or encrypt the password by command:</p><pre>alias cdev_bash=&#39;docker run -it -v $(pwd):/workspace/cluster-dev --env-file=env --network=host --entrypoint=&quot;&quot; clusterdev/cluster.dev:v0.6.3 bash&#39;<br>cdev_bash<br>password=$(tr -dc a-zA-Z0-9,._! &lt;/dev/urandom | head -c 20)<br>apt install -y apache2-utils &amp;&amp; htpasswd -bnBC 10 &quot;&quot; ${password} | tr -d &#39;:\n&#39; ; echo &#39;&#39;<br>echo &quot;Password: $password&quot;<br>exit</pre><p><em>Set Grafana password</em></p><p>Now we are going to add a custom password for <a href="https://grafana.com/docs/grafana/latest/">Grafana</a>. To secure Grafana we should replace the value of grafana_password key by a unique password in config file project.yaml.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1015/1*Nyam7YhL4v-A_MRFM2fZpA.png" /></figure><p>This command may help us to generate a random password:</p><pre>echo &quot;$(tr -dc a-zA-Z0-9,._! &lt;/dev/urandom | head -c 20)&quot;</pre><h4>Run Bash in Cluster.dev container</h4><p>To avoid installation of all needed tools directly to the client host, we will run all commands inside the Cluster.dev container. In order to execute Bash inside the Cluster.dev container and proceed to deploy, run the command:</p><pre>cdev_bash</pre><h4>Deploy the project</h4><p>Now we should deploy our project to AWS via cdev command:</p><pre>cdev apply -l debug | tee apply.log</pre><p>In case of successful deployment we should get further instructions on how to access Kubernetes, and the URLs of Argo CD and Grafana web UIs. Sometimes, because of DNS update delays we need to wait some time to access those web UIs. In such case we can forward all needed services via kubectl to the client host:</p><pre>kubectl port-forward svc/argocd-server -n argocd 18080:443  &gt; /dev/null 2&gt;&amp;1 &amp;<br>kubectl port-forward svc/monitoring-grafana -n monitoring 28080:80  &gt; /dev/null 2&gt;&amp;1 &amp;</pre><p>We may test our forwards via curl:</p><pre>curl 127.0.0.1:18080<br>curl 127.0.0.1:28080</pre><p>If we see no errors from curl, then the client host should access these endpoints via any browser.</p><h3>Destroy the project</h3><p>We can delete our cluster with the command:</p><pre>cdev apply -l debug<br>cdev destroy -l debug | tee destroy.log</pre><h3>Conclusion</h3><p>Within this article we have learnt how to deploy the Prometheus monitoring stack with the Cluster.dev AWS-K3s template. The resulting stack allows us to monitor workloads in our cluster. We can also reuse the stack as a prepared infrastructure pattern to launch environments for testing monitoring cases, before applying them to production.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d5e57b68619c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why you need Cluster.dev?]]></title>
            <link>https://medium.com/@cluster.dev/why-you-need-cluster-dev-efa33d2b3dfa?source=rss-e69ec49fc0c0------2</link>
            <guid isPermaLink="false">https://medium.com/p/efa33d2b3dfa</guid>
            <category><![CDATA[crossplane]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[cloud-native]]></category>
            <dc:creator><![CDATA[Cluster.dev]]></dc:creator>
            <pubDate>Tue, 22 Mar 2022 18:57:13 GMT</pubDate>
            <atom:updated>2022-05-24T06:21:18.475Z</atom:updated>
            <content:encoded><![CDATA[<h3>Why do you need Cluster.dev?</h3><p>Open source community bounts with a variety of products. Today we are going to introduce <a href="http://cluster.dev/">Cluster.dev </a>— an infrastructure managing software that joins the ranks of publicly accessible tools.</p><p>In this article we shall address the questions of why users need Cluster.dev, what problems it helps to solve and what practical values its adoption could bring.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xzeu_AVcsxcTrE4SBKV61w.jpeg" /></figure><h3>What for?</h3><p>Cluster.dev began as an in-house SHALB project. At first it was aimed to solve our own problems as a DevOps company: how to automate infrastructure deployments? How to propagate changes across environments? What’s the most effective way to create reference infrastructure patterns and share experience across teams? Later on, inspired by the results, we decided to open source it to the world.</p><p>The main idea of Cluster.dev is to integrate previously disconnected infrastructure components, so that a whole infrastructure could be described and deployed with a single tool. Cluster.dev achieves this due to precise inner structure and the templating engine it has inside. Using units as building blocks, it supports executing infrastructure patterns and their reconciliation within a high-level abstraction of a project.</p><p>Being a synthesis of technology best practices, Cluster.dev advocates the most effective ways of infrastructure management, such as IaC, GitOps, safe working with secrets, etc.</p><p>Moreover, it supports your existing stack, which makes it easy to start working with. You can import your already created Terraform repos, modules and Kubernetes manifests without any changes; reuse existing Terraform code and Kubernetes Helm charts, CRDs and even your applications — whatever infrastructure tools you have, Cluster.dev is designed to connect and manage them all together.</p><h3>For whom?</h3><p>Our target audience is primarily infrastructure teams with a certain level of expertise, to whom Cluster.dev could simplify their daily routine: creating clusters, deploying services to the clusters, launching environments, sharing experience with development teams, etc.</p><p>Using Cluster.dev would be most effective in companies with rapidly changing infrastructures that have problems with the components’ dependencies and interrelation. Most often it is fast-growing startups with full-cycle development, frequent updates of infrastructure components and deployments to different environments.</p><h3>What’s the difference?</h3><p>With all the wonderful capabilities of Cluster.dev, one may ask — why would I need it? What advantages does it have against in-house scripts? Well, to put it concisely, it is the elegance and reliability of the solution, the coherence of all components and the speed of implementation.</p><p>As any other software, the scripts have to be tested, maintained and updated. There is no guarantee that they will work together seamlessly, which puts in question the consistency of infrastructure operation. Moreover, an infrastructure automated by scripts is hard to replicate, test against new changes and keep knowledge about.</p><p>Сluster.dev, on the contrary, is a ready-made automation solution. It provides you with a solid bonding agent that consolidates all parts of your system within an infrastructure pattern, which is reusable and easily replicable. So whenever you need to test some infrastructure changes, you can spin up identical environments and play around with them, before propagating the changes further. As a GitOps tool, it keeps all information about the state of your infrastructure in a Git repo, meaning that all changes are documented and the knowledge well preserved.</p><p>Cluster.dev is an infrastructure automation tool. It is designed to describe and deploy a whole infrastructure as a single set — the kind of thing that is hard to achieve with other tools because of their inner limitations. Since Cluster.dev maintains automated deployment of tools in chain order, it enables you to launch the whole system in a single go.</p><h3>Cluster.dev vs TF</h3><p>As a managing software, Cluster.dev uses Terraform alongside other tools as one of the infrastructure building blocks. It does not substitute Terraform but rather makes it stronger by overcoming some of its limitations, especially when it comes to templating.</p><p>The lack of option to template Terraform files makes users rely on temporary solutions, which makes things even more complicated. Powerful templating capabilities of Cluster.dev allow you to template everything, as well as Terraform code. This way you can include Jenkins Terraform module with custom inputs for the dev environment and not include it for staging and production — all in the same codebase.</p><p>Another pain point of Terraform that Cluster.dev successfully solves is the logic of working with providers. For example, in Terraform you cannot define a provider for Kubernetes or Helm within the same codebase that creates a Kubernetes cluster. You can do this either in two different deploys, or by means of bash scripts. With Cluster.dev you can have your tools automatically deployed one by one, with no need to keep in mind a scheme of their interaction, and as such launch the whole system with a single command.</p><h3>What’s its business value?</h3><p>From a business perspective, adoption of Cluster.dev brings certain values to a company.</p><p>First and foremost, it accelerates the product time to market by enhancing the conditions for its development. With most of the infrastructure processes automated, it becomes easier to launch new environments, testing new features, performing chain order deployments, etc. The productivity of SRE and product teams increases, which in turn makes a positive effect on the product development process.</p><p>Using Cluster.dev imposes no risks of vendor lock-in. First, it is built on open-source technologies and has broad integration possibilities. Second, it supports export to plain Terraform code, which means no need to recreate your whole infrastructure over again in case you switch to another tool.</p><h3>Conclusion</h3><p>Drawing a parallel between Kubernetes and Cluster.dev, we can say that Cluster.dev does to infrastructure components the same as Kubernetes to containers, i.e. consolidates them all within itself. Along with that, it is not a revolutionary solution: Cluster.dev is based on DevOps tools and practices that have been used to a good effect before, such as Iac, Terraform and templating. The question at issue is how we combined all these technologies and made them work together.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=efa33d2b3dfa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cluster.dev — DevOps Platform Framework]]></title>
            <link>https://medium.com/@cluster.dev/cluster-dev-devops-platform-framework-3bc832bff05e?source=rss-e69ec49fc0c0------2</link>
            <guid isPermaLink="false">https://medium.com/p/3bc832bff05e</guid>
            <category><![CDATA[devops-tool]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[cloud-native]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Cluster.dev]]></dc:creator>
            <pubDate>Fri, 18 Feb 2022 14:20:23 GMT</pubDate>
            <atom:updated>2022-02-18T14:21:37.952Z</atom:updated>
            <content:encoded><![CDATA[<h3>Cluster.dev — DevOps Platform Framework</h3><h3>At <a href="http://shalb.com/">SHALB</a> we build infrastructures and platforms. An infrastructure is a set of components that are used to launch workloads.The components could be networks, DNS servers, container orchestrators, databases, functions, policies, etc.</h3><h3>Under a platform we mean some reference infrastructure patterns. We design them for SRE and Product teams so that they could launch infrastructures from those examples.</h3><p>Building DevOps Platforms</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7Vu3pU5ikOnWhFQR.jpg" /></figure><h3>So the platform delivery looks like this:</h3><p>To follow this approach, the infrastructures should be 100% described as code. In this case you will be able to apply, test and propagate changes to all dependent infrastructures. Suppose we want to deliver an infrastructure using a platform approach. Let’s take a sample platform and see what our workflow would look like.</p><h3>Our platform will be:</h3><p>AWS</p><pre>terraform/</pre><pre>/vpc - module that defines network segmentation in the cloud</pre><pre>/dns - module that creates DNS records with Route 53</pre><pre>/eks - module that launches managed Kuberentes cluster</pre><pre>kubernetes/</pre><pre>/ingress-nginx - manifests that bring the Ingress controller on EKS.</pre><pre>helm/</pre><pre>/argocd - ArgoCD - deployment controller</pre><pre>/externaldns - K8s controller to update DNS records</pre><pre>env/</pre><pre>/dev - infrastructure values and sequence of infrastructure launching (tf files, Bash scripts, README&#39;s)</pre><pre>/stage - another version of infrastructure</pre><p>Even if we store this in Git and have a pretty decent runbook, we face the following challenges:</p><ul><li>– How to fully automate infrastructure deployments</li><li>– How to implement continuous infrastructure testing</li><li>– How to enable propagation of infrastructure changes across different environments</li></ul><p>The root cause of the problem is that infrastructure code contains different technologies, like: Terraform, Helm, K8s manifests, Bash scripts, etc. This makes it hard and sometimes even impossible to couple them together.</p><p>We can address these issues with cluster.dev.</p><h3>Abstractions</h3><h3>Cluster.dev has a few abstractions that help solve the problems of platform delivery.</h3><p>1. Unit.</p><p>Like a basic lego brick, a unit is responsible for passing variables to a particular technology, for example: Terraform Module, Helm chart or Bash script. By executing a unit you get the outputs.</p><p>2. Stack Template.</p><p>A set of different units, coupled together with a common templating engine. Stack Template defines infrastructure patterns or even the whole platform.</p><p>3. Stack.</p><p>A set of variables and secrets that will be applied to a Stack Template and executed. After the Stack execution we will be ready to use infrastructure objects.</p><p>4. Project.</p><p>A house for multiple Stacks that can share global variables and exchange outputs. All Stacks in Project can be executed in parallel and have dependencies.</p><p>5. Backend.</p><p>Like the Terraform backend, defines where to store the state for execution. Could be local or using a cloud object storage.</p><p>6. Generators.</p><p>As part of a Stack Template, you can script dialogues for end users where they could populate Stack values in an interactive mode.</p><h3>Workflow</h3><p>Now, let’s get back to our platform and check the workflow.</p><p>Platform team -&gt; creates TF modules, Helm charts, etc. The code is hosted in monorepo or in multiple repos.</p><p>Platform team -&gt; assembles infrastructure pattern as a Stack Template and keeps it in Git repo, able to versionate, tag, etc.</p><p>SRE/Product team -&gt; Declares values for the Stack, picks the version of the Stack Template by Git URL and executes a one-shot command: `cdev apply` that will create or update the target infrastructure/s.</p><h3>Alternatives</h3><p>So, what other options could be an alternative to this approach?</p><ol><li>Define everything in Terraform. Looks fine, but has a few downsides. Sometimes you need to do several `terraform apply`, which dismisses the idea to run this as a one shot. Also, you have to keep Helm charts values or raw Kubernetes manifests converted to HCL code, which is a fairly complex and useless task.</li><li>Pulumi. A great option if your platform team is good at programming on TypeScript or .NET. The downside of Pulumi is that you need to rewrite or convert all Terraform modules that you use, and maintain them on your own.</li><li>Crossplane. Basically a good option if you are a heavy Kubernetes user, because to run things you need to launch an operational cluster. Also, you need to have a common templating to your manifests or use Helm for this. Note that the number of objects supported is smaller than in Terraform.</li><li>CDK. There is an AWS CDK, Terraform CDK, Kubernetes CDK. So you’ll have to rewrite the existing code and maintain it.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3bc832bff05e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why do we need infrastructure templating?]]></title>
            <link>https://medium.com/@cluster.dev/why-do-we-need-infrastructure-templating-50c46f5ce383?source=rss-e69ec49fc0c0------2</link>
            <guid isPermaLink="false">https://medium.com/p/50c46f5ce383</guid>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[devops-practice]]></category>
            <category><![CDATA[cloud-native]]></category>
            <category><![CDATA[devops-tool]]></category>
            <dc:creator><![CDATA[Cluster.dev]]></dc:creator>
            <pubDate>Fri, 18 Feb 2022 14:10:25 GMT</pubDate>
            <atom:updated>2022-02-18T14:12:05.184Z</atom:updated>
            <content:encoded><![CDATA[<p>For modern cloud native environments, infrastructure templating is critical as it helps simplify the processes of infrastructure development and maintenance, in particular:</p><ol><li>Makes infrastructure development easier by defining functional borders.</li><li>Enables to test the interoperability of components even if they contain different technologies.</li><li>Provides for sharing infrastructure patterns with other team members.</li><li>Makes it possible to ship infrastructure as part of the product.</li><li>Allows split responsibilities between Platform and SRE teams.</li><li>Enables to fully utilize GitOps approach for all infrastructure components.</li></ol><p>Now, let’s explore the most common use cases of infrastructure templating and take a closer look at the benefits that it holds.</p><h3>Infrastructure development and promotion</h3><p>During the development process you need to have a pipeline to develop and promote some features from dev to stage and prod environments, the same way as you deploy and test your applications. Using common infrastructure templates and versionating through Git helps you do this and integrate with your existing CI/CD solution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/704/0*ZVSBzHZM5mNYXck4.png" /></figure><p>Infrastructure development process with the versioned template example.</p><h3>Segregation of team responsibilities</h3><p>This becomes especially relevant when your company grows larger and you have several teams. The team responsible for creating infrastructure patterns (let’s call it a platform team) can provide these patterns as a complete Infra Template to an SRE team who actually deploys and operates production infrastructures. Beside that the same Infra Template can be used by developers and QA engineers to spawn temporary dev and test infrastructures:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GFhHWUcLmweSaJkV.png" /></figure><h3>Software shipment</h3><p>Complex business applications often require a complex infrastructure to be pre-deployed. In this case a vendor can ship their product along with the Infrastructure template in order to simplify the adoption process for the enterprise solution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vt9C4Bp1Nh3yC8pE.png" /></figure><h3>Template Market</h3><p>Another use-case is when some engineer needs to deploy a new infrastructure for testing or exploring and wants all to be set in a few commands. He or she can choose a template from the Github project or from the marketplace, set the values and spawn the required infrastructure in minutes:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*WoWzrUoa5QUETEWJ.png" /></figure><p>As we can see from the use cases above, templating can dramatically simplify the tasks of DevOps and SRE teams, including deployment and testing in complex environments. Now, what are the components of infra templates? We shall explore the building blocks required to create an infra template, proceeding from infrastructure layering.</p><h3>Infrastructure Layering</h3><p>Modern cloud native infrastructures may contain a lot of different layers. Based on our experience we identify the following of them:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1005/0*GEoXpoR9q2Wono8S.png" /></figure><ol><li>Networking Layer — VPC’s, Peerings, VPN’s, Security Groups and Routing.</li><li>Permissions Layer — IAM roles and user policies.</li><li>Infra and OS Layer — server instances provision, operating system settings.</li><li>Data Management Layer — Relational and NoSQL databases, caches, file and object storages.</li><li>Application Layer — container orchestration, application continuous delivery, business applications and workloads, infrastructure applications.</li><li>Observability Layer — Metric logs and tracing applications and storages.</li><li>Configuration Layer — Declarative configuration storage, infrastructure state storages, secret storages.</li></ol><p>Let’s see how these layers could be covered with technologies and tooling.</p><h3>Networking Layer</h3><p>With the use of modern clouds most of the networking is covered by Software Defined Networks and Cloud API’s that enable users to declare a network as a code. There are two the most commonly used approaches here:</p><p>To use Terraform modules designed to define cloud network for your project, for example: <a href="https://github.com/terraform-aws-modules/terraform-aws-vpc">Terraform module which creates VPC resources on AWS<br></a><a href="https://github.com/gruntwork-io/terraform-google-network">Terraform code and scripts for deploying a GCP Virtual Private Cloud (VPC).<br></a><a href="https://github.com/Azure/terraform-azurerm-network">Terraform Azure RM Module for Network</a></p><p>When you need to define networking inside your container orchestration layer (ex Kubernetes) and there you have plenty of options using network plugins (CNI), for example: <a href="https://www.projectcalico.org/">https://www.projectcalico.org/</a> or <a href="https://cilium.io/">https://cilium.io/</a>. In most cases the tools are delivered as Helm charts along with Kubernetes manifests.</p><h3>Permissions Layer</h3><p>Fine-grained permissions could be declared on different layers. Let’s check the most common ones.</p><p>The infrastructure permissions could be set with Terraform modules for IAM and Roles, for example: <a href="https://github.com/terraform-aws-modules/terraform-aws-iam">Terraform module which creates IAM resources on AWS</a>, <a href="https://github.com/terraform-google-modules/terraform-google-iam">Terraform module to manage multiple IAM roles for resources on Google Cloud.</a></p><p>Or, if you need to set it in Kubernetes, the most common way to do this is to use native <a href="https://kubernetes.io/docs/reference/access-authn-authz/rbac/">RBAC</a>. Sometimes you also need to have external authentication like using <a href="https://kubernetes.io/docs/reference/access-authn-authz/authentication/#openid-connect-tokens">OpenID Connect Tokens</a>.</p><p>But sometimes you need to link permissions within Kubernetes to your cloud roles, and so you need to use technologies like <a href="https://aws.amazon.com/blogs/opensource/introducing-fine-grained-iam-roles-service-accounts/">AWS IRSA</a>, <a href="https://docs.microsoft.com/en-us/azure/aks/use-managed-identity">Azure Managed Identities</a>, <a href="https://cloud.google.com/kubernetes-engine/docs/how-to/workload-identity">GKE Workload Identity</a>. In this case you need to combine Terraform modules with Kubernetes manifests, getting outputs from one technology and passing them to another.</p><p>Permissions and policy enforcement are mostly done using <a href="https://www.openpolicyagent.org/docs/latest/">Open Policy Agent.</a></p><h3>Infra and OS Layer</h3><p>As with previous layers, the infrastructure layer can also be declared with the Terraform modules: <a href="https://github.com/terraform-aws-modules/terraform-aws-autoscaling">Terraform module Auto Scaling resources on AWS</a>, <a href="https://github.com/terraform-google-modules/terraform-google-kubernetes-engine">Terraform module for configuring GKE clusters</a>, <a href="https://registry.terraform.io/modules/Azure/compute/azurerm/latest">Azure compute Terraform module</a>, but sometimes you need to add extra configurations to your images with cloud-init and scripts, <a href="https://www.packer.io/">Hashicorp Packer</a> or <a href="https://www.ansible.com/">Ansible</a>.</p><h3>Data Management Layer</h3><p>Most cloud providers support managed storages: AWS S3/EBS, GCP Cloud Storage, Azure file and blob storage. The same goes for Managed Databases: AWS RDS, Azure Cosmos DB, Google Cloud Databases. The most common way to declare them is with Terraform modules.</p><h3>Application Layer</h3><p>Cloud native applications can be divided into two groups:</p><p>Infrastructure Applications — are deployed along with an infrastructure, like Kafka, Service Mesh, Ingress Controller, GitOps Controller. These are generally deployed with Helm charts or with some sort of bash-scripts. <br>Business Applications — are mostly deployed with CI/CD tooling like Jenkins and GitLab. Business applications have their own lifecycle that is different from infrastructure applications.</p><h3>Observability Layer</h3><p>Monitoring and logging can be provided by the cloud itself like AWS CloudWatch or Google Stackdriver, or by an external vendor like Datadog. Most of these solutions support Terraform for configuration. <br>In a cluster tooling like EFK or Prometheus/Grafana is mostly deployed with Terraform or as a Helm chart.</p><h3>Configuration Layer</h3><p>The most common way to store configuration and infrastructure declarations is in the Git repo. This approach adds accountability and enables us to restore required configuration versions to a certain point of time. <br>Another thing to consider is that you need to keep the resulting infrastructure state after applying the configuration. As it could contain some sensitive data, it is better to use a different storage, like object storage or database.</p><p>For storing secrets and certificates you can use cloud specific storages like AWS SSM, Azure Vault or opt for external tooling like <a href="https://www.vaultproject.io/">Hashicorp Vault</a> or <a href="https://github.com/mozilla/sops">SOPS</a>.</p><p>So let’s recap how we could describe a modern infrastructure using a specific set of tooling for each layer:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*iDicvFaZW7iYIivA.png" /></figure><p>Infrastructure declaration by tools and layers.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=50c46f5ce383" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>