Cloud-oriented Life

Cloud Native Technology Improves Lives

Usage

First, edit Vagrant file to add external disk configuration.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
  config.vm.provider "virtualbox" do |vb|
# Display the VirtualBox GUI when booting the machine
vb.gui = true

# Customize the amount of memory on the VM:
vb.memory = "1024"

+ file_to_disk = './disks/external-disk-1.vdi'
+ # 100 * 1024 = 100GB
+ vb.customize ['createhd', '--filename', file_to_disk, '--size', 100 * 1024]
+ # IDE mode
+ vb.customize ['storageattach', :id, '--storagectl', 'IDE', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', file_to_disk]
+ # SATA Controller mode
+ # vb.customize ['storageattach', :id, '--storagectl', 'SATA Controller', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', file_to_disk]
end

Then, run vagrant up or vagrant reload to make external disk available.

1
2
3
4
$ VAGRANT_EXPERIMENTAL=disks vagrant up

# Or reload
# $ VAGRANT_EXPERIMENTAL=disks vagrant reload

Done!

1
2
3
4
5
$ vagrant ssh -c lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20.0G 0 disk
├─sda1 8:1 0 19.6G 0 part
sdb 8:16 0 100.0G 0 disk

FAQs

Could not find a controller named ‘SATA Controller’

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
$ VAGRANT_EXPERIMENTAL=disks vagrant up
...
A customization command failed:

["storageattach", :id, "--storagectl", "SATA Controller", "--port", 1, "--device", 0, "--type", "hdd", "--medium", "./disks/disk-1.vdi"]

The following error was experienced:

#<Vagrant::Errors::VBoxManageError: There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.

Command: ["storageattach", "5454cd06-0f61-43c5-a14e-071c9100439c", "--storagectl", "SATA Controller", "--port", "1", "--device", "0", "--type", "hdd", "--medium", "./disks/disk-1.vdi"]

Stderr: VBoxManage: error: Could not find a controller named 'SATA Controller'
>

Please fix this customization and try again.

Check current Storage Controller Name.

1
2
3
4
5
6
7
$ VBoxManage showvminfo 5454cd06-0f61-43c5-a14e-071c9100439c | grep "Storage"
Storage Controller Name (0): IDE
Storage Controller Type (0): PIIX4
Storage Controller Instance Number (0): 0
Storage Controller Max Port Count (0): 2
Storage Controller Port Count (0): 2
Storage Controller Bootable (0): on

Change Storage Controller Name SATA Controller from to IDE.

1
2
3
4
5
+     # IDE mode
+ vb.customize ['storageattach', :id, '--storagectl', 'IDE', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', file_to_disk]
+ # SATA Controller mode
+ # vb.customize ['storageattach', :id, '--storagectl', 'SATA Controller', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', file_to_disk]
- vb.customize ['storageattach', :id, '--storagectl', 'SATA Controller', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', file_to_disk]

VERR_ALREADY_EXISTS

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
$ VAGRANT_EXPERIMENTAL=disks vagrant up
A customization command failed:

["createhd", "--filename", "./disks/disk-1.vdi", "--size", 1048576]

The following error was experienced:

#<Vagrant::Errors::VBoxManageError: There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.

Command: ["createhd", "--filename", "./disks/disk-1.vdi", "--size", "1048576"]

Stderr: 0%...
Progress state: VBOX_E_FILE_ERROR
VBoxManage: error: Failed to create medium
VBoxManage: error: Could not create the medium storage unit '/Users/cloudolife/col-vagrant/disks/disk-1.vdi'.
VBoxManage: error: VDI: cannot create image '/Users/cloudolife/col-vagrant/disks/disk-1.vdi' (VERR_ALREADY_EXISTS)
VBoxManage: error: Details: code VBOX_E_FILE_ERROR (0x80bb0004), component MediumWrap, interface IMedium
VBoxManage: error: Context: "RTEXITCODE handleCreateMedium(HandlerArg*)" at line 450 of file VBoxManageDisk.cpp
>

Please fix this customization and try again.

There is already a disk disk-1.

Check the UUID of the disk disk-1

1
2
3
4
5
$ VBoxManage list hdds
...
UUID: <UUID>
Location: /home/vagrant/vagrants/vagrant-example/disks/disk-1.vdi
...

Delete the disk disk-1.

1
$ vboxmanage closemedium disk <UUID> --delete

Then, run VAGRANT_EXPERIMENTAL=disks vagrant up.

References

[1] Add a second disk to system using vagrant - https://gist.github.com/leifg/4713995

[2] Vagrant virtualbox multiple disks - https://gist.github.com/muresan/e81df5d8aaf8be78b4ecdf787a9dba15

[3] How to define multiple disks inside Vagrant using VirtualBox provider – sleeplessbeastie’s notes - https://sleeplessbeastie.eu/2021/05/10/how-to-define-multiple-disks-inside-vagrant-using-virtualbox-provider/

[4] Fix for VBoxManage: error: Could not find a controller named ‘SATA’ Error | Sharmi Writes Here - https://www.minvolai.com/fix-for-vboxmanage-error-could-not-find-a-controller-named-sata-error/

[5] Vagrant by HashiCorp - https://www.vagrantup.com/

[6] Oracle VM VirtualBox - https://www.virtualbox.org/

Ruby Version Manager (RVM)

RVM is a command-line tool which allows you to easily install, manage, and work with multiple ruby environments from interpreters to sets of gems.

RVM: Ruby Version Manager - RVM Ruby Version Manager - Documentation - https://rvm.io/

Read more »

asdf and Ruby Plugin

asdf is a single CLI tool for managing multiple runtime versions. It extend with a simple plugin system to install your favourite language: Dart, Elixir, Flutter, Golang (Go), Java, Node.js, Python, Ruby …

This article is about how to use asdf and Ruby plugin to install multiple Ruby versions on macOS with the Homebrew package manager.

Read more »

Git Large File Storage (LFS)

Git Large File Storage (LFS) is an open source Git extension for versioning large files that replaces large files such as audio samples, videos, datasets, and graphics with text pointers inside Git, while storing the file contents on a remote server like GitLab, GitLab.com, GitHub.com or GitHub Enterprise.

Read more »

lens

Lens is the only IDE you’ll ever need to take control of your Kubernetes clusters. It’s built on open source and free. Download it today!

https://k8slens.dev/images/header-screenshot.png

Feature

An IDE designed for those who work with Kubernetes on a daily basis: Beautiful, polished and powerful

  • Remove Complexity

    Explore and navigate Kubernetes clusters without having to learn kubectl commands. Great for developers just getting started.

  • Real Time Observability

    Inspect live statistics, events, and log streams in real-time. No spinners, refreshing or waiting for screens to update.

  • Troubleshoot & Debug

    See errors and warnings on dashboard and click to see details. Click again to see logs or get a command line.

  • Run on Your Desktop

    Standalone application for MacOS, Windows and Linux. 1-minute install. No need to install anything in cluster.

  • Built on Open Source & Free

    Lens is built on open source with vibrant community and is backed by Kubernetes and cloud native ecosystem pioneers.

  • Works with Any Kubernetes

    Using EKS, AKS, GKE, Minikube, Rancher, k0s, k3s, OpenShift… ? They all work. Simply import the kubeconfigs for the clusters you want to work with.

Installation

macOS

    1. Download Lens for macOS - https://k8slens.dev/.
    1. Open the browser’s download list and locate the downloaded archive.
    1. Select the ‘magnifying glass’ icon to open the archive in Finder.
    1. Double-click Lens-{version}.dmg and drag Lens.app to the Applications folder, making it available in the macOS Launchpad.
    1. Add Lens to your Dock by right-clicking on the icon to bring up the context menu and choosing Options, Keep in Dock.

Or Install it via Homebrew (brew).

1
% brew install --cask lens

Windows#

Linux

See the Lens Website - https://k8slens.dev/ for a complete list of available installation options.

After installing Lens manually (not using a package manager file such as .deb or .rpm) the following will need to be done to allow protocol handling. This assumes that your linux distribution uses xdg-open and the xdg-* suite of programs for determining which application can handle custom URIs.

    1. Create a file called lens.desktop in either ~/.local/share/applications/ or /usr/share/applications (if you have permissions and are installing Lens for all users).
    1. That file should have the following contents, with <path/to/executable> being the absolute path to where you have installed the unpacked Lens executable:
1
2
3
4
5
6
7
8
9
10
[Desktop Entry]
Name=Lens
Exec=<path/to/executable> %U
Terminal=false
Type=Application
Icon=lens
StartupWMClass=Lens
Comment=Lens - The Kubernetes IDE
MimeType=x-scheme-handler/lens;
Categories=Network;

Then run the following command:

1
$ xdg-settings set default-url-scheme-handler lens lens.desktop

If that succeeds (exits with code 0) then your Lens install should be set up to handle lens:// URIs.

Snap

Lens is officially distributed as a Snap package in the Snap Store - https://snapcraft.io/store:

You can install it by running:

1
$ sudo snap install kontena-lens --classic

References

[1] Lens | The Kubernetes IDE - https://k8slens.dev/

[2] lensapp/lens: Lens - The Kubernetes IDE - https://github.com/lensapp/lens

[3] lens — Homebrew Formulae - https://formulae.brew.sh/cask/lens

[4] The Missing Package Manager for macOS (or Linux) — Homebrew - https://brew.sh/

[5] Install Lens for Linux using the Snap Store | Snapcraft - https://snapcraft.io/kontena-lens

[6] Snap Store - https://snapcraft.io/store

logrotate

The logrotate utility is designed to simplify the administration of log files on a system which generates a lot of log files. Logrotate allows for the automatic rotation compression, removal and mailing of log files. Logrotate can be set to handle a log file hourly, daily, weekly, monthly or when the log file gets to a certain size.

Read more »

helm-nfs-server-provisioner-example

NFS Server Provisioner

The NFS client provisioner - https://github.com/kubernetes-incubator/external-storage/tree/master/nfs-client is an automatic provisioner for Kubernetes that uses your already configured NFS server, automatically creating Persistent Volumes.

This chart will deploy the Kubernetes nfs provisioner. This provisioner is intended for connecting to a pre-existing NFS server, and not includes a built in NFS server. If you want a built in NFS Server, please consider using the nfs-client-provisioner - https://github.com/helm/charts/tree/master/stable/nfs-client-provisioner instead.

This article is about how to use Helm to install nfs-client-provisioner on Kubernetes (K8S).

Read more »

Optimistic locking

Optimistic locking allows multiple users to access the same record for edits, and assumes a minimum of conflicts with the data. It does this by checking whether another process has made changes to a record since it was opened, an ActiveRecord::StaleObjectError exception is thrown if that has occurred and the update is ignored.

Read more »
0%