<?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 Prashant Kumar on Medium]]></title>
        <description><![CDATA[Stories by Prashant Kumar on Medium]]></description>
        <link>https://medium.com/@prashantdhedha?source=rss-d6323665cda5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*PeGFuUL06SfIOVM-</url>
            <title>Stories by Prashant Kumar on Medium</title>
            <link>https://medium.com/@prashantdhedha?source=rss-d6323665cda5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 23:41:07 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@prashantdhedha/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[CentOS Stream 9 OpenStack Installation and Configuration Guide]]></title>
            <link>https://medium.com/@prashantdhedha/centos-stream-9-openstack-installation-and-configuration-guide-fcea580b88c7?source=rss-d6323665cda5------2</link>
            <guid isPermaLink="false">https://medium.com/p/fcea580b88c7</guid>
            <category><![CDATA[openstack]]></category>
            <category><![CDATA[packstack]]></category>
            <dc:creator><![CDATA[Prashant Kumar]]></dc:creator>
            <pubDate>Sun, 15 Sep 2024 06:53:21 GMT</pubDate>
            <atom:updated>2024-09-15T07:01:44.878Z</atom:updated>
            <content:encoded><![CDATA[<p>This document outlines installing and configuring OpenStack on CentOS Stream 9. Follow the instructions carefully to set up a working OpenStack all-in-one environment using the Packstack installer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UArjXVxFsv1v7Shoa7fCdw.png" /></figure><p>Packstack is an OpenStack deployment tool intended to <strong>install Proof of Concept small environments in a quick and easy way using the RDO distribution on a CentOS Stream hosts</strong>.</p><h3>Pre-requisites</h3><p><strong>Hardware:</strong></p><p>Machine with at least 16GB RAM, processors with hardware virtualization extensions, and at least one network adapter. As this is just a proof of Concept and not a Production setup you can go with 6GB RAM and 4 CPU cores.</p><p><strong>Locale Settings:</strong></p><p>Ensure your system has a valid hostname and the locale settings are configured correctly, especially if you are using a non-English locale.</p><p>Edit the `/etc/environment` file to include the following lines:</p><pre>LANG=en_US.utf-8<br>LC_ALL=en_US.utf-8</pre><p><strong>Hostname:</strong></p><p>Name the host with a fully qualified domain name rather than a short-form name to avoid DNS issues with Packstack.</p><pre>$ sudo hostnamectl set-hostname [hostname.domain]</pre><p>Replace `[hostname.domain]` with your desired hostname, such as `openstack.example.com`.</p><p><strong>Install Network-Scripts:</strong></p><p>Since CentOS 9 does not include the `network-scripts` package by default, you will need to install it manually.</p><pre># Step 1: Install Dependencies<br>$ sudo yum install initscripts-10.11.4-1.el9 ipcalc bc<br><br># Step 2: Install the Network-Scripts Package<br>$ sudo rpm -ivh https://blog.racknerd.com/wp-content/uploads/2022/12/network-scripts-10.11.4-1.el9.x86_64.rpm</pre><p><strong>Network Configuration:</strong></p><p>Configure your network interface by editing the appropriate network script. For example, if your network interface is `enp0s3`, you should edit or create the corresponding configuration file.</p><p>Step 1: Edit Network Interface Configuration</p><pre># Open or create the configuration file for your network interface:<br>$ sudo vi /etc/sysconfig/network-scripts/ifcfg-enp0s3<br><br># Add or modify the following lines:<br>DEVICE=enp0s3 # interface name<br>TYPE=Ethernet<br>PROXY_METHOD=none<br>BROWSER_ONLY=no<br>BOOTPROTO=none # disable dhcp<br>ONBOOT=yes # enable the interface automatically during system boot<br>NAME=enp0s3<br>IPADDR=192.168.29.11 # static IP<br>PREFIX=24<br>GATEWAY=192.168.29.1 <br>DNS1=8.8.8.8  # custom DNS (Google DNS server)<br>DEFROUTE=yes</pre><p>Make sure to replace the IP addresses and interface name according to your environment setup.</p><p>Step 2: Disable Firewall and NetworkManager</p><pre>$ sudo systemctl disable firewalld<br>$ sudo systemctl stop firewalld<br>$ sudo systemctl disable NetworkManager<br>$ sudo systemctl stop NetworkManager<br>$ sudo systemctl enable network<br>$ sudo systemctl start network</pre><h3>OpenStack Installation</h3><p>This section will guide you through the steps required to install OpenStack using the Packstack installer.</p><p><strong>Enable Software Repositories:</strong></p><p>On CentOS Stream 9, first you need to enable the crb. Then, the extras-common repository provides the RPM that enables the OpenStack repository. It is enabled by default on CentOS Stream 9, so you can simply install the RPM to set up the OpenStack repository:</p><pre>$ sudo dnf config-manager --enable crb<br>$ sudo dnf install -y centos-release-openstack-caracal<br>$ sudo dnf update -y</pre><p><strong>Install Packstack Installer:</strong></p><pre>$ sudo dnf install -y openstack-packstack</pre><p><strong>Disable SELinux Enforcing Mode:</strong></p><pre>$ sudo setenforce 0</pre><p><strong>Generate and Edit Packstack Answer File:</strong></p><p>Run the following command to generate a default answer file for Packstack:</p><pre>$ packstack --gen-answer-file packstack-answer-file.txt</pre><p>Edit the answer file (`packstack-answer-file.txt`) to suit your environment. Key configurations include:</p><pre># Specify &#39;y&#39; to install OpenStack Orchestration (heat).<br>CONFIG_HEAT_INSTALL=y<br><br># Set the password for the &#39;admin&#39; user.<br>CONFIG_KEYSTONE_ADMIN_PW=password<br><br># Specify the L2 agent for OpenStack Networking.<br>CONFIG_NEUTRON_L2_AGENT=openvswitch<br><br># Define the Open vSwitch bridge mappings.<br>CONFIG_NEUTRON_OVS_BRIDGE_MAPPINGS=extnet:br-ex</pre><p>If you are using a multinode cluster then you can specify or edit the IP of nodes in this file. As we are installing all in one cluster so we will leave it as default.</p><p><strong>Run Packstack with Answer File:</strong></p><p>Once the necessary changes are made, run the Packstack installer using the updated answer file:</p><pre>$ sudo packstack --answer-file packstack-answer-file.txt</pre><p>The installation will take 20 to 30 mins depending upon your network and system.</p><p>Once the process is complete, you can log in to the OpenStack web interface Horizon by going to http://$YOURIP/dashboard. The user name is admin. The password can be found in the file keystonerc_admin in the /root directory of the control node.</p><h3>References</h3><ul><li><a href="https://docs.openstack.org/2024.1/#install-guides">OpenStack Docs: 2024.1</a></li><li><a href="https://www.rdoproject.org/deploy/packstack/">Packstack - An OpenStack distribution</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fcea580b88c7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploy Kubernetes cluster on AWS EC2 using Ansible and Terraform]]></title>
            <link>https://medium.com/@prashantdhedha/deploy-kubernetes-cluster-on-aws-ec2-using-ansible-and-terraform-3599d2929687?source=rss-d6323665cda5------2</link>
            <guid isPermaLink="false">https://medium.com/p/3599d2929687</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[ansible]]></category>
            <dc:creator><![CDATA[Prashant Kumar]]></dc:creator>
            <pubDate>Sun, 01 Sep 2024 18:07:01 GMT</pubDate>
            <atom:updated>2024-09-02T12:35:52.138Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article, we will walk through the steps to set up a Kubernetes cluster on AWS EC2 instances running RHEL 9 using two popular DevOps tools: Terraform for infrastructure as code and Ansible for configuration management.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_76N35AL8Qu8fRYc.jpeg" /></figure><h3>Prerequisites</h3><p>Before getting started, make sure you have these items configured or installed on your machine:</p><ul><li>AWS Credential on a local machine</li><li>Terraform Installed</li><li>Ansible Installed</li></ul><p><strong>GitHub Link: </strong><a href="https://github.com/Prashantd3dha/K8s-AWS-Ansible-Terraform.git">https://github.com/Prashantd3dha/K8s-AWS-Ansible-Terraform.git</a></p><h3>Motivation</h3><p>Learning Kubernetes can be challenging, especially when setting it up manually, which is often a time-consuming process. This is where tools like Ansible and Terraform come into play.</p><p>By automating the deployment of a Kubernetes cluster on AWS EC2, these tools save you valuable time and reduce the complexity involved in manual setup. They streamline the process, allowing you to focus more on learning and mastering Kubernetes itself rather than getting bogged down by repetitive configuration tasks.</p><p>Leveraging automation not only accelerates your learning curve but also provides a solid foundation for scaling and managing Kubernetes clusters effectively. Embrace these tools as they make your journey smoother and more efficient, leading to deeper insights and expertise in Kubernetes.</p><h3>The project Skeleton</h3><pre>├── ansible<br>├── terraform<br>├── .gitignore<br>└── host.ini</pre><h3>Terraform</h3><p>In this section, we will discuss implementing terraform for infrastructure provisioning.</p><p>We will create a VPC, VPC public subnet, internet gateway, route table, security group, and three EC2 instances inside our VPC.</p><p>Inside your project folder we will create the following skeleton:</p><pre>├── main.tf<br>├── modules<br>│   ├── aws<br>│       ├── vpc.tf<br>|       ├── vpc-subnet.tf<br>|       ├── security-group.tf<br>|       ├── igw.tf<br>|       ├── route-table.tf<br>|       ├── route-table-association.tf<br>|       ├── ec2.tf<br>│       ├── outputs.tf<br>│       └── variables.tf      <br>├── outputs.tf<br>└── variables.tf</pre><p>We will start with the main.tf, note that we will define the variables in the variables.tf file:</p><p>Here we specify that the AWS provider is required, with the source hashicorp/aws and a version constraint of ~&gt; 5.0. and specify the paths for shared credentials and configuration files using variables var.shared_credential and var.shared_config stored locally for authentication.</p><pre>terraform {<br>  required_providers {<br>    aws = {<br>      source  = &quot;hashicorp/aws&quot;<br>      version = &quot;~&gt; 5.0&quot;<br>    }<br>  }<br>}<br><br># Configure the AWS Provider<br>provider &quot;aws&quot; {<br>  region = &quot;ap-south-1&quot;<br>  shared_credentials_files = [var.shared_credential]<br>  shared_config_files      = [var.shared_config]<br>}</pre><p>In the variable.tf :</p><pre>variable &quot;shared_credential&quot; {<br>  type        = string<br>  description = &quot;AWS credtional file location&quot;<br>  default     = &quot;C:/Users/hp/.aws/credentials&quot;<br>}<br><br>variable &quot;shared_config&quot; {<br>  type        = string<br>  description = &quot;AWS config file location&quot;<br>  default     = &quot;C:/Users/hp/.aws/conf&quot;<br>}</pre><p><strong>Now we create resources inside modules/aws:</strong></p><p>We will create a Virtual Private Cloud (VPC) in AWS for isolated networking for your AWS resources, giving you control over IP address ranges, subnets, routing, and security settings. The aws_vpc resource creates a VPC with the CIDR block specified by var.vpc_cidr.</p><pre>vpc.tf<br><br>resource &quot;aws_vpc&quot; &quot;k8-vpc&quot; {<br>  cidr_block = var.vpc_cidr<br><br>  tags = {<br>    Name = &quot;k8-vpc&quot;<br>  }<br>}</pre><p>The aws_subnet resource defines the subnet with the CIDR block provided by var.vpc_subnet_cidr and places it in the availability zone specified by var.vpc_subnet_availability_zone.</p><pre>vpc-subnet.tf<br><br>resource &quot;aws_subnet&quot; &quot;k8-public-subnet&quot; {<br>  vpc_id     = aws_vpc.k8-vpc.id<br>  cidr_block = var.vpc_subnet_cidr<br>  availability_zone = var.vpc_subnet_availability_zone<br><br>  tags = {<br>    Name = &quot;k8-public-subnet&quot;<br>  }<br>}</pre><p>The aws_security_group resource allows all inbound and outbound traffic by setting wide-open rules for ease of installation. For detailed ports which need to be opened, you can refer to <a href="https://kubernetes.io/docs/reference/networking/ports-and-protocols/">Kubernetes official docs</a>.</p><pre>security-group.tf<br><br>resource &quot;aws_security_group&quot; &quot;k8-allow-all&quot; {<br>  name        = &quot;k8-allow-all&quot;<br>  description = &quot;Allow All inbound traffic and all outbound traffic&quot;<br>  vpc_id      = aws_vpc.k8-vpc.id<br><br>  tags = {<br>    Name = &quot;k8-allow-all&quot;<br>  }<br><br>    ingress {<br>    from_port        = 0<br>    to_port          = 0<br>    protocol         = &quot;-1&quot;<br>    cidr_blocks      = [&quot;0.0.0.0/0&quot;]<br>    ipv6_cidr_blocks = [&quot;::/0&quot;]<br>  }<br><br>  egress {<br>    from_port        = 0<br>    to_port          = 0<br>    protocol         = &quot;-1&quot;<br>    cidr_blocks      = [&quot;0.0.0.0/0&quot;]<br>    ipv6_cidr_blocks = [&quot;::/0&quot;]<br>  }<br>}</pre><p>aws_internet_gateway provide internet connectivity to the VPC.</p><pre>igw.tf<br><br>resource &quot;aws_internet_gateway&quot; &quot;k8-igw&quot; {<br>  vpc_id = aws_vpc.k8-vpc.id<br><br>  tags = {<br>    Name = &quot;k8-igw&quot;<br>  }<br>}</pre><p>The aws_route_table directs all outbound traffic (0.0.0.0/0) to the internet via the specified internet gateway (gateway_id).</p><pre>route-table.tf<br><br>resource &quot;aws_route_table&quot; &quot;k8-route-table&quot; {<br>  vpc_id = aws_vpc.k8-vpc.id<br><br>  route {<br>    cidr_block = &quot;0.0.0.0/0&quot;<br>    gateway_id = aws_internet_gateway.k8-igw.id<br>  }<br><br>  tags = {<br>    Name = &quot;k8-route-table&quot;<br>  }<br>}</pre><p>The aws_route_table_association resource named public-subnet-asso links the subnet (subnet_id) identified as k8-public-subnet to the route table (route_table_id) identified as k8-route-table.</p><pre>route-table-assosiation.tf<br><br>resource &quot;aws_route_table_association&quot; &quot;public-subnet-asso&quot; {<br>  subnet_id      = aws_subnet.k8-public-subnet.id<br>  route_table_id = aws_route_table.k8-route-table.id<br>}</pre><p>Now we will create ec2 instances in our VPC as mentioned below:</p><ul><li><strong>Master Node (</strong><strong>k8-master):</strong> Deploys a t2.medium instance with a specified AMI. It is assigned a private IP of 10.0.0.11, a public IP, and a 30 GB root volume. The instance is linked to a security group that allows all traffic and is tagged as &quot;k8-master.&quot;</li><li><strong>Worker Nodes (</strong><strong>k8-node):</strong> Deploys multiple t2.micro instances based on var.node_count. Each instance is assigned a unique private IP (10.0.0.12, 10.0.0.13, etc.), a public IP, and a 30 GB root volume. The instances are associated with the same security group as the master node and are tagged sequentially as &quot;k8-node1&quot;, &quot;k8-node2&quot;, etc.</li></ul><pre>ec2.tf<br><br>resource &quot;aws_instance&quot; &quot;k8-master&quot; {<br>  ami           = &quot;ami-022ce6f32988af5fa&quot;<br>  instance_type = &quot;t2.medium&quot;<br><br>  key_name = var.ssh_key_name<br>  subnet_id = aws_subnet.k8-public-subnet.id<br>  vpc_security_group_ids = [aws_security_group.k8-allow-all.id]<br>  private_ip = &quot;10.0.0.11&quot;<br>  associate_public_ip_address = true<br>  <br>  metadata_options{<br>    http_tokens = &quot;required&quot;<br>  }<br><br>  root_block_device{<br>    volume_size = 30<br>  } <br>  <br>  tags = {<br>    Name = &quot;k8-master&quot;<br>  }<br>}<br><br>resource &quot;aws_instance&quot; &quot;k8-node&quot; {<br>  ami           = &quot;ami-022ce6f32988af5fa&quot;<br>  instance_type = &quot;t2.micro&quot;<br>  count = var.node_count<br><br>  key_name = var.ssh_key_name<br>  subnet_id = aws_subnet.k8-public-subnet.id<br>  vpc_security_group_ids = [aws_security_group.k8-allow-all.id]<br>  private_ip = &quot;10.0.0.${12 + count.index}&quot;<br>  associate_public_ip_address = true<br>  <br>  metadata_options{<br>    http_tokens = &quot;required&quot;<br>  }<br><br>  root_block_device{<br>    volume_size = 30<br>  } <br>  <br>  tags = {<br>    Name = &quot;k8-node${1+count.index}&quot;<br>  }<br>}</pre><p>and we output the public IP and instance ID:</p><pre>output.tf<br><br>// master node output<br>output &quot;master_instance_id&quot; {<br>  description = &quot;ID of the EC2 instance&quot;<br>  value       = aws_instance.k8-master.id<br>}<br><br>output &quot;master_instance_public_ip&quot; {<br>  description = &quot;Public IP address of the EC2 instance&quot;<br>  value       = aws_instance.k8-master.public_ip<br>}<br><br><br>// worker node output<br>output &quot;worker_instance_id&quot; {<br>  description = &quot;ID of the EC2 instance&quot;<br>  value       = aws_instance.k8-node.*.id<br>}<br><br>output &quot;worker_instance_public_ip&quot; {<br>  description = &quot;Public IP address of the EC2 instance&quot;<br>  value       = aws_instance.k8-node.*.public_ip<br>}</pre><p>and variables file which are used above:</p><pre>variables.tf<br><br>variable &quot;vpc_cidr&quot; {<br>  type        = string<br>  description = &quot;Public VPC CIDR values&quot;<br>  default     = &quot;10.0.0.0/16&quot;<br>}<br><br>variable &quot;vpc_subnet_cidr&quot; {<br>  type        = string<br>  description = &quot;Public Subnet CIDR values&quot;<br>  default     = &quot;10.0.0.0/16&quot;<br>}<br><br>variable &quot;vpc_subnet_availability_zone&quot; {<br>  type        = string<br>  default     = &quot;ap-south-1b&quot;<br>}<br><br>variable &quot;ssh_key_name&quot; {<br>  type        = string<br>  description = &quot;ssh key name&quot;<br>  default     = &quot;redhat-key-aws&quot;<br>}<br><br>variable &quot;node_count&quot; {<br>  type        = number<br>  description = &quot;Worker node count&quot;<br>  default     = 2<br>}</pre><p>Edit main.tf file</p><ul><li><strong>module &quot;aws&quot;:</strong> Includes a module located in the ./modules/aws directory, which likely contains the configuration for deploying AWS resources.</li><li><strong>local_file &quot;ansible_hosts&quot;:</strong> Creates a local file named inventory.ini with content generated from a template file hosts.ini. The templatefile function is used to populate the template with the public IP addresses of the master and worker instances obtained from the aws module. This file will serve as an inventory for Ansible, listing the IP addresses of the deployed EC2 instances.</li></ul><pre>main.tf<br><br>module &quot;aws&quot; {<br>  source = &quot;./modules/aws&quot;<br>}<br><br>resource &quot;local_file&quot; &quot;ansible_hosts&quot; {<br>  filename = &quot;../inventory.ini&quot;<br>  content = templatefile(<br>    &quot;../hosts.ini&quot;,<br>    {<br>      master = module.aws.master_instance_public_ip<br>      worker = module.aws.worker_instance_public_ip<br>    }<br>  )<br>}</pre><p>template file:</p><pre>hosts.ini<br><br>[master]<br>k8-master ansible_host=${master} ansible_user=&quot;ec2-user&quot;<br><br>[worker]<br>%{ for index, addr in worker ~}<br>k8-node${1+index} ansible_host=${addr} ansible_user=&quot;ec2-user&quot;<br>%{ endfor ~}</pre><p>output file used:</p><pre>output &quot;master_instance_public_ip&quot; {<br>  description = &quot;ID of the EC2 instance&quot;<br>  value       = module.aws.master_instance_public_ip<br>}<br><br>output &quot;worker_instance_public_ip&quot; {<br>  description = &quot;Public IP address of the EC2 instance&quot;<br>  value       = module.aws.worker_instance_public_ip<br>}</pre><p>Use the following command to provision infrastructure:</p><pre>terraform init<br>terraform apply</pre><h3>Ansible</h3><p>We will be using Ansible to install the prerequisites, configure the cluster, and install Kubernetes.</p><p>Inside your project folder we will create the following skeleton:</p><pre>.<br>├── playbook.yml<br>├── inventory.ini<br>└── roles<br>    ├── containerd<br>    │   ├── README.md<br>    │   ├── defaults<br>    │   ├── files<br>    │   ├── handlers<br>    │   │   └── main.yml<br>    │   ├── meta<br>    │   ├── tasks<br>    │   │   └── main.yml<br>    │   ├── templates<br>    │   ├── tests<br>    │   └── vars<br>    ├── kubeadm<br>    │   ├── README.md<br>    │   ├── defaults<br>    │   ├── files<br>    │   ├── handlers<br>    │   │   └── main.yml<br>    │   ├── meta<br>    │   ├── tasks<br>    │   │   └── main.yml<br>    │   ├── templates<br>    │   ├── tests<br>    │   └── vars<br>    └── init-cluster<br>        ├── README.md<br>        ├── defaults<br>        ├── files<br>        ├── handlers<br>        ├── meta<br>        ├── tasks<br>        │   └── main.yml<br>        ├── templates<br>        ├── tests<br>        └── vars</pre><p>Inventory file created by Terraform:</p><pre>[master]<br>k8-master ansible_host=*.*.*.* ansible_user=&quot;ec2-user&quot; <br><br>[worker]<br>k8-node1 ansible_host=*.*.*.* ansible_user=&quot;ec2-user&quot; <br>k8-node2 ansible_host=*.*.*.* ansible_user=&quot;ec2-user&quot;</pre><p>The command ansible-galaxy init roles/containerd initializes a new Ansible role named containerd in the roles directory.</p><pre>---<br># Enable IPv4 packet forwarding <br>- name: Set sysctl parameters in k8s.conf<br>  copy:<br>    content: |<br>      net.ipv4.ip_forward = 1<br>    dest: /etc/sysctl.d/k8s.conf<br>    mode: &#39;0644&#39;<br>  notify: Reload sysctl<br><br># Install Containerd<br>- name: Install yum-utils<br>  yum:<br>    name: yum-utils<br>    state: present<br><br>- name: Add Docker repository<br>  shell: |<br>    yum-config-manager --add-repo https://download.docker.com/linux/rhel/docker-ce.repo<br>  args:<br>    creates: /etc/yum.repos.d/docker-ce.repo<br>    <br>- name: Install containerd<br>  yum:<br>    name: containerd<br>    state: present<br><br>- name: Start containerd<br>  service:<br>    name: containerd<br>    state: started<br>    enabled: yes<br><br># Configuring the systemd cgroup driver<br>- name: Generate default containerd config<br>  shell: containerd config default &gt; /etc/containerd/config.toml<br>  args:<br>    executable: /bin/bash<br><br>- name: Set SystemdCgroup to true in containerd config<br>  lineinfile:<br>    path: /etc/containerd/config.toml<br>    regexp: &#39;SystemdCgroup&#39;<br>    line: &#39;            SystemdCgroup = true&#39;<br>    backrefs: yes<br><br>- name: Restart containerd to apply changes<br>  service:<br>    name: containerd<br>    state: restarted</pre><pre>---<br># handlers file for containerd<br>- name: Reload sysctl<br>  command: sysctl --system</pre><p>The command ansible-galaxy init roles/kubeadm initializes a new Ansible role named kubeadm in the roles directory.</p><pre>---<br># Set SELinux in permissive mode<br>- name: Set SELinux in permissive mode<br>  command: setenforce 0<br>  when: ansible_selinux.status == &quot;enforcing&quot;<br>  notify: SELinus<br><br># Add K8 yum repositry<br>- name: Add Kubernetes repository<br>  yum_repository:<br>    name: kubernetes<br>    description: Kubernetes Repository<br>    baseurl: https://pkgs.k8s.io/core:/stable:/v1.31/rpm/<br>    enabled: 1<br>    gpgcheck: 1<br>    gpgkey: https://pkgs.k8s.io/core:/stable:/v1.31/rpm/repodata/repomd.xml.key<br>    exclude: kubelet,kubeadm,kubectl,cri-tools,kubernetes-cni<br><br># Install kubelet, kubeadm, and kubectl<br>- name: Install kubelet, kubeadm, and kubectl<br>  yum:<br>    name:<br>      - kubelet<br>      - kubeadm<br>      - kubectl<br>    state: present<br>    disable_excludes: kubernetes<br><br>- name: Enable and start kubelet service<br>  service:<br>    name: kubelet<br>    state: started<br>    enabled: yes</pre><pre>---<br># handlers file for roles/kubeadm<br>- name: SELinus<br>  command: sed -i &#39;s/^SELINUX=enforcing$/SELINUX=permissive/&#39; /etc/selinux/config</pre><p>The command ansible-galaxy init roles/init-cluster initializes a new Ansible role named init-cluster in the roles directory.</p><pre>---<br># Initializing Cluster with kubeadm<br>- name: Create cluster<br>  command: kubeadm init --pod-network-cidr=192.168.0.0/16<br>  register: init_cluster<br><br>- name: Create .kube directory<br>  file:<br>    path: &quot;/home/ec2-user/.kube&quot;<br>    state: directory<br>    mode: &#39;0755&#39;<br><br>- name: Copy Kubernetes admin config to .kube directory<br>  copy:<br>    src: /etc/kubernetes/admin.conf<br>    dest: &quot;/home/ec2-user/.kube/config&quot;<br>    owner: &quot;{{ ansible_user_id }}&quot;<br>    group: &quot;{{ ansible_user_gid }}&quot;<br>    mode: &#39;0755&#39;<br>    remote_src: true<br><br># Installing a Pod network add-on<br>- name: Apply Calico Tigera Operator manifest<br>  command: kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.28.0/manifests/calico.yaml<br><br># Creating join token<br>- name: create join token<br>  command: sudo kubeadm token create --print-join-command<br>  register: join_token<br><br>- name: Debug join_token<br>  debug:<br>    msg: &quot;{{ join_token.stdout }}&quot;<br><br>- name: Set join token fact<br>  set_fact:<br>    join_token_out: &quot;{{ join_token.stdout }}&quot;</pre><p>the main playbook.yaml</p><pre>---<br>- name: Install containerd, kubeadm<br>  hosts: all<br>  become: yes<br>  roles:<br>    - role: containerd<br>    - role: kubeadm<br><br>- name: Init-cluster<br>  hosts: master<br>  become: yes<br>  roles:<br>    - role: init-cluster<br><br>- name: Join worker nodes<br>  hosts: worker<br>  become: yes<br>  tasks:<br>    - name: Join worker nodes<br>      command: &quot;{{ hostvars[groups[&#39;master&#39;][0]].join_token_out }}&quot;</pre><p>Before running this command add ansible_ssh_private_key_file:&quot;location.pem&quot; in the inventory.ini file</p><pre>ansible-playbook -i inventory.ini playbook.yaml</pre><h3>🔗 <strong>Check Out the Project:</strong></h3><ul><li><strong>GitHub Repository:</strong> <a href="https://github.com/Prashantd3dha/K8s-AWS-Ansible-Terraform.git">https://github.com/Prashantd3dha/K8s-AWS-Ansible-Terraform.git</a></li></ul><h3>References</h3><ol><li><a href="https://docs.ansible.com/ansible/latest/">https://docs.ansible.com/ansible/latest/</a></li><li><a href="https://developer.hashicorp.com/terraform/language">https://developer.hashicorp.com/terraform/language</a></li><li><a href="https://registry.terraform.io/providers/hashicorp/aws/latest/docs">https://registry.terraform.io/providers/hashicorp/aws/latest/docs</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3599d2929687" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>