Skip to content

Instantly share code, notes, and snippets.

@hamidrhashmi
Last active June 23, 2025 10:29
Show Gist options
  • Save hamidrhashmi/68b7896d747c12b544e8e0181f8b1628 to your computer and use it in GitHub Desktop.
Save hamidrhashmi/68b7896d747c12b544e8e0181f8b1628 to your computer and use it in GitHub Desktop.
How to create EC2 instances in a AWS VPC?

Create VPC

go To VPC and click create VPC and provide the details as per teh follwoing screen shot VPC-eu-central-1-05-25-2025_10_40_PM

After creating VPC, It will look like this image

Create EC2 Instances

Go to EC2 and create Instances like below https://www.awesomescreenshot.com/video/40228522?key=986b75c9adc93c9df5c211375334d100

CReate three machines by repeating the above process image

Create Security groups

Creeat Secrity rules as of the follwing

image

Set Hostnames

ssh each machine and set thier hostnames

hostnamectl set-hostname masterkube

set new name in /etc/hosts

127.0.0.1       localhost masterkube
192.168.10.8    masterkube.hbvoice.local

repeat it with each new created machine

Confirm communication with other nodess

root@nodekube2:/home/admin# ping nodekube1.hbvoice.local -c4
PING nodekube1.hbvoice.local (192.168.10.14) 56(84) bytes of data.
64 bytes from nodekube1.hbvoice.local (192.168.10.14): icmp_seq=1 ttl=64 time=0.301 ms
64 bytes from nodekube1.hbvoice.local (192.168.10.14): icmp_seq=2 ttl=64 time=0.726 ms
64 bytes from nodekube1.hbvoice.local (192.168.10.14): icmp_seq=3 ttl=64 time=0.577 ms
64 bytes from nodekube1.hbvoice.local (192.168.10.14): icmp_seq=4 ttl=64 time=0.307 ms

--- nodekube1.hbvoice.local ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3075ms
rtt min/avg/max/mdev = 0.301/0.477/0.726/0.181 ms
root@nodekube2:/home/admin# ping masterkube.hbvoice.local -c4
PING masterkube.hbvoice.local (192.168.10.8) 56(84) bytes of data.
64 bytes from masterkube.hbvoice.local (192.168.10.8): icmp_seq=1 ttl=64 time=0.365 ms
64 bytes from masterkube.hbvoice.local (192.168.10.8): icmp_seq=2 ttl=64 time=0.388 ms
64 bytes from masterkube.hbvoice.local (192.168.10.8): icmp_seq=3 ttl=64 time=0.543 ms
64 bytes from masterkube.hbvoice.local (192.168.10.8): icmp_seq=4 ttl=64 time=0.552 ms

--- masterkube.hbvoice.local ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3077ms
rtt min/avg/max/mdev = 0.365/0.462/0.552/0.085 ms

IMPORTANT

Please disable source destination check on each node if you want to use these nodes for Kubernetes cluster actions --> Networking --> Disable Source/destination checK https://youtu.be/VcWpZoRAQXE?t=927

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment