Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
belajarpowershell committed Jan 27, 2024
1 parent e1cb31d commit 2db37ef
Show file tree
Hide file tree
Showing 19 changed files with 554 additions and 39 deletions.
11 changes: 11 additions & 0 deletions kubernetes-lab-setup/Document/001-Hyper-V-Host-Specification.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
In this Lab setup The Hyper V host server specifications are as follows

1. Interl i7-8700 3.2GHz CPU
2. 32GB of Memory
3. At least 1 Terabytes of Hard Disk

As a reference with all the Virtual Machines Running the following was the utilization
1. CPU <50% utilization
2. Memory ~ 64%

This is to provide a perspective on the Host CPU specifications for your Lab setup.
32 changes: 20 additions & 12 deletions kubernetes-lab-setup/Document/001-Hyper-V-VM-creation.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ To use this script:-
- run `Powershell ISE` as admin.
- Save a file to a working folder with the content below.
- The script uses the `f:\` drive you may want to change it to match the drive you have.
- You also need to create a file `vms.csv` with the content stated in the script. This will be the source for the VM's to be created.
- You also need to create a file `001-Kubernetes-Create-HyperV-VM-v1.1.csv` with the content stated in the script. This will be the source for the VM's to be created.
- Once the file is saved click on the `Green Play` button, this will execute the script.


// method to access Video-- QR code?

[Here is a video that might help](https://clipchamp.com/watch/EYzyfDZUGRv)

```
# create working folder
# this script will default to F:\kubernetes-project-lab
Expand All @@ -24,16 +25,16 @@ Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
example content of "vms.csv"
You can change the VM name
VMName,NetworkSwitch1,NetworkSwitch2,DiskSizeGB1,DiskSizeGB2,CPUCount,MemoryGB,ISOPath,BootOrder
aaa-alpine1,Internet,"Private 192.168.100.0/24",50,,1,1,alpine-standard-3.18.4-x86_64.iso,DVD
aaa-loadbalancer,,"Private 192.168.100.0/24",50,,1,1,alpine-standard-3.18.4-x86_64.iso,Network
aaa-master1,,"Private 192.168.100.0/24",50,,1,1,ubuntu-20.04.6-live-server-amd64.iso,Network
aaa-master1,,"Private 192.168.100.0/24",50,,1,1,ubuntu-20.04.6-live-server-amd64.iso,Network
aaa-master2,,"Private 192.168.100.0/24",50,,1,1,ubuntu-20.04.6-live-server-amd64.iso,Network
aaa-master3,,"Private 192.168.100.0/24",50,,1,1,ubuntu-20.04.6-live-server-amd64.iso,Network
aaa-worker1,,"Private 192.168.100.0/24",50,30,1,1,ubuntu-20.04.6-live-server-amd64.iso,Network
aaa-worker2,,"Private 192.168.100.0/24",50,30,1,1,ubuntu-20.04.6-live-server-amd64.iso,Network
aaa-worker3,,"Private 192.168.100.0/24",50,30,1,1,ubuntu-20.04.6-live-server-amd64.iso,Network
aaa-xsinglenode,,"Private 192.168.100.0/24",50,30,1,1,ubuntu-20.04.6-live-server-amd64.iso,Network
alpine1,Internet,"Private 192.168.100.0/24",50,,1,1,alpine-standard-3.18.4-x86_64.iso,DVD
loadbalancer,,"Private 192.168.100.0/24",50,,1,1,alpine-standard-3.18.4-x86_64.iso,Network
master1,,"Private 192.168.100.0/24",50,,1,1,ubuntu-20.04.6-live-server-amd64.iso,Network
master1,,"Private 192.168.100.0/24",50,,1,1,ubuntu-20.04.6-live-server-amd64.iso,Network
master2,,"Private 192.168.100.0/24",50,,1,1,ubuntu-20.04.6-live-server-amd64.iso,Network
master3,,"Private 192.168.100.0/24",50,,1,1,ubuntu-20.04.6-live-server-amd64.iso,Network
worker1,,"Private 192.168.100.0/24",50,30,1,1,ubuntu-20.04.6-live-server-amd64.iso,Network
worker2,,"Private 192.168.100.0/24",50,30,1,1,ubuntu-20.04.6-live-server-amd64.iso,Network
worker3,,"Private 192.168.100.0/24",50,30,1,1,ubuntu-20.04.6-live-server-amd64.iso,Network
xsinglenode,,"Private 192.168.100.0/24",50,30,1,1,ubuntu-20.04.6-live-server-amd64.iso,Network
##
NetworkSwitch1 : this is the internet connection
Expand Down Expand Up @@ -174,3 +175,10 @@ foreach ($vm in $vms) {
```



Mistakes made

1. Memory needs to be at 1GB. Any lower the Ubuntu will fail to install. Wasted a few days to catch this.
2. If you are using the download ISO to memory then you need to have a minimum of 4GB to load the ISO to memory.
4 changes: 2 additions & 2 deletions kubernetes-lab-setup/Document/100-alpine1-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ sysctl -p
After logging on at the prompt type
```
setup-alpine
```
```
You will be asked a series of questions . I have listed my selection.
```
Keyboard Layout : [us]
Expand All @@ -65,7 +65,7 @@ Erase the above disks and continue? [y]
```

## Installation begins.
Once the installtion is completed you will see the notice to reboot.
Once the installation is completed you will see the notice to reboot.
Before rebooting, change the boot sequence in Hyper-V for alpine1 to be Hard Drive first.

This will ensure the reboot will be to the Hard Disk.
Expand Down
3 changes: 2 additions & 1 deletion kubernetes-lab-setup/Document/102-setup-router.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ rc-update add iptables
iptables -A FORWARD -i eth1 -j ACCEPT
# eth0 is the external interface (connected to the internet)
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE /etc/init.d/iptables save
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
/etc/init.d/iptables save
```

Expand Down
8 changes: 7 additions & 1 deletion kubernetes-lab-setup/Document/103-setup-dns.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ master3 IN A 192.168.100.204
worker1 IN A 192.168.100.205
worker2 IN A 192.168.100.206
worker3 IN A 192.168.100.207
single IN A 192.168.100.199
singleubuntu IN A 192.168.100.198
```

Validate the bind configuration
Expand All @@ -94,6 +97,9 @@ As there are no other servers setup, this can be validated when the VM's are cre
To ensure alpine1 resolves the FQDN's correctly ensure the following is configured

```
# run command to check Network interface configuration
vi /etc/network/interfaces
auto lo
iface lo inet loopback
Expand All @@ -112,7 +118,7 @@ dns-nameservers 192.168.100.1

```
#on alpine1 only.
rm /etc/resolve
vi /etc/resolve
nameserver 192.168.100.1
search k8s.lab
Expand Down
17 changes: 8 additions & 9 deletions kubernetes-lab-setup/Document/104-setup-nginx.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ vi /etc/nginx/http.d/installfileserver.conf
# paste the following code.
server {
server_name localhost;
root /kubernetes-lab/kubernetes-lab-setup/srv/;
root /srv/;
#index index.html;
location /:x { # new url path # this is the URL path on browser
alias /kubernetes-lab/kubernetes-lab-setup/srv/; # directory to list
#in this case http://ip/ will list files in "/kubernetes-lab/kubernetes-lab-setup/srv/"
location / { # new url path # this is the URL path on browser
alias /srv/; # directory to list
#in this case http://ip/ will list files in "/srv/"
# this might not be best practice, but this is a Lab setup
autoindex on;
}
Expand All @@ -55,7 +55,7 @@ nginx -t
#reload nginx
rc-service nginx restart
```
```
Logs
You can check the files accessed via url, this way you can validate if the correct paths are in place.

Expand All @@ -67,12 +67,12 @@ Validate

```
# create a file to be listed
mkdir -p /kubernetes-lab/kubernetes-lab-setup/srv/autoinstall/ && touch /kubernetes-lab/kubernetes-lab-setup/srv/autoinstall/test.txt
mkdir -p /srv/autoinstall/ && touch /srv/autoinstall/test.txt
#In a browser open the following URL
https://192.168.100.1
http://192.168.100.1
The list of files hosted in `/kubernetes-lab/kubernetes-lab-setup/srv/autoinstall/` will be listed.
The list of files hosted in `/srv/autoinstall/` will be listed.
```
Here is and example
![alt text](./screenshots/Alpine1-screenshots/browser-list-files-update.png)
Expand All @@ -87,4 +87,3 @@ We will proceed with the nfs server installation
Please continue with
# [105-alpine1-nfs](./105-alpine1-nfs.md)


42 changes: 35 additions & 7 deletions kubernetes-lab-setup/Document/105-nfs.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,29 @@
We do have use cases for `nfs` so lets set this up.

```
# in this lab we will mount the ubuntu ISO to be served via nfs.
# the first part will be to mount the ubuntu ISO files to a folder.
# create the folder to download the iso file to.
mkdir -p /srv/tftp/iso
# Download the ISO
wget -P /srv/tftp/iso https://releases.ubuntu.com/20.04.6/ubuntu-20.04.6-live-server-amd64.iso
#Create folder to mount ISO file
mkdir -p /srv/isoubuntu
# this will mount the ISO file until the server is rebooted
mount -o loop,ro -t iso9660 /srv/tftp/iso/ubuntu-20.04.6-live-server-amd64.iso /srv/isoubuntu
ls /srv/isoubuntu
# to make the iso mounted permanantly
# update the fstab
vi /etc/fstab
#add following entry
/srv/tftp/iso/ubuntu-20.04.6-live-server-amd64.iso /srv/isoubuntu iso9660 loop 0 0
Validate by rebooting the server and check if the iso files are listed.
ls /srv/isoubuntu
#install nfs
apk update
apk add nfs-utils
Expand All @@ -17,22 +40,28 @@ rc-update add nfs
# check status
rc-service nfs status
# start nfs service
rc-service rpcbind start
rc-service nfs start
#### revalidate config and validation
#nfs configuration
# update file with the entry below.
vi /etc/exports
/srv/isoubuntu 192.168.100.1/24(async,ro,no_subtree_check,no_root_squash)
/kubernetes-lab/kubernetes-lab-setup/srv/isoubuntu 192.168.100.1/24(async,ro,no_subtree_check,no_root_squash)
# refresh the nfs with the updated row.
exportfs -a -v
exportfs -arv
#test mount using the following command
mkdir -p mntnfs
mount 192.168.100.1:/kubernetes-lab/kubernetes-lab-setup/srv/isoubuntu /mntnfs
mkdir mntnfs
mount 192.168.100.1:/srv/isoubuntu mntnfs
# List files in mount
ls /mntnfs
# List files in mount
ls mntnfs/
```

Expand All @@ -46,4 +75,3 @@ We will proceed with the tftp server installation
Please continue with
# [106-alpine1-tftp](./106-alpine1-tftp.md)


5 changes: 4 additions & 1 deletion kubernetes-lab-setup/Document/106-tftp.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
tftp is required for PXELINUX boot setup.
This is how the initial boot files are retrieved from the remote client.
```
#install nginx
# create directories
mkdir /srv/tftp/
#install tftpd
apk update
apk add tftp-hpa
Expand Down
4 changes: 4 additions & 0 deletions kubernetes-lab-setup/Document/107-cloud-init.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Turns out `cloud-init` has a command for just that!
```
# enable community repository
vi /etc/apk/repositories
remove # from the row
#http://mirror.jingk.ai/alpine/v3.18/community
#install `cloud-init`
apk update
Expand All @@ -19,6 +21,8 @@ setup-cloud-init
```

Validate `user-data` using the command below.
At this time the lab has not generated the `user-data` file .

You can test this if you have a `user-data` file handy. The `user-data` will be shared in later steps

```
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `alpine1` setup and configuration.

# Ubuntu Autoinstall
# Ubuntu Autoinstall on single VM

One other aspect I was looking at is to automate all the servers to access the configuration files that is reference with the hostname,IP,gateway and Disk config.
This way every time I have to rebuild the lab, it will be quicker.
Expand All @@ -14,9 +14,10 @@ I understand from the Ubuntu [Automated Server installation](https://ubuntu.com/

#### Lets get to the details

The autoinstall requires `user-data` and `meta-data`. The `meta-data` is a blank file.
The autoinstall requires `user-data` , `vendor-data` and `meta-data`. The `meta-data` and , `vendor-data` are blank files.
`user-data` however must be populated with some valid content.
In the file `/srv/tftp/efi64/pxelinux.cfg/default`, the append row below looks for the `user-data` and `meta-data` we need to ensure these file exists is referenced here.

```
`autoinstall ds=nocloud-net;s=http://192.168.100.1/autoinstalldata/`
```
Expand Down Expand Up @@ -165,26 +166,44 @@ Generate the crypted password using the command below. The result will change wi
mkpasswd --method=sha-512 123 # 123 is the password in this example
```

We now have all the files in place for a machine to start up and autoinstall ubuntu.

## Validate

Validate `user-data` using the command below.

```
cloud-init schema --config-file user-data
```



We now have all the files in place for a machine to start up and autoinstall ubuntu.

With the setup in place you can now start the Virtual Machine `master1`, the network boot will present the Menu, select the option `ubuntu-iso-local` the VM will boot up with and the installation will complete without manual input.

#### Video overview on the Ubuntu Autoinstall process .
This a video covering the initial boot, Ubuntu installation and the booting to the newly installed Ubuntu.
[Autoinstall-Ubuntu-master1](https://clipchamp.com/watch/5HU0H7YUsnU)

# update to include new link

## Troubleshooting steps.
As I performed the configuration, I faced some issues , and the following had configuration errors mostly. i.e. wrong IP, typos etc.

- check dhcp
Ensure the IP Addresses are assigned correctly.

- Check nginx
You can use the access log to check if a URL has been accessed. This way you can guess where the errors could be.

- Ensure Virtual Machine specifications meet the minimum requirements.

I had set the Memory to 512MB and enabled Dynamic memory of 512MB to 2048GB but this caused the autoinstall to crash and not complete.

- if you choose `ubuntu-iso-remote` ensure VM has minimum 4GB of memory to load the Ubuntu OS setup. This is for the ISO to be extracted to memory.

- URL path incorrect
Many times I found myself making simple mistakes in the path. Double check if you did the same too.
- `meta-data` not created or path configured does not have `meta-data`
Many times I found myself making simple mistakes in the path. Double check if you did the same too.

- `meta-data` and `vendor-data` not created or path configured does not have `meta-data` and `vendor-data`

Loading

0 comments on commit 2db37ef

Please sign in to comment.