Building kube-state-metrics from source

Today I had to build kube-state-metrics Kubernetes extra metrics exporter for Prometheus monitoring system. I wanted to build it for specific Linux (kernel) version (in my case it was Alpine Linux 3.4), and I also wanted to build a specific version of kube-state-metrics – latest stable, which is 1.3.1 currently.

I didn’t want to get latest version from master as I was not sure about it’s stability and I would have hard time re-creating the build since master would move on over time, so simply making “go get” wasn’t an option.

The process turned out to be a bit tricky – I wanted to use docker to have proper version of Go lang for Alpine Linux 3.4 while I’m on a macOS myself, but the makefile of kube-state-metrics also uses docker (for whatever silly reason that is), so I needed to build it using go build.

As it turned out, I had to do two things – install Go into Alpine 3.4 (which took some copypasting from https://github.com/docker-library/golang where they have Dockerfile for Alpine 3.7 – contents of which I used) and then get the paths right for GOPATH in order to build kube-state-metrics.

Here’s the resulting Dockerfile: Continue reading

Advertisements

OS X (macOS) Migration Assistant disk space bug

Hi all,

Have you ever encountered an issue with OS X (AKA macOS) Migration Assistant being stuck on restart and/or starting up screen? I know I have, and I know other people have too.

IMG_6818.JPG

If you don’t even know what Migration Assistant is, chances are you’ve used it anyway – because it’s run as an option on macOS installation – the one where you choose to import files from another drive/mac/etc. FYI.

The solution to the issue turned out to be rather simple in my case, but figuring it out took a couple of retries which all took several hours, so in total I’ve spent a few days (well, evenings) resolving the issue – and with this post I hope I can spare some people from repeating my fate.

Long story short, the issue was caused by a lack of disk space. Basically, if you choose not to import some files/folders in order to fit your data onto the target drive – Migration Assistant ignores that choice and tries to import everything. And when it runs out of disk space – it does not show any error or anything like that. Instead, import stops just as if all files were copied, installation proceeds to restart step (in case you’ve been doing it during macOS install like I did) – which gets stuck BTW. And on boot (by force reboot in my case) it was stuck on “Starting up” step. All because of lack of disk space.

The fix for me was to offload a particularly big folder to an external HDD, and then do the import.

That’s about it. Hope this helps.

RAM disk on OS X High Sierra

Here’s a code for creating RAM disk that works for me under OS X High Sierra.
One can change FS from HFS+ to something else (say, APSE, or case-sensitive/journaled FSs), but for me HFS+ is the one I want.

ramdiskSizeMB=$(osascript -e 'return text returned of (display dialog "RAM disk size in MB" default answer "1024")')
echo Creating RAM disk of size $ramdiskSizeMB MB
hdidOutput=$(hdid -nomount ram://$((2048*ramdiskSizeMB)) | cut -d ' ' -f 1) && diskutil erasedisk "HFS+" ramdisk $hdidOutput

To free the RAM one can simply unmount it in finder or DiskUtility.

P.S. Updated version with FS type selection:

#!/bin/bash

choiceScript='return choose from list {';
while read -r fsType 
do
  choiceScript="${choiceScript}\"$fsType\","
done <<EOT
$(diskutil listFilesystems -plist | grep Personality -A 1 | grep -F "<string>" | grep -E -o ">[^<]+<" | grep -o -E "[^><]+" | sort)
EOT
choiceScript="${choiceScript}\"\"} with prompt \"Choose filesystem type\" "

ramdiskSizeMB=$(osascript -e 'return text returned of (display dialog "RAM disk size in MB" default answer "1024")')
if [ "$ramdiskSizeMB" != "" ]
then
  fsType=$(osascript -e "$choiceScript")

  if [ "$fsType" != "false" ]
  then
    export ramdiskName=$(osascript -e 'return text returned of (display dialog "RAM disk name" default answer "ramdisk")')
    if [ "$ramdiskName" == "" ] 
    then
      ramdiskName="ramdisk"
    fi
  
    echo Creating RAM disk $ramdiskName of size $ramdiskSizeMB MB with FS type $fsType
    hdidOutput=$(hdid -nomount ram://$((2048*ramdiskSizeMB)) | cut -d ' ' -f 1) && diskutil erasedisk "$fsType" "$ramdiskName" $hdidOutput
  fi
fi

 

PiTFT on Raspberry Pi 3 under Jessie

I’ve been using successfully my 2.8″ 320×240 uTouch PiTFT with Raspberry Pi 1 and 2, but recently I’ve tried it with Pi 3 and got a 90-degree rotated touch input.

I’ve installed PiTFT support using adafruit-pitft-helper and this instruction at Adafruit. However, if did not help with the rotated input issue.

What did help was this StackOverflow answer and this manual on transformation matrix.

In short, I had to edit /usr/share/X11/xorg.conf.d/40-libinput.conf adding this to “libinput touchscreen catchall” section:

Option "TransformationMatrix" "0 -1 1 1 0 0 0 0 1"

This is a transformation matrix for 90 degree rotation of screen, which was the case for me.

Once done, the touchscreen input has got proper rotation.

TimeLapses with free software

The software that I use for processing and assembling timelapses now (on macOS):

Darktable is FOSS (GPL/CreativeCommons). Very powerful and quite awesome software, with somewhat clumsy user interface that doesn’t look like native app and takes a bit of getting used to, but is quite functional once you get used to it.

Darktable does the mass-edting of RAW files – all kinds of adjustments and color manipulations, cropping/rotation/resizing and export to JPEG.

Interval is a handy software for assembling bunch of JPEG images into a video file.