Skip to content

Commit

Permalink
updated PXE boot menu and copy casper files to tftp folder
Browse files Browse the repository at this point in the history
  • Loading branch information
belajarpowershell committed Feb 8, 2024
1 parent 79e7180 commit f5584c0
Show file tree
Hide file tree
Showing 11 changed files with 90 additions and 26 deletions.
18 changes: 9 additions & 9 deletions k3s-lab-setup/000-ReadMeFirst/003-clone-repository.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
## Clone Repository on HyperV host.
## Clone Repository on Hyper-V host

Keep in mind this is to be run on the Windows PC where you are running Hyper-V. The git pull done on step `000-ReadMeFirst` was on `alpine1`
The scripts required to perform the various tasks are located in the git repository https://github.com/belajarpowershell/kubernetes-lab

The files required can be downloaded from the Repository https://github.com/belajarpowershell/kubernetes-lab
You will need to have GIT installed [Install Git ](https://git-scm.com/download/win)

You will need to have GIT installed [Install Git ](https://git-scm.com/download/win)
On Windows 11 you can open a `Terminal` that can run the `git' commands.



The following command will create a folder "kubernetes-lab"
The following command will create a folder `kubernetes-lab` and download the files.

```
# change to the Drive you want to store the files before executing this.
git clone https://github.com/belajarpowershell/kubernetes-lab.git
```

![alt text](./../../screenshots/Alpine1-screenshots/003-01-clone-repository.png)

![003-01-clone-repository](./../screenshots/003-01-clone-repository.png)

The files can then be found in ( in this example its the g:\ drive it might be different for you.)
The files can then be found in ( in this example its the c:\ drive it might be different for you.)

```
g:\kubernetes-lab
c:\kubernetes-lab
```

2 changes: 0 additions & 2 deletions k3s-lab-setup/000-ReadMeFirst/004-Hyper-V-VM-creation.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ To use this script:-

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

####

#### Lessons Learned

1. Hyper-V VM Memory needs to be at minimum 1GB. Any lower the Ubuntu will fail to install. Wasted a few days to catch this.
Expand Down
4 changes: 2 additions & 2 deletions k3s-lab-setup/100-alpine1/102-Clone-repository.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Clone the repository

In this step we will download the files required for
In this step we will download the files required to setup the various services. We now clone the repository to `ansible1`.

##### This script is to download the folder /srv from the Repository https://github.com/belajarpowershell/kubernetes-lab
##### This script is to download the files from the Repository https://github.com/belajarpowershell/kubernetes-lab

```
# Step 1 clone the repository
Expand Down
21 changes: 10 additions & 11 deletions k3s-lab-setup/100-alpine1/113-generate-user-data-multipleVM.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,39 +40,38 @@ The generated files are in the subfolder `.\autoinstall\`



From the configuration in step `111-setup-boot-files-part3-pxelinux.cfg` ( refer to manual step 111) , the Boot sequence is looking up the location. `http://192.168.100.1/autoinstall/`
From the configuration in step `111-setup-boot-files-part3-pxelinux.cfg` ( refer to manual step 11) , the Boot sequence is looking up the location. `http://192.168.100.1/autoinstall/`

This is from the following code

```
APPEND netboot=nfs boot=casper root=/dev/nfs nfsroot=192.168.100.1:/srv/isoubuntu autoinstall
```

Copy the files created to the folder
#### Copy autoinstall files to `alpine1`

` /srv/autoinstall/` on the `alpine1` server. The duplicate file with the node name is workaround to show the hostname of the specific file. As I did not find away to identify the hostname using the Ubuntu autoinstall method.
Using [WinSCP](https://winscp.net/eng/download.php) copy the files created to the folder `/srv/autoinstall/` on the `alpine1` server. The duplicate file with the node name is workaround to show the hostname of the specific file.

![114-02-wsftp-cp-autoinstall](./../screenshots\113-02-wsftp-cp-autoinstall.png)


![114-02-wsftp-cp-autoinstall](./../screenshots\114-02-wsftp-cp-autoinstall.png)



If you recall from 104-setup-nginx, the folder /srv/ was exposed to be visible from `http://192.168.100.1/`. All folders created in `/srv/` will be listed via the browser.

Copy the files using WSFTP or some other method .
From step `104-setup-nginx`( refer to manual steps), the folder /srv/ was exposed to be visible from `http://192.168.100.1/`. All folders created in `/srv/` will be listed via the browser.

Validate by browsing `http://192.168.100.1/`



![114-03-list-autoinstall-in-browser](./../../screenshots\114-03-list-autoinstall-in-browser.png)
![114-03-list-autoinstall-in-browser](./../screenshots\114-03-list-autoinstall-in-browser.png)

// To update Video of Script generation and the Ubuntu setup.



#### Lessons Learnt

The MAC addresses for a newly created Hyper-V VM is not generated until its started at least once.
- The MAC addresses for a newly created Hyper-V Virtual Machine is not generated until its started at least once.
- the `meta-data` and`vendor-data` while empty must exist.



Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,32 @@ ls /srv/isoubuntu

![alt text](./../../screenshots/Alpine1-screenshots/mount-ubuntu-iso.png)



#### Step 2 Extract `vmlinuz` and `initrd`

Run the commands below to extract the boot files.

```
#create ubuntu folder to store the boot files.
# this way we can have boot files for multple distros if required.
mkdir -p /srv/tftp/ubuntu/casper
# copy files
cp /srv/isoubuntu/casper/vmlinuz /srv/tftp/ubuntu/casper
cp /srv/isoubuntu/casper/initrd /srv/tftp/ubuntu/casper
```

**Validate**
The boot files will be served via http. Do validate if this folder and content is listed.


![alt text](./../screenshots/Alpine1-screenshots/browser-list-casper.png)





**Validate if accessible via HTTP**

As we have already setup `nginx` to list directory content. This should be visible via browser.
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
21 changes: 21 additions & 0 deletions srv/ansible/playbook-alpine1/110-setup-boot-files-part2-OS.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,24 @@

- name: List contents of the mounted ISO
shell: ls /srv/isoubuntu

- name: Copy Ubuntu Casper images
hosts: localhost
tasks:
- name: Create Ubuntu directory structure
file:
path: "/srv/tftp/ubuntu/casper"
state: directory
mode: 0755

- name: Copy vmlinuz to TFTP server
copy:
src: "/srv/isoubuntu/casper/vmlinuz"
dest: "/srv/tftp/ubuntu/casper/vmlinuz"
mode: 0644

- name: Copy initrd to TFTP server
copy:
src: "/srv/isoubuntu/casper/initrd"
dest: "/srv/tftp/ubuntu/casper/initrd"
mode: 0644
20 changes: 20 additions & 0 deletions srv/ansible/playbook-alpine1/alpine-services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -403,3 +403,23 @@

- name: List contents of the mounted ISO
shell: ls /srv/isoubuntu
- name: Copy Ubuntu Casper images
hosts: localhost
tasks:
- name: Create Ubuntu directory structure
file:
path: "/srv/tftp/ubuntu/casper"
state: directory
mode: 0755

- name: Copy vmlinuz to TFTP server
copy:
src: "/srv/isoubuntu/casper/vmlinuz"
dest: "/srv/tftp/ubuntu/casper/vmlinuz"
mode: 0644

- name: Copy initrd to TFTP server
copy:
src: "/srv/isoubuntu/casper/initrd"
dest: "/srv/tftp/ubuntu/casper/initrd"
mode: 0644
4 changes: 2 additions & 2 deletions srv/tftp/efi64/pxelinux.cfg/default
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ LABEL ubuntu-iso-remote #iso downloaded from http. Requires 4GB of Memory
append url=http://192.168.100.1/tftp/iso/ubuntu-20.04.6-live-server-amd64.iso autoinstall ds=nocloud-net;s=http://192.168.100.1/autoinstall/ ip=dhcp fsck.mode=skip ---

LABEL ubuntu-DVD-local (Ubuntu DVD locally mounted - 1GB Memory)
MENU LABEL ubuntu-iso-local (iso locally mounted 1GB of Memory)
MENU LABEL ubuntu-DVD-local (iso locally mounted 1GB of Memory)
KERNEL http://192.168.100.1/tftp/ubuntu/casper/vmlinuz
INITRD http://192.168.100.1/tftp/ubuntu/casper/initrd
APPEND autoinstall ds=nocloud-net;s=http://192.168.100.1/autoinstall/ ip=dhcp fsck.mode=skip ---

LABEL ubuntu-nfs-boot (Ubuntu iso mounted on nfs - 1GB Memory)
MENU LABEL ubuntu-iso-local (iso locally mounted 1GB of Memory)
MENU LABEL ubuntu-nfs-boot (iso mounted on nfs 1GB of Memory)
KERNEL http://192.168.100.1/tftp/ubuntu/casper/vmlinuz
INITRD http://192.168.100.1/tftp/ubuntu/casper/initrd
APPEND netboot=nfs boot=casper root=/dev/nfs nfsroot=192.168.100.1:/srv/isoubuntu autoinstall ds=nocloud-net;s=http://192.168.100.1/autoinstall/ ip=dhcp fsck.mode=skip ---
Expand Down

0 comments on commit f5584c0

Please sign in to comment.