23 February 2022

Docker on Ubuntu

This method installs the sources as detailed here.

sudo apt-get update
sudo apt-get install \
ca-certificates \
curl \
gnupg \
lsb-release

install the key:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io

Then run the post install tasks here. Switch to the relevant user then:

sudo groupadd docker
sudo usermod -aG docker $USER
activate new group: newgrp docker or log out/in

Ten test it works as this user: docker run hello-world

Azure DevOps on Ubuntu

 Aim: Run a local server as a build agent.

1. Add a user

Advised to run the agent under a specific user: sudo adduser azuredevops

Add user to sudoers: sudo adduser azuredevops sudo

2. Switch to new user

su azuredevops

3. Install the agent

Go to Azure DevOps, Organization settings, Agent Pools, Select Pool (Default), Add agent

  • Make a dir: mkdir azureagent && cd azureagent
  • Download: wget [Download URL]
  • Unpack: tar zxvf vsts-agent-linux-x64-2.200.0.tar.gz
  • Run: . config.sh
  • Enter Server URL: https://dev.azure.com/{your-organization}
  • Enter PAT: See Authenticate with PAT

4. Run the service

Run the installer
sudo ./svc.sh install azuredevops
sudo ./svc.sh start

5. Install dependencies

NB: You might need to install some dependencies depending on your build steps e.g. zip

6. Optional: Clear up Docker images

The agent downloads a load of Docker images which take up loads of space, so run a build on the server from Azure DevOps and then clean up the docker images: docker rmi -f $(docker images -aq)

MicroK8s on Ubuntu Server

Aim: To install MicroK8s on Ubuntu Server

Also see k8s docs here.

Download version of Ubuntu Server and create a bootable USB

Easiest to do from another machine running Ubuntu: See the tutorial

It is possible from Windows or Mac but there are some hoops to jump through.

Boot from the USB and Install

Plug in the USB and reboot, ensuring your BIOS is set o boot from USB. Follow the guide to continue the setup procedure. Note that the last step of installing security updates will take a long time.

  • Do install SSH so you can connect remotely. Suggest downloading keys e.g. from GitHub

Post Install

Install MicroK8s

You can install via snap or apt: Snap includes all dependencies and provides automatic updates but likely runs slower as installed independently. Apt requires that you install the dependencies correctly.
Enable ad ons e.g. 
microk8s enable dns
microk8s enable storage
microk8s enable helm
NB: If you're using kubesail.io follow their docs here

Setup kubectl

MicroK8s comes with it's own microk8s.kubectl cmd, so if you want to you can either configure kubectl or setup an alias

Configure kubctl

  1. Install kubectl if you don't have it already: either from native package manager or snap.
    snap install kubectl --classic && kubectl version --client
  2. Configure it to work with MicroK8s. If the only configuration:
    cd $HOME
    mkdir .kube
    cd .kube
    microk8s config > config

Setup Alias

Edit bashrc file: echo "alias kubectl='microk8s kubectl'" >> ~/.bashrc
Execute: . ~/.bashrc

Install Helm

A number of packages are distributed using helm so its worth having that locally:

sudo snap install helm --classic

Join a Cluster

https://microk8s.io/docs/clustering

On existing node: microk8s add-node
On joining node: microk8s join ...

If the machines are local you might need to add the hostnames to /etc/hosts:
vi /etc/hosts
Append:
[ip address] [hostname]

09 September 2020

Remote desktop Mac to Ubuntu

It should be easy, and it is, but first a few hoops:

Using in build in 'vino'

  1. On Ubuntu install vino: sudo apt-get install -y vino
  2. Use 'Settings' app (top right via preferences, or apps, select Sharing
  3. Switch on at the top, and desktop sharing
    1. Set a password
    2. Ensure selected:
      1. "Allow other users to view your desktop"
      2. "Allow other users to control your desktop"
    3. Ensure NOT selected: "You must confirm each access to the this machine"
  4. Disable encryption on Ubuntu: gsettings set org.gnome.Vino require-encryption false
  5. Restart Ubuntu and log into it locally (Vino doesn't start until user logged in)

Using VNC

Vino is ok, but having to login first on the actual machine, and screen resolution pushed me to find another method: using VNC
  1. Install vnc: sudo apt update && sudo apt install -y xfce4 xfce4-goodies
  2. sudo apt install tightvncserver
  3. Setup default password: vncserver
    1. enter password
  4. Reconfigure vnc display:
    1. vncserver -kill :1
    2. copy config: mv ~/.vnc/xstartup ~/.vnc/xstartup.bak
    3. create startup script: vi ~/.vnc/xstartup
    4. Enter startup script:
      #!/bin/bash
      xrdb $HOME/.Xresources
      startxfce4 &
    5. Change to executable: sudo chmod +x ~/.vnc/xstartup
    6. Now connect...

To Connect

  1. Get Ubuntu ip address: apt-get install -y net-tools && ifconfig -a
  2. Connect using Screen Sharing app on Mac and ip address of Ubuntu machine

Installing Kubernetes (minikube) on Ubuntu

Prerequisites

Kubernetes

Optionally you might need to adjust the amount of memory kubernetes has:
  • minikube config set memory 8192
  • minikube delete
  • minikube start

Install Multiple Ubuntu Versions on the Same Computer

 You can have multiple versions of Ubuntu on the same computer using grub to switch between them.

  1. Install the first OS to the first disk
  2. Install the second OS to the second disk
If using multiple disks for different versions, after installing the second OS use grub to select the default using the first OS/disk. e.g. to select the second OS/disk as default boot:
  1. Log into the first OS/disk
  2. Edit grub: sudo vi /etc/default/grub
  3. Edit timeout to sufficient to see the menu e.g. 5
  4. Save, exit and run: update-grub
  5. Reboot and note the number of the second install in the list (index 1), but load the first
  6. Edit grub: sudo vi /etc/default/grub
  7. Edit default option

03 December 2018

Update packages for Ubuntu 18.04

Default package list is a bit short, so if you want to use standard packages you'll need to amend it:
  • Confirm it's release (you'll need this in the next step)
    cat /etc/*-release
  • For 18.04 Package isn't included in the default sources.
  • Search for it e.g. https://packages.ubuntu.com/search?keywords=xen-hypervisor&searchon=names
  • Modify the package sources list to include it's source:
    • sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup
    • vi /etc/apt/sources.list
    • Add:
      deb http://archive.ubuntu.com/ubuntu/ bionic main restricted universe multiverse
      deb http://archive.ubuntu.com/ubuntu/ bionic-updates main restricted universe multiverse
      deb http://archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse
      deb http://security.ubuntu.com/ubuntu bionic-security main restricted universe multiverse
      deb http://archive.canonical.com/ubuntu bionic partner
    • sudo apt-get update