<?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 Arun Singh Sisodiya on Medium]]></title>
        <description><![CDATA[Stories by Arun Singh Sisodiya on Medium]]></description>
        <link>https://medium.com/@arun-sisodiya?source=rss-e25f2a184621------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*skfgRRLK6H7FnpO2xoyWfQ.png</url>
            <title>Stories by Arun Singh Sisodiya on Medium</title>
            <link>https://medium.com/@arun-sisodiya?source=rss-e25f2a184621------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 25 Nov 2026 01:05:10 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@arun-sisodiya/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[Secure Your Kubernetes Cluster: Learn the Essential Best Practices for Keeping Your Deployment Safe…]]></title>
            <link>https://blog.devops.dev/secure-your-kubernetes-cluster-learn-the-essential-best-practices-for-keeping-your-deployment-safe-4830d9b156d9?source=rss-e25f2a184621------2</link>
            <guid isPermaLink="false">https://medium.com/p/4830d9b156d9</guid>
            <category><![CDATA[best-practices]]></category>
            <category><![CDATA[devsecops]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[cloudsecurityinuk]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Arun Singh Sisodiya]]></dc:creator>
            <pubDate>Mon, 27 Feb 2023 14:54:10 GMT</pubDate>
            <atom:updated>2023-03-03T19:55:56.619Z</atom:updated>
            <content:encoded><![CDATA[<h3>Secure Your Kubernetes Cluster: Learn the Essential Best Practices for Keeping Your Deployment Safe 🔒</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-soTP4oRyG9Ux0XBgBi-zQ.jpeg" /></figure><p>🚀 Kubernetes has quickly become one of the most popular container orchestration tools used in cloud-native applications. However, with great power comes great responsibility, and it’s crucial to ensure that your Kubernetes deployments are secure. In this blog post, we’ll explore some Kubernetes security best practices that you can implement to secure your LinkedIn application deployments.</p><h3>🔒 Use Role-Based Access Control (RBAC)</h3><p>RBAC is a Kubernetes feature that allows you to control access to Kubernetes resources. You can define roles and permissions for different users or groups of users, and restrict access to sensitive resources. By using RBAC, you can limit the damage that an attacker can do if they manage to gain access to your Kubernetes cluster. For example, you might have a developer who needs to be able to deploy applications, but they don’t need to be able to view or modify the cluster’s configuration. You can use RBAC to give them the permissions they need without exposing the entire cluster to them.</p><p>Let’s look into an example:</p><pre>kind: Role<br>apiVersion: rbac.authorization.k8s.io/v1<br>metadata:<br>  namespace: example<br>  name: pod-reader<br>rules:<br>- apiGroups: [&quot;&quot;]<br>  resources: [&quot;pods&quot;]<br>  verbs: [&quot;get&quot;, &quot;watch&quot;, &quot;list&quot;]<br>---<br>kind: RoleBinding<br>apiVersion: rbac.authorization.k8s.io/v1<br>metadata:<br>  name: read-pods<br>  namespace: example<br>subjects:<br>- kind: Group<br>  name: developers<br>  apiGroup: rbac.authorization.k8s.io<br>roleRef:<br>  kind: Role<br>  name: pod-reader<br>  apiGroup: rbac.authorization.k8s.io</pre><p>This example defines a Role named pod-reader that grants read-only access to pods in the example namespace. A RoleBinding named read-pods is also defined that assigning this role to a group called developers.</p><h3>🔒 Enable Network Policies</h3><p>Network policies are another Kubernetes feature that can help you secure your deployments. They allow you to define rules for traffic flow within your cluster, which can be used to prevent unauthorized access to sensitive resources. For example, you might have a database that should only be accessible from a specific set of pods. You can use network policies to restrict access to that database to only those pods and block all other traffic.</p><p>Let’s look into an example:</p><pre>kind: NetworkPolicy<br>apiVersion: networking.k8s.io/v1<br>metadata:<br>  name: allow-db-access<br>spec:<br>  podSelector:<br>    matchLabels:<br>      app: database<br>  ingress:<br>  - from:<br>    - podSelector:<br>        matchLabels:<br>          app: frontend<br>    ports:<br>    - protocol: TCP<br>      port: 3306</pre><p>This example defines a NetworkPolicy named allow-db-access that only allows traffic from pods labeled app: frontend to access the database pod labeled app: database on port 3306.</p><h3>🔒 Use Pod Security Policies (PSP)</h3><p>Pod Security Policies are a way to enforce security standards on the pods running in your Kubernetes cluster. They allow you to define a set of security standards that all pods must adhere to, such as requiring specific Linux capabilities or preventing privileged containers. PSPs can help you prevent attackers from gaining elevated privileges within your cluster and reduce the impact of any potential vulnerabilities.</p><p>Let’s look into an example:</p><pre>apiVersion: policy/v1beta1<br>kind: PodSecurityPolicy<br>metadata:<br>  name: restrict-privileged-containers<br>spec:<br>  privileged: false<br>  seLinux:<br>    rule: RunAsAny<br>  runAsUser:<br>    rule: MustRunAsNonRoot<br>  fsGroup:<br>    rule: RunAsAny<br>  volumes:<br>  - &#39;*&#39;</pre><p>This example defines a PodSecurityPolicy named restrict-privileged-containers that requires pods to run as a non-root user and prohibits the use of privileged containers.</p><h3>🔒 Keep Your Kubernetes Version Up-to-date</h3><p>Kubernetes releases regular updates to address security vulnerabilities and improve the platform’s security. It’s essential to keep your Kubernetes cluster up-to-date with the latest security patches and updates. Failing to do so can leave your cluster vulnerable to known exploits and attacks. Make sure to subscribe to security announcements and patch your cluster as soon as possible when updates are available.</p><h3>🔒 Monitor Your Kubernetes Cluster</h3><p>Monitoring your Kubernetes cluster is essential to detect and responding to security incidents. Kubernetes provides various monitoring tools, such as Prometheus, which can be used to track metrics and logs from your cluster. You can also use Kubernetes audit logs to monitor user activity and detect suspicious behaviour. By monitoring your Kubernetes cluster, you can detect security incidents early and respond quickly before they cause significant damage.</p><h3>🔒 Use Container Image Scanning</h3><p>When deploying containers in your Kubernetes cluster, it’s essential to ensure that the container images are free of vulnerabilities. You can use container image scanning tools like Clair or Trivy to scan your container images for known vulnerabilities. By scanning your container images, you can prevent attackers from exploiting known vulnerabilities in your applications.</p><p>Here’s an example of using the trivy tool to scan a container image:</p><pre>$ trivy image alpine:3.14</pre><p>This command scans the alpine:3.14 image for known vulnerabilities and reports any findings. You can integrate this command into your CI/CD pipeline to ensure that container images used in your Kubernetes deployment are free of vulnerabilities.</p><p>In conclusion, Kubernetes security is crucial for protecting your LinkedIn applications from potential attacks. By implementing these Kubernetes security best practices, you can reduce the risk of security incidents and maintain a secure Kubernetes deployment. Remember to keep your Kubernetes cluster up-to-date, use RBAC, enable network policies, use Pod Security Policies, monitor your Kubernetes cluster, and use container image scanning to ensure the security of your Kubernetes deployments.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4830d9b156d9" width="1" height="1" alt=""><hr><p><a href="https://blog.devops.dev/secure-your-kubernetes-cluster-learn-the-essential-best-practices-for-keeping-your-deployment-safe-4830d9b156d9">Secure Your Kubernetes Cluster: Learn the Essential Best Practices for Keeping Your Deployment Safe…</a> was originally published in <a href="https://blog.devops.dev/">DevOps.dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering EKS IRSA with Terraform: A Comprehensive Guide to Granular AWS Resource Access Control…]]></title>
            <link>https://blog.devops.dev/mastering-eks-irsa-with-terraform-a-comprehensive-guide-to-granular-aws-resource-access-control-9bf657901a09?source=rss-e25f2a184621------2</link>
            <guid isPermaLink="false">https://medium.com/p/9bf657901a09</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[ek]]></category>
            <category><![CDATA[iam-roles]]></category>
            <category><![CDATA[kubenetes]]></category>
            <dc:creator><![CDATA[Arun Singh Sisodiya]]></dc:creator>
            <pubDate>Wed, 22 Feb 2023 15:11:56 GMT</pubDate>
            <atom:updated>2023-03-01T19:05:56.853Z</atom:updated>
            <content:encoded><![CDATA[<h3>🚀 Secure Your Kubernetes with EKS IRSA and Terraform: A Step-by-Step Guide. 💻🔒</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fYbk4IU002E9cpVxKQh3WQ.png" /></figure><h3>Prerequisites</h3><ul><li>An AWS account with permissions to create EKS clusters and IAM roles.</li><li>The <a href="https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html">AWS CLI</a> and <a href="https://kubernetes.io/docs/tasks/tools/#kubectl">kubectl</a> are installed on your local machine.</li><li>A running EKS cluster with at least one node group. You can use <a href="https://eksctl.io/">eksctl</a> or <a href="https://registry.terraform.io/modules/terraform-aws-modules/eks/aws/latest">terraform eks module</a> to spin up the EKS cluster</li></ul><p>Let us begin by describing the steps we must follow to implement IRSA on the EKS cluster.</p><h4>Step 1: Create an IAM policy</h4><p>The first step is to create an IAM policy that grants the necessary permissions to your EKS pods. You can use the following example policy as a starting point:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*txiKz8uOKt6bcqdptFHyzg.png" /><figcaption>IAM policy for s3 read-only permissions</figcaption></figure><p>This policy allows your pods to read and list objects in all S3 buckets in your AWS account. Replace the resource ARN with the ARN of the specific resource you want to grant access to.</p><h4>Step 2: Create an IAM role</h4><p>Next, create an IAM role that your EKS pods can assume to gain the permissions defined in the IAM policy. You can use the following Terraform code to create a new IAM role:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EZLGRb0bF3HUP06cP5-hCw.png" /><figcaption>IAM role for IRSA to assume-role</figcaption></figure><p>Replace “<strong>eks-s3-access</strong>” with a name of your choice.</p><h4>Step 3: Attach the IAM policy to the IAM role</h4><p>Once you’ve created the IAM role, attach the IAM policy you created in step 1 to the role using the following Terraform code:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*00ZR0kv0EOp5sPSpWZb5CA.png" /><figcaption>IAM policy attachment for s3 read-only access</figcaption></figure><p>Replace “<strong>aws_iam_policy.s3_access_policy.arn</strong>” with the ARN of the IAM policy you created in step 1, and “<strong>aws_iam_role.s3_access_role.name</strong>” with the name of the IAM role you created in step 2.</p><h4>Step 4: Create a Kubernetes service account</h4><p>Next, create a Kubernetes service account that you can associate with the IAM role you created in step 2. Use the following Terraform code to create a new service account:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sPohdXPsME8NR5-XqmALpA.png" /><figcaption>Kubernetes service account for s3 access from the cluster</figcaption></figure><blockquote>Note: If you want to create Kubernetes service account using terraform, you must use <a href="https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs">Kubernetes Provider</a> by terraform.</blockquote><h4>Step 5: Annotate the service account with the IAM role ARN</h4><p>To associate the Kubernetes service account with the IAM role you created in step 2, annotate the service account with the ARN of the role using the following Terraform code:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WGY_oqAAhiGogv0heufzoA.png" /><figcaption>Kubernetes Service account annotation for EKS role</figcaption></figure><p>Replace “<strong>aws_iam_role.s3_access_role.arn</strong>” with the ARN of the IAM role you created in step 2, and “<strong>kubernetes_service_account.s3_access_sa.metadata.0.name</strong>” with the name of the Kubernetes service account you created in step 4.</p><h4>Step 6: Deploy a sample pod</h4><p>Finally, deploy a sample pod that uses the IAM role you created in step 2 to access an AWS resource. Use the following Terraform code to deploy a sample pod:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2tOgZhvfIn4y1jGvIwZiuQ.png" /><figcaption>Kubernetes pod definition to use the ServiceAccount name</figcaption></figure><p>This deploys a sample Nginx container that mounts the AWS credentials from the Kubernetes service account and sets the AWS region environment variable. Replace “<strong>kubernetes_service_account.s3_access_sa.metadata.0.name</strong>” with the name of the Kubernetes service account you created in step 4.</p><p>That’s it! Once you apply these Terraform configurations, you should have a Kubernetes pod that has access to the AWS resource specified in the IAM policy you created in step 1, using the IAM role you created in step 2.</p><h3>Conclusion</h3><p>In conclusion, EKS IRSA is a powerful feature that allows you to achieve fine-grained access control to AWS resources on Kubernetes clusters. With Terraform, you can easily automate the process of creating and managing IAM roles, Kubernetes service accounts, and their association, allowing you to streamline your infrastructure management workflow. By following this step-by-step guide, you can implement EKS IRSA with Terraform and take advantage of its benefits to achieve greater security and efficiency in your Kubernetes environment.</p><p>#EKS #IRSA #Terraform #Kubernetes #AWS #InfrastructureAsCode #AccessControl #IAM #CloudSecurity #Automation #DevOps</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9bf657901a09" width="1" height="1" alt=""><hr><p><a href="https://blog.devops.dev/mastering-eks-irsa-with-terraform-a-comprehensive-guide-to-granular-aws-resource-access-control-9bf657901a09">Mastering EKS IRSA with Terraform: A Comprehensive Guide to Granular AWS Resource Access Control…</a> was originally published in <a href="https://blog.devops.dev/">DevOps.dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering Terraform Functions: A Guide with Examples ‍]]></title>
            <link>https://blog.devops.dev/mastering-terraform-functions-a-guide-with-examples-4fe363459797?source=rss-e25f2a184621------2</link>
            <guid isPermaLink="false">https://medium.com/p/4fe363459797</guid>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[terraforming]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[infrastructure-as-code]]></category>
            <category><![CDATA[terraform]]></category>
            <dc:creator><![CDATA[Arun Singh Sisodiya]]></dc:creator>
            <pubDate>Thu, 16 Feb 2023 16:53:49 GMT</pubDate>
            <atom:updated>2023-03-01T19:08:24.150Z</atom:updated>
            <content:encoded><![CDATA[<p>Discover the power of Terraform functions and learn how to use them to simplify your infrastructure as code. From filesystem functions to collection and encoding functions, we cover it all with examples and images.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y0HZCbscmEJoWtG9LMaueA.png" /></figure><h3>Introduction</h3><p>In this blog post, we’ll explore the world of Terraform functions and how they can help you write more concise and powerful infrastructure as code. With Terraform functions, you can perform advanced data manipulation, simplify variable interpolation, and work with files and directories. We’ll show you how to use Terraform functions in your code, with examples and images to guide you.</p><h3>What are Terraform functions?</h3><p>👋 Hey there, fellow Terraform users! Are you looking to level up your infrastructure-as-code game? Well, have you considered using Terraform functions? 🤔</p><p>Terraform functions allow you to perform various operations on your Terraform code. They can generate dynamic values, manipulate strings, and perform mathematical calculations, among other things. This blog post will cover some of the most common Terraform functions and how you can use them in your code.</p><p>Terraform functions are used in the expression of an argument and return a value of a specified type. The built-in functions can be generalized using the syntax below:</p><pre>&lt;function_name&gt;(arg 1, arg 2)</pre><p>The number and type of arguments accepted by Terraform functions are predefined. The Terraform language includes several built-in functions that you can call from within expressions to transform and combine values.</p><h3>🌟 Interpolation Functions 🌟</h3><p>Interpolation functions are used to insert a value into a string. They can be used in resource configuration blocks, data source configuration blocks, and other parts of your Terraform code.</p><p>Let’s see some examples and do some hands-on:</p><ul><li><a href="https://developer.hashicorp.com/terraform/language/functions/format"><strong><em>format()</em></strong></a><strong><em>: </em></strong>This function is used to format a string. It takes one or more arguments and returns a formatted string.</li></ul><pre>Syntax→ fomrat(spec, values...)<br><br>E.g.<br>&gt; format(&quot;Hello, %s!&quot;, &quot;Terraform&quot;)<br>Hello Terraform<br>&gt; format(&quot;There are %d lights&quot;, 4)<br>There are 4 lights</pre><ul><li><a href="https://developer.hashicorp.com/terraform/language/functions/join"><strong><em>join()</em></strong></a><strong><em>: </em></strong>This function is used to concatenate a list of strings. It takes two arguments: a separator and a list of strings.</li></ul><pre>Syntax→ join(separator, list)<br><br>E.g.<br>&gt; join(&quot;, &quot;, [&quot;foo&quot;, &quot;bar&quot;, &quot;baz&quot;])<br>foo, bar, baz<br>&gt; join(&quot;, &quot;, [&quot;foo&quot;])<br>foo</pre><ul><li><a href="https://developer.hashicorp.com/terraform/language/functions/lookup"><strong><em>lookup()</em></strong></a><strong><em>: </em></strong>This function is used to look up a value in a map. It takes two arguments: the map and the key.</li></ul><pre>Syntax→ lookup(map, key, default)<br><br>E.g.<br>&gt; lookup({a=&quot;ay&quot;, b=&quot;bee&quot;}, &quot;a&quot;, &quot;what?&quot;)<br>ay<br>&gt; lookup({a=&quot;ay&quot;, b=&quot;bee&quot;}, &quot;c&quot;, &quot;what?&quot;)<br>what?</pre><h3>🌟 Numeric Functions 🌟</h3><p>Numeric functions are used to perform mathematical calculations. They can be used in resource configuration blocks, data source configuration blocks, and other parts of your Terraform code.</p><p>Let’s see some examples and do some hands-on:</p><ul><li><a href="https://developer.hashicorp.com/terraform/language/functions/abs"><strong><em>abs()</em></strong></a><strong><em>: </em></strong>abs returns the absolute value of the given number.</li></ul><pre>&gt; abs(23)<br>23<br>&gt; abs(0)<br>0<br>&gt; abs(-12.4)<br>12.4</pre><ul><li><a href="https://developer.hashicorp.com/terraform/language/functions/ceil"><strong><em>ceil()</em></strong></a><strong><em>: </em></strong>ceil returns the closest whole number that is greater than or equal to the given value, which may be a fraction.</li></ul><pre>&gt; ceil(5)<br>5<br>&gt; ceil(5.1)<br>6</pre><ul><li><a href="https://developer.hashicorp.com/terraform/language/functions/floor"><strong><em>floor()</em></strong></a><strong><em>: </em></strong>floor returns the closest whole number that is less than or equal to the given value, which may be a fraction.</li></ul><pre>&gt; floor(5)<br>5<br>&gt; floor(4.9)<br>4</pre><ul><li><a href="https://developer.hashicorp.com/terraform/language/functions/log"><strong><em>log()</em></strong></a><strong><em>: </em></strong>log returns the logarithm of a given number in a given base.</li></ul><pre>Syntax→ log(number, base)<br><br>E.g.<br>&gt; log(50, 10)<br>1.6989700043360185<br>&gt; log(16, 2)<br>4</pre><ul><li><a href="https://developer.hashicorp.com/terraform/language/functions/max"><strong><em>max()</em></strong></a><strong><em>: </em></strong>max takes one or more numbers and returns the greatest number from the set. If the numbers are in a list or set value, use ... to expand the collection to individual arguments:</li></ul><pre>&gt; max(12, 54, 3)<br>54<br>&gt; max([12, 54, 3]...)<br>54</pre><ul><li><a href="https://developer.hashicorp.com/terraform/language/functions/min"><strong><em>min()</em></strong></a><strong><em>: </em></strong>min takes one or more numbers and returns the smallest number from the set.If the numbers are in a list or set value, use ... to expand the collection to individual arguments:</li></ul><pre>&gt; min(12, 54, 3)<br>3<br>&gt; min([12, 54, 3]...)<br>3</pre><ul><li><a href="https://developer.hashicorp.com/terraform/language/functions/pow"><strong><em>pow()</em></strong></a><strong><em>: </em></strong>pow calculates an exponent, by raising its first argument to the power of the second argument.</li></ul><pre>&gt; pow(3, 2)<br>9<br>&gt; pow(4, 0)<br>1</pre><ul><li><a href="https://developer.hashicorp.com/terraform/language/functions/signum"><strong><em>signum()</em></strong></a><strong><em>: </em></strong>signum determines the sign of a number, returning a number between -1 and 1 to represent the sign.</li></ul><pre>&gt; signum(-13)<br>-1<br>&gt; signum(0)<br>0<br>&gt; signum(344)<br>1</pre><ul><li><a href="https://developer.hashicorp.com/terraform/language/functions/parseint"><strong><em>parseint()</em></strong></a><strong><em>: </em></strong>parseint parses the given string as a representation of an integer in the specified base and returns the resulting number. The base must be between 2 and 62 inclusive. All bases use the arabic numerals 0 through 9 first. Bases between 11 and 36 inclusive use case-insensitive latin letters to represent higher unit values. Bases 37 and higher use lowercase latin letters and then uppercase latin letters. If the given string contains any non-digit characters or digit characters that are too large for the given base then parseint will produce an error.</li></ul><pre>&gt; parseint(&quot;100&quot;, 10)<br>100<br><br>&gt; parseint(&quot;FF&quot;, 16)<br>255<br><br>&gt; parseint(&quot;-10&quot;, 16)<br>-16<br><br>&gt; parseint(&quot;1011111011101111&quot;, 2)<br>48879<br><br>&gt; parseint(&quot;aA&quot;, 62)<br>656<br><br>&gt; parseint(&quot;12&quot;, 2)<br><br>Error: Invalid function argument<br><br>Invalid value for &quot;number&quot; parameter: cannot parse &quot;12&quot; as a base 2 integer.</pre><h3>🌟 String Functions 🌟</h3><p>String functions are used to manipulate strings. They can be used in resource configuration blocks, data source configuration blocks, and other parts of your Terraform code.</p><p>Let’s see some examples and do some hands-on:</p><ul><li><a href="https://developer.hashicorp.com/terraform/language/functions/lower"><strong><em>lower()</em></strong></a><strong><em>: </em></strong>lower converts all cased letters in the given string to lowercase.</li></ul><pre>&gt; lower(&quot;HELLO&quot;)<br>hello<br>&gt; lower(&quot;АЛЛО!&quot;)<br>алло!</pre><ul><li><a href="https://developer.hashicorp.com/terraform/language/functions/upper"><strong><em>upper()</em></strong></a><strong><em>: </em></strong>upper converts all cased letters in the given string to uppercase.</li></ul><pre>&gt; upper(&quot;hello&quot;)<br>HELLO<br>&gt; upper(&quot;алло!&quot;)<br>АЛЛО!</pre><ul><li><a href="https://developer.hashicorp.com/terraform/language/functions/replace"><strong><em>replace()</em></strong></a><strong><em>: </em></strong>replace searches a given string for another given substring, and replaces each occurrence with a given replacement string.</li></ul><pre>Syntax→ replace(string, substring, replacement)<br><br>E.g.<br>&gt; replace(&quot;1 + 2 + 3&quot;, &quot;+&quot;, &quot;-&quot;)<br>1 - 2 - 3<br><br>&gt; replace(&quot;hello world&quot;, &quot;/w.*d/&quot;, &quot;everybody&quot;)<br>hello everybody</pre><ul><li><a href="https://developer.hashicorp.com/terraform/language/functions/trim"><strong><em>trim()</em></strong></a><strong><em>: </em></strong>trim removes the specified set of characters from the start and end of the given string.</li></ul><pre>Syntax→ trim(string, str_character_set)<br><br>E.g.<br>&gt; trim(&quot;?!hello?!&quot;, &quot;!?&quot;)<br>&quot;hello&quot;<br><br>&gt; trim(&quot;foobar&quot;, &quot;far&quot;)<br>&quot;oob&quot;<br><br>&gt; trim(&quot;   hello! world.!  &quot;, &quot;! &quot;)<br>&quot;hello! world.&quot;</pre><blockquote>There are many more terraform functions. You can find the details here: <a href="https://developer.hashicorp.com/terraform/language/functions">https://developer.hashicorp.com/terraform/language/functions</a></blockquote><h3>🌟 Conclusion 🌟</h3><p>Terraform functions can help you write more efficient and dynamic infrastructure code. By using these functions, you can easily manipulate strings, perform mathematical calculations, and generate dynamic values. So give them a try and see how they can improve your Terraform workflows! 🔥</p><p>#Terraform #Functions #InfrastructureAsCode #DevOps #CloudComputing</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4fe363459797" width="1" height="1" alt=""><hr><p><a href="https://blog.devops.dev/mastering-terraform-functions-a-guide-with-examples-4fe363459797">Mastering Terraform Functions: A Guide with Examples 👨‍💻</a> was originally published in <a href="https://blog.devops.dev/">DevOps.dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Automate Your Node.js Testing and Deployment with GitHub Actions: A Practical Guide ‍]]></title>
            <link>https://blog.devops.dev/automate-your-node-js-testing-and-deployment-with-github-actions-a-practical-guide-17d1a1a06c05?source=rss-e25f2a184621------2</link>
            <guid isPermaLink="false">https://medium.com/p/17d1a1a06c05</guid>
            <category><![CDATA[github-actions]]></category>
            <category><![CDATA[cicd]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <dc:creator><![CDATA[Arun Singh Sisodiya]]></dc:creator>
            <pubDate>Tue, 14 Feb 2023 09:48:44 GMT</pubDate>
            <atom:updated>2023-02-25T18:49:42.919Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P_SiEWmzvcRB-y2D1Py1aA.jpeg" /><figcaption>GitHub Actions</figcaption></figure><p>GitHub Actions is an effective tool that enables coders to mechanize their workflows and refine their development procedures. By utilizing GitHub Actions, coders can automate processes such as constructing, evaluating and dispatching their code, leaving them with more time to concentrate on the actual development work. In this post, we will scrutinize what GitHub Actions are, how to get them up and running, and a few best practices to help you to get going.</p><h3><strong>What are GitHub Actions?</strong></h3><p>GitHub Actions is an integrated workflow automation tool within GitHub that allows developers to automate various parts of the development process such as running tests, building, deploying applications, and sending out notifications. It is composed of two main components: workflows and actions.</p><p>A workflow is an arrangement of automated processes which are initiated when a certain incident takes place such as a commit to a particular branch, a request for merging, or the launch of a new version. Workflows are specified in a YAML document which defines the phases to be carried out when the workflow is activated.</p><p>Reusable pieces of code, known as actions, can be used in workflows. Programmers can generate these actions and make them available in the GitHub Marketplace, granting other developers access to utilize them in their own workflows. These actions can be employed to execute an array of tasks, such as constructing and testing code, deploying applications, and issuing notifications.</p><h3>Getting started with GitHub Actions</h3><p>In order to get going with GitHub Actions, a GitHub account and a repository must be obtained. When you have set up your repository, it is possible to craft a workflow by specifying a YAML file in the .github/workflows directory of your repository.</p><p>Here’s an example of a simple workflow that runs a set of tests whenever a new commit is pushed to the master branch:</p><pre>name: Test<br>on:<br>  push:<br>    branches: [ master ]<br>jobs:<br>  build:<br>    runs-on: ubuntu-latest<br>    steps:<br>    - uses: actions/checkout@v2<br>    - name: Run tests<br>      run: npm test</pre><p>This workflow has a single job called “build” that runs on the latest version of Ubuntu. The job consists of two steps: the first step checks out the code from the repository, and the second step runs a set of tests using the npm test command.</p><p>Let’s take a practical example of using GitHub Actions to automate the testing and deployment of a Node.js application</p><p>Suppose you have a Node.js application that you want to deploy to a server every time you push changes to the master branch on GitHub. You also want to run a set of tests on the application to make sure everything is working correctly before deploying it.</p><p>To accomplish this, you can create a GitHub Actions workflow that runs the tests and deploys the application whenever changes are pushed to the master branch. Here&#39;s what the workflow might look like:</p><pre>name: Node.js CI/CD<br><br>on:<br>  push:<br>    branches:<br>      - master<br><br>jobs:<br>  test:<br>    runs-on: ubuntu-latest<br><br>    steps:<br>    - uses: actions/checkout@v2<br>    - name: Use Node.js 14.x<br>      uses: actions/setup-node@v1<br>      with:<br>        node-version: &#39;14.x&#39;<br>    - name: Install Dependencies<br>      run: npm install<br>    - name: Run Tests<br>      run: npm test<br><br>  deploy:<br>    needs: test<br>    runs-on: ubuntu-latest<br>    if: github.ref == &#39;refs/heads/master&#39;<br>    steps:<br>    - name: Checkout code<br>      uses: actions/checkout@v2<br>    - name: Use Node.js 14.x<br>      uses: actions/setup-node@v1<br>      with:<br>        node-version: &#39;14.x&#39;<br>    - name: Install Dependencies<br>      run: npm install<br>    - name: Build and Deploy<br>      run: npm run build &amp;&amp; npm run deploy<br>      env:<br>        SERVER_URL: ${{ secrets.SERVER_URL }}<br>        SERVER_USERNAME: ${{ secrets.SERVER_USERNAME }}<br>        SERVER_PASSWORD: ${{ secrets.SERVER_PASSWORD }}</pre><p>Let’s understand the above workflow and see how it works.</p><p>The <strong>master</strong> branch push event triggers the workflow. The job first checks the code, installs the dependencies, and runs the tests using the <strong>npm test</strong> command.</p><p>Once the test task is completed and all the tests are passed, Github Action will trigger the <strong>deploy</strong> task. This task will take the checkout of the codebase and install the dependencies with the <strong>npm install</strong> command. In the last step, we will build the application using the <strong>npm run build</strong> command and run the application using the <strong>npm run deploy</strong> command.</p><p>The <strong>deploy</strong> job uses environment variables to store sensitive information, such as server URLs and login credentials. This variable is defined as a secret in the GitHub repository and can be accessed using <strong>${{ secrets.SECRET_NAME }} </strong>syntax.</p><p>Using this workflow, you can automate the testing and deployment of your Node.js application every time you push changes to the <strong>master</strong> branch on GitHub. This can save you time and ensure that your code is consistently tested and deployed in a consistent and reliable manner.</p><h3>Best practices for using GitHub Actions</h3><p>When making use of GitHub Actions, it’s important to take into account the following guidelines for optimal results. Keep your workflows simple and focused. Each workflow should have a single, specific purpose, such as building and testing code or deploying an application.</p><ol><li>Use pre-built actions whenever possible. Many common tasks, such as running tests or deploying applications, can be automated using pre-built actions from the GitHub Marketplace.</li><li>Use environment variables to store secrets and sensitive information. Environment variables can be used to store secrets, such as API keys and authentication tokens, that should not be stored in your repository.</li><li>Use the matrix strategy to run tests across different configurations. The matrix strategy allows you to run tests across multiple configurations, such as different versions of a programming language or different operating systems.</li><li>Keep your workflows organized and easy to understand. Use descriptive names for your jobs and steps, and include comments and documentation to make your workflows easier to understand for other developers.</li></ol><h3>Conclusion</h3><p>GitHub Actions is an advantageous resource that can facilitate the automation of your software development approach and simplify your development process. Utilizing best practices and making use of pre-made actions can help you conserve time and put your emphasis on the primary objective: creating exceptional software. These instructions and a bit of practice will have you making use of GitHub Actions quickly.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=17d1a1a06c05" width="1" height="1" alt=""><hr><p><a href="https://blog.devops.dev/automate-your-node-js-testing-and-deployment-with-github-actions-a-practical-guide-17d1a1a06c05">🚀 Automate Your Node.js Testing and Deployment with GitHub Actions: A Practical Guide 👨‍💻</a> was originally published in <a href="https://blog.devops.dev/">DevOps.dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kyverno — A policy manager for Kubernetes]]></title>
            <link>https://arun-sisodiya.medium.com/kyverno-a-policy-manager-for-kubernetes-286f6e082062?source=rss-e25f2a184621------2</link>
            <guid isPermaLink="false">https://medium.com/p/286f6e082062</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[policy-management]]></category>
            <category><![CDATA[policy-as-code]]></category>
            <category><![CDATA[kyverno]]></category>
            <category><![CDATA[policy]]></category>
            <dc:creator><![CDATA[Arun Singh Sisodiya]]></dc:creator>
            <pubDate>Wed, 15 Sep 2021 21:47:28 GMT</pubDate>
            <atom:updated>2021-09-16T14:24:56.128Z</atom:updated>
            <content:encoded><![CDATA[<h3>Kyverno — A Kubernetes native policy manager (Policy as Code)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*R3cXB6SVWft1rkBS1Fwcqw.png" /><figcaption>Kyverno logo</figcaption></figure><h3>Problem Statement</h3><p>While working with the Kubernetes cluster, there are many problem statements such as -</p><ul><li>If one of the applications is having really <strong>high CPU &amp; memory utilization</strong>, how the other applications will run?</li><li>A user is changing the <strong>default network policies </strong>which can result in open gates to the attackers. How can we prevent that?</li><li>Developers are not using the <strong>best practices </strong>for the applications such as using the <strong><em>latest</em></strong><em> </em>tags for the docker images.</li><li>Checking if we are putting the proper configuration to the k8s resources according to the need to project.</li></ul><blockquote>How can we tackle such situations? How can we put policies to the cluster? 🤔</blockquote><h3>Solution</h3><p>To handle such situations, we can enforce a policy management solution to the Kubernetes cluster that can handle many problems related to policies.</p><p>There are many policy management solutions are available such as <a href="https://kubernetes.io/blog/2019/08/06/opa-gatekeeper-policy-and-governance-for-kubernetes/"><strong><em>OPA Gatekeeper</em></strong></a><strong><em> </em></strong>but there is a cloud-native solution available for k8s i.e. <a href="https://kyverno.io/"><strong><em>Kyverno</em></strong></a><strong><em> (</em></strong><a href="https://kyverno.io/">https://kyverno.io/</a><strong><em>)</em></strong></p><h3>Kyverno Overview</h3><p>Kyverno is a policy engine designed for Kubernetes. With Kyverno, policies are managed as Kubernetes resources and no new language is required to write policies. This allows using familiar tools such as <em>kubectl</em>, <em>git</em>, and <em>kustomize</em> to manage policies.</p><p>Kyverno policies can perform the following operations on generated Kubernetes resources-</p><ul><li>Validation</li><li>Mutation</li><li>Generation</li></ul><p>The Kyverno CLI can be used to test policies and validate resources as part of a CI/CD pipeline.</p><blockquote>For more reference — <a href="https://kyverno.io/docs/introduction/">https://kyverno.io/docs/introduction/</a></blockquote><h3>Kyverno Installation</h3><h4>Prerequisites</h4><p>To install Kyverno, we need a functional Kubernetes cluster. For this purpose, we can either use local k8s clusters such as <strong><em>Minikube, Kind</em></strong><em> </em>etc. or any cluster running on the cloud.</p><p>Kyverno can be installed using the installation methods mentioned at <a href="https://kyverno.io/docs/installation/">https://kyverno.io/docs/installation/</a></p><h4>Helm Installation</h4><p>In order o install kyverno using helm, perform the following steps -</p><ul><li>Add the Kyverno helm repository</li></ul><pre>helm repo add kyverno https://kyverno.github.io/kyverno/</pre><ul><li>Scan the helm for the latest charts for Kyverno</li></ul><pre>helm repo update</pre><ul><li>For the kyverno version ≥ 1.4.2, we need to add <strong><em>kyverno-crds</em></strong> separately before installing the kyverno</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c3dc6e1ec7ea58f471f29f6a10bafee5/href">https://medium.com/media/c3dc6e1ec7ea58f471f29f6a10bafee5/href</a></iframe><h4>YAML Installation</h4><p>If you want to install the kyverno without Helm directly using manifest, we can deploy the latest release using the following command</p><pre>kubectl create -f <a href="https://raw.githubusercontent.com/kyverno/kyverno/main/definitions/release/install.yaml">https://raw.githubusercontent.com/kyverno/kyverno/main/definitions/release/install.yaml</a></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eZFX6Ai7xeveqIMsT8ESQA.gif" /><figcaption>kyverno installation</figcaption></figure><h3>Kyverno Operations</h3><p>Let&#39;s have a deeper look into the operations that can be performed using Kyverno.</p><h4>Validation</h4><p>Using validation, we can tackle the situation such as high CPU, memory usage or avoid altering default network policies etc. We can apply the kyverno policy to do such validation.</p><p>Here is the sample ClusterPolicy definition to avoid creating k8s resource, if resource definitions are not defined -</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4aeb5dea1476bcf4e22c54c1ac297797/href">https://medium.com/media/4aeb5dea1476bcf4e22c54c1ac297797/href</a></iframe><p>Once this policy will be applied, no one cannot create any Kubernetes resources without the resource definitions for the containers. This will avoid the overutilization of a single application.</p><blockquote>More kyverno validation policies can be found here — <a href="https://kyverno.io/policies/?policytypes=validate">https://kyverno.io/policies/?policytypes=validate</a></blockquote><h4>Mutation</h4><p>Using mutation, we can modify the resources if a certain condition matches. For example, we can change the imagePullPolicy to Always if the image tag is latest.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/73d6376320690f946e7d6890420fa428/href">https://medium.com/media/73d6376320690f946e7d6890420fa428/href</a></iframe><blockquote>More kyverno mutation policies can be found here — <a href="https://kyverno.io/policies/?policytypes=mutate">https://kyverno.io/policies/?policytypes=mutate</a></blockquote><h4>Generation</h4><p>Using generation, we can generate new resources in the Kubernetes cluster, if a condition has been met.</p><p>For example, if a new namespace is created, we might want to create <em>ResourceQuota</em> and <em>LimitRange</em> resources for the namespace.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6bacce45fbd11d4a48822a7b380a2695/href">https://medium.com/media/6bacce45fbd11d4a48822a7b380a2695/href</a></iframe><p>This policy will generate the respective resources whenever a new <em>namespace </em>will be created.</p><blockquote>More kyverno generation policies can be found here — <a href="https://kyverno.io/policies/?policytypes=generate">https://kyverno.io/policies/?policytypes=generate</a></blockquote><h3>Hands-On</h3><p>Now we will see the kyverno in action. To check whether kyverno is installed properly, check all the resources in the <em>kyverno </em>namespace -</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Nus8i6eOV7mFIbrerId-NA.png" /><figcaption>Kyverno Verification</figcaption></figure><h4>Applying Policies</h4><p>Once kyverno installation has been verified, we will try to create some policies and apply them to the cluster.</p><p>Now, we want to apply a policy that will disallow resource creation in the <strong><em>default</em></strong> namespace.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ba914d8d7c4ae4cb20c288d1aff27d2e/href">https://medium.com/media/ba914d8d7c4ae4cb20c288d1aff27d2e/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4_rYCJ0NEHUEVCwTqgSRvg.gif" /></figure><h4>Resource Creation Testing</h4><p>Once the policies are applied to the cluster, we can proceed with the testing of the resource creation.</p><p>Since we have applied the policies to ensure that no resource can be created in the default namespace, so we will try to create a pod in the default namespace.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pVREA614Nmt54Gw_4nJbZQ.gif" /></figure><p>As the above error provides the information that we are not allowed to create the resource in the <em>default </em>namespace.</p><p>Now we will try to create the same pod in the <em>kyverno </em>namespace and see if that is working.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5Q5DMk0sYqrTSq5er4WLxA.gif" /></figure><p>As we can see that we can create the pod in any namespace other than the default one.</p><h4>Note</h4><blockquote>There is one important option while applying the policies — <strong>Validation Failure Action </strong>which provides the option how the user should be impacted if the policies are applied. If we set the value of this option to <strong>enforce </strong>then the end user will not able to create the resource while with the option <strong>audit, </strong>end user can create the resources but the warning will be logged into the events.<br><strong>Refernce</strong> — <a href="https://kyverno.io/docs/writing-policies/validate/#validation-failure-action">https://kyverno.io/docs/writing-policies/validate/#validation-failure-action</a></blockquote><h3>Conclusion</h3><p>As we can see that Kyverno is an awesome <strong><em>Policy as Code </em></strong>or <strong><em>Policy Management</em> </strong>tool<strong> </strong>that is native to Kubernetes. We can easily apply policies and best practices into our Kubernetes clusters. Since the policies are written in YAML, it is quite easy to write and come up with less complexity.</p><p><em>Thanks for reading. Hope you got good insights about Kyverno.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=286f6e082062" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>