1 - Continuous Integration / Continuous Delivery

Tools

NameDescriptionUse
KindTool for running local Kubernetes clusters using Docker container “nodes”Testing chart functionality

2 - Development workstation with Multipass on MacOS

Requirements

  • An enabled hypervisor, either HyperKit or VirtualBox. HyperKit is the default hypervisor backend on MacOS Yosemite or later installed on a 2010 or newer Mac.
  • Administrative access on Mac.

Download, install and setup Multipass

There are two ways to install Multipass on MacOS: brew or the installer. Using brew is the simplest:

$ brew install --cask multipass

Check Multipass version which you are running:

$ multipass version 

Start a Multipass VM, then install Microk8s Brew is the easiest way to install Microk8s, but it is not so easy to install an older version. At the time of writing, Microk8s latest version v1.20 seems to have problem for Ingress to attach an external IP (127.0.0.1 on Microk8s vm). We recommend manual installation.

$ multipass launch --name microk8s-vm --cpus 2 --mem 4G --disk 40G 

Get a shell inside the newly created VM:

multipass shell microk8s-vm

Install Microk8s v1.19 in the VM:

$ sudo snap install microk8s --classic --channel=1.19/stable
$ sudo iptables -P FORWARD ACCEPT

List your Multik8s VM:

$ multipass list

Shutdown the VM

$ multipass stop microk8s-vm

Delete and cleanup the VM:

$ multipass delete microk8s-vm
$ multipass purge

3 - NixOS: Minikube

NixOS + Minikube

# Configure environment
cat <<EOF > default.nix
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
  buildInputs = with pkgs; [
    minikube
    kubernetes-helm
    jq
  ];

  shellHook = ''
    alias kubectl='minikube kubectl'
    . <(minikube completion bash)
    . <(helm completion bash)

    # kubectl and docker completion require the control plane to be running
    if [ $(minikube status -o json | jq -r .Host) = "Running" ]; then
            . <(kubectl completion bash)
            . <(minikube -p minikube docker-env)
    fi
  '';
}
EOF
nix-shell

minikube start

# Will block the terminal, will need to open a new one
minikube dashboard

# Creates "default-http-backend"
minikube addons enable ingress

4 - Ubuntu: microk8s

microk8s

sudo snap install microk8s --classic
microk8s enable dns fluentd ingress metrics-server prometheus rbac registry storage

# Install and configure the kubectl client
sudo snap install kubectl --classic
# Start running more than one cluster and you will be glad you did these steps
microk8s config |sed 's/\(user\|name\): admin/\1: microk8s-admin/' >${HOME}/.kube/microk8s.config
# On Mac, use below to set up the admin user
# microk8s config |sed 's/\([user\|name]\): admin/\1: microk8s-admin/' >${HOME}/.kube/microk8s.config
cat >>${HOME}/.profile <<'EOT'
DIR="${HOME}/.kube"
if [ -d "${DIR}" ]; then
  KUBECONFIG="$(/usr/bin/find $DIR \( -name 'config' -o -name '*.config' \) \( -type f -o -type l \) -print0 | tr '\0' ':')"
  KUBECONFIG="${KUBECONFIG%:}"
  export KUBECONFIG
fi
EOT
# logout or run the above code in your current shell to set the KUBECONFIG environment variable
kubectl config use-context microk8s

If you have an issue with the operation of microk8s microk8s inspect command is you best friend.

microk8s notes

To enable a Load Balancer microk8s comes with metalLB and configures Layer2 mode settings by default. You will be asked for an IPv4 block of addresses, ensure that the address block is in the same Layer 2 as your host, unused and reserved for this purpose (you may need to alter your DHCP service). When you are ready perform the following:

$ microk8s enable metallb
  • microk8s does not support IPv6 at this time!

5 - Windows 10: Multipass

Development workstation with Multipass on Windows 10

Requirements:

  • An enabled Hypervisor, either Hyper-V (recommended) or VirtualBox (introduces certain networking issues, if you are using VirtualBox on Windows 10 then use the VirtualBox UI directly or another package such as Vagrant)
  • Administrative access to Windows 10 workstation. This is required for:
    • Enabling Hyper-V if not already configured, or installing Oracle VirtualBox
    • Installing Multipass
    • Altering the local DNS override file c:\Windows\System32\drivers\etc\hosts

Windows PowerShell console as Administrator

Right click Windows PowerShell and select Run as Administrator, enter your Admin credentials. From the Administrator: Windows PowerShell console perform the following.

  • Open the DNS hosts file for editing.
PS C:\> notepad.exe C:\Windows\System32\drivers\etc\hosts
  • Verify Hyper-V state; the bellow shows that Hyper-V is Enabled on this workstation
PS C:\> Get-WindowsOptionalFeature -FeatureName Microsoft-Hyper-V-All -Online

FeatureName      : Microsoft-Hyper-V-All
DisplayName      : Hyper-V
Description      : Provides services and management tools for creating and running virtual machines and their
                   resources.
RestartRequired  : Possible
State            : Enabled
CustomProperties :

If this is not the case!

PS C:\> Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All

Download, install and setup Multipass

From the Multipass website, verify that your Windows 10 workstation meets the minimum requirements and then download the Windows installation file.

  1. Select Start button and then select Settings.
  2. In Settings, select System > About or type about in the search box.
  3. Under Windows specifications verify Edition and Version

Follow the installation instructions from the Multipass site selecting the preferred Hypervisor.

NB: The Environment variable that configure the search PATH to find the Multipass binaries will not be available until you logout and log back in.

Edit the workstations local DNS lookup/override file

This is required to direct your workstations browser and other clients to the development VM which runs your CTP and/or XNAT service.

For each service requiring a DNS entry you will need to add an entry into your hosts file. From your Notepad application opened as an Administrator you will need to enter the following.

C:\Windows\System32\drivers\etc\hosts

IP_Address_of_the_VM	fqdn.service.name fqdn2.service.name

Get the IP address of your VM

PS C:\> multipass exec vm-name -- ip addr

So if your VM’s IP address is 192.168.11.93 and your service FQDN is xnat.cmca.dev.local add the following entry into C:\Windows\System32\drivers\etc\hosts file and save.

C:\Windows\System32\drivers\etc\hosts

192.168.11.93	xnat.cmca.dev.local

Launch Ubuntu 20.04 LTS (Focal) with AIS development tools

PS C:\Users\00078081\ais> Invoke-WebRequest https://raw.githubusercontent.com/Australian-Imaging-Service/charts/main/contrib/cloud-init/user-data-dev-microk8s.yaml -OutFile user-data-dev-microk8s.yaml
PS C:\Users\00078081\ais> multipass launch --cpus 4 --mem 2G -nais-dev --cloud-init .\user-data-dev-microk8s.yaml

6 - XNAT chart README

# add the required helm repositories
helm repo add bitnami https://charts.bitnami.com/bitnami

# import the helm chart dependencies (e.g., PostgreSQL) from the xnat chart directory
# ensure you have cloned the repo and changed to charts/xnat directory before running this command
helm dependency update

# view the helm output without deployment from the xnat chart directory
helm install --debug --dry-run xnat ais/xnat  2>&1 |less

# create xnat namespace in kubernetes
kubectl create ns xnat

# Deploy the AIS XNAT service
helm upgrade xnat ais/xnat --install --values ./my-site-overrides.yaml --namespace xnat

# Watch the AIS goodness
watch kubectl -nxnat get all

# watch the logs scroll by
kubectl -nxnat logs xnat-xnat-web-0 -f

# find out what happened if pod does not start
kubectl -nxnat get pod xnat-xnat-web-0 -o json

# view the persistent volumes
kubectl -nxnat get pvc,pv

# view the content of a secret
kubectl -nxnat get secret xnat-xnat-web -o go-template='{{ index .data "xnat-conf.properties" }}' | base64 -d

# tear it all down
helm delete xnat -nxnat
kubectl -nxnat delete pod,svc,pvc --all
kubectl delete namespace xnat

8 -

Development instructions, recommendations, etc…

The /docs/_development folder is a dump directory for any documentation related to setup and practices of development related to the AIS released services.

Jekyll is used to render these documents and any MarkDown files with the appropriate FrontMatter tags will appear in the Development drop-down menu item.

https://australian-imaging-service.github.io/charts/