9th June 2018

Technical Resources

A collection of my Technical Resource documentation.

Latest Tech Articles

3rd January 2020

Giving other users access to EKS Cluster

By default, only the IAM user who created the EKS Cluster will have access – Follow the below instructions to provide other AWS users access to the Cluster.

Getting the ARN for the new user

Login to the AWS Console and open the IAM page and find the user who you wish to provide access to the EKS cluster.

When opening the User’s page you will see their IAM ARN at the top of the page – Make a note of this, eg:

arn:aws:iam::123456789012:user/example.user

Providing Access

When deploying your EKS cluster via this guide – You will have created a file in your Code Versioning software called “aws-auth-cm.yaml”. This is the file that determines which users have access to the EKS Cluster.

Open this file and add the ARN copied earlier under “mapUsers”. Eg:

 - userarn: arn:aws:iam::123456789012:user/example.user
   username: example.user
   groups:
     - system:kubelet-api-admin
     - system:masters

Save this file into your Code Versioning and apply the file to your EKS Cluster:

kubectl apply -f aws-auth-cm.yaml
27th December 2019

Running Windows from Dual-Boot in Ubuntu OS

If you, like I, have a Windows machine on your Ubuntu Desktop for dual-booting (Eg for playing games or running Windows-Only apps) I have always wanted to quickly access my Windows Machine without having to reboot into it.

To do this I installed Virtualbox on my Ubuntu Desktop and mounted the physical disk running Windows onto the Virtual Machine which allows me to quickly spin up the VM to test / run something in Windows without having to shutdown my Ubuntu install.

NOTE: It is possible for something to go wrong here so ensure that, before proceeding, you have backed up any data from your Windows disk. 

Installing Virtualbox

If you don’t have it installed already, go here to download the latest version of Virtualbox onto your Ubuntu Desktop – Download Virtualbox.

Creating a Virtual Disk file for your Physical Disk

The next step will be to create a virtual disk file to mount your Physical Disk from. Firstly you should get the disk name of your Windows installation on your Ubuntu Desktop – To do this, use fdisk to get a list of your Disks and make a note of the ID for your Windows install (You should be able to tell from the disk size) if not you can remove the grep to see the partition sizes.

[email protected]:~$ sudo fdisk -l | grep "Disk /dev/sd"
Disk /dev/sda: 111.8 GiB, 120034123776 bytes, 234441648 sectors
Disk /dev/sdb: 55.9 GiB, 60022480896 bytes, 117231408 sectors
Disk /dev/sdc: 223.6 GiB, 240057409536 bytes, 468862128 sectors

Once you have the disk name – Run the below Virtualbox command to create a virtual disk file for your physical disk (Replacing the location in which you wish to store the file and the disk name:

sudo VBoxManage internalcommands createrawvmdk -filename /mnt/virtualbox/win10-os.vmdk -rawdisk /dev/sdb

Creating the Virtual Machine

The next step is to create a Virtual Machine in the Virtualbox GUI. Open the package and click “New” at the top of the Window – Give your VM an appropriate name and select a location to store the configuration.

When you get to the Disk section, select the Folder icon under “USe an existing virtual hard disk file” and click “Add” to find your virtual disk file created earlier.

Select the Virtual disk file and click “Choose”.

Booting the Virtual Machine

Once you have configured your machine, select it from the Homescreen and select “Start” to boot!

13th December 2019

Setting up a Mongodb replicaset in docker-compose with Hidden Members

Notes

This is for instructional purposes, obviously in a production environment you would not run multiple mongodb databases on the same host as this will dramatically increase the load on the server as well as providing no redundancy in the event of the host going down.

Installation

sudo docker-compose up -d

Configuration

  • To create the replicaset, use the mongo command to access mongodb1 on port 27017 and use rs.initiate to create the replicaset (Adjusting the initiate command based on how many mongodb instances you require).

NOTE: If you do not have mongo client installed on your Desktop, you can docker exec into the container to run the below.

mongo

rs.initiate( {
_id : "test",
members: [
{ _id: 0, host: "mongodb1:27017" },
{ _id: 1, host: "mongodb2:27018" },
{ _id: 2, host: "mongodb3:27019" },
]
})

You can confirm the replicaset status by running the below:

mongo

rs.status()

Adding a Replica set member

To add a new member to your cluster, run the below command from one of the existing database servers (Will be using mongodb4 for this example):.

mongo

rs.add( { host: "mongodb4:27020", priority: 0, votes: 0 } )

Making a “Hidden” Replicaset member

To add a hidden member to your Mongodb cluster (Eg for backups) add the new member to the cluster and set it’s attribute to hidden as below (Will be using mongodb5 for this example):

mongo

rs.add( { host: "mongodb5:27021", priority: 0, votes: 0 } )

Now use rs.status() to get the “id” of the new replicaset member – Make a note of this _id:

mongo

rs.status()

Now edit the replicaset configuration to set this new member to “hidden”, replacing id with the value you noted before (Eg 4)

cfg = rs.conf()
cfg.members[4].priority = 0
cfg.members[4].hidden = true
rs.reconfig(cfg)