PostsAboutGames
All posts tagged with linux

Copy microk8s.kubectl config to Windows kubectl

September 10, 2019 - Søren Alsbjerg Hørup

For testing purposes, I recently installed Kubernetes on an Ubuntu Server VM, running on my XEN Server, through the use of the Microk8s package:

https://microk8s.io/

Installation was a breeze, and I quickly got Kubernetes up and running and was able to interact with it using microk8s.kubectl. Microk8s.kubectl is a version of kubectl having it’s own configuration pointing to the locally installed Kubernetes. This avoid conflicting with the standard kubectl which would have had its configuration overwritten by the microk8s package.

On my Windows developer PC, I wanted the ability to access the cluster using kubectl without having to run microk8s.kubectl through an SSH session.

To do this, one first have to find the kubectl config yaml file. This resides in the %userprofile%\.kube directory. If the file is not there, create it.

Configuration of the file to match that of microk8s.kubectl can be done copy paste the configuration of microk8s.kubectl and replace localhost with the external IP of the cluster. This can be done through SSH using the config view command.

$ microk8s.kubectl config view

apiVersion: v1
clusters:
- cluster:
    server: https://<externalip>:<externalport>
  name: microk8s-cluster
contexts:
- context:
    cluster: microk8s-cluster
    user: admin
  name: microk8s
current-context: microk8s
kind: Config
preferences: {}
users:
- name: admin
  user:
    password: <password>
    username: admin

Now, copy paste to the config file on Windows, and replace localhost with the external IP of the cluster.

In addition, if the SSL certificate is untrusted on the cluster (which it typically is), make sure to add insecure-skip-tls-verify: true under the cluster part.

The final config file should look like this:

apiVersion: v1
clusters:
- cluster:
    insecure-skip-tls-verify: true
    server: https://<externalip>:<externalport>
  name: microk8s-cluster
contexts:
- context:
    cluster: microk8s-cluster
    user: admin
  name: microk8s
current-context: microk8s
kind: Config
preferences: {}
users:
- name: admin
  user:
    password: <password>
    username: admin

If everything is well, executing kubectl get services on Windows should return at-least the Kubernetes service.

Lakka 50hz vs 60hz

December 05, 2017 - Søren Alsbjerg Hørup

Lakka supports Raspberry Pi 3 and I wanted to see if it was indeed powerfull enough to run SNES and N64 emulation.

I flashed a Microsd with the latest Lakka image and tested the setup using my 42” Panasonic Plasma. First impressions were very bad, Super Mario World was choppy and the sound was glitchy.

Changing resolution of retro-arch from 1920x1080 to 1280x720 helped a bit, but still the performance was not acceptable. I tried with vsync off and on, but the performance still seemed bad.

After tweaking a bit, I noticed that the FPS was locked at 50 when inside the menu. It seemed my TV was running 50Hz and not 60Hz. The Super Mario World rom was the NTSC version, i.e. 59.99Hz version, which ofcourse meant that 50Hz would feel bad.

I connected with SSH and using tvservice to see what my output was. Indeed, 1920x1080x50hz was my output!! What the hell…

Luckily, this can be changed within the config.txt file residing in /flash. (Remember to remount flash with write permissions since it is readonly by default)

Adding the following lines to config.txt fixed my issue:

hdmi_drive=2 hdmi_group=1 hdmi_mode=16

the lines above configures the output to be HDMI with audio with a specific mode. Mode defines the resolution and refresh-rate, e.g. mode 16 is 1920x1080x60hz while mode 31 is 1920x1080x50hz. Mode 31 was selected by default in my setup apparently.

After a reboot, everything was smooth as silk.

.NET Core

June 30, 2017 - Søren Alsbjerg Hørup

.NET Core is yet another .NET framework implementation implementing .NET Standard 1 (production) and .NET Standard 2 (beta) while also extending the standard with .NET core specific API’s such as Console and Thread (which are not part of the .NET Standard).

The cool thing with .NET Core is that it is: 100% open-source, 100% cross-platform and very modular. This stands in contrast to .NET and Mono since these are very monolithic implementations and huge in size. The source is available under MIT on GitHub: https://github.com/dotnet/core

Since .NET Core is very crossplatform, one can write .NET applications for x86/ARM Windows and x86/ARM Linux - and since it is very modular, the framework does not occupy much space compared to the desktop implementations.

API’s are generally not available in the framework but needs to be downloaded from NuGet, e.g. EntityFramework, ASP.NET, and even some Reflection support are an “add-on”.

I measured the raw framework installation on my Win 10 x64 box to about 70MB, while the .NET 4.6 framework is roughly 2000MB in size, that is, 28 times larger! Deployment wise, .NET Core SDK supports deploying application + framework meaning that the target does not have to have the specific framework installed.

The SDK will automatically pull all the dependencies into the publish package, which includes all NuGet dlls + native assemblies where applicable (e.g. if using sqlite .NET core wrapper). One can also publish to a specific target, such as Linux-x86 or Linux-arm, which will produce a platform specific package with an elf executable that can be executed.

Referencing .NET assemblies which does not target .NET Standard or .NET Core is not possible in .NET Core 1.1 since the APIs are incompatible. .NET Core 2.0 will include a compatibility layer making it possible to reference assemblies targeting other frameworks - although this sounds awesome, I have not experimented with this feature yet.

.NET Core is without a doubt the future of .NET!

MariaDB: Access from 0.0.0.0

March 29, 2017 - Søren Alsbjerg Hørup

I recently installed MariaDB, a MySQL fork, on a Linux VM in the cloud for testing and development purposes. I really struggled with getting proper access from my dev machine to the installation in the cloud.

Simply put, I just wanted a totally open SQL database for deving and testing, nothing production wise was needed.

MariaDB is by standard pretty secure: a good thing, and does not allow remote access: also a good thing.

Firstly, one has to edit the proper .cnf file under /etc/mysql/* and set the bind-address from 127.0.0.1 to 0.0.0.0. MariaDB by default listens only on the loopback interface, thus making it impossible to reach it from outside either LAN or WAN.

Next up, one needs to restart the service: service mysql restart which will apply the changed bind-address.

Now it is possible to connect from outside, TCP/IP wise, however, the MariaDB user (such as root) needs to be granted access from outside to be able to actually make a logical connection to the DBMS.

This can be done by issuing the following SQL query (in this case, for root with password xyzw):

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'xyzw' WITH GRANT OPTION;

Which will grant root access level from anywhere.

To fire off this SQL, I suggest to simply login to the box using SSH and connect to the mysql CLI using:

sudo mysql -u root

and then fire off the query.

Node on Raspberry PI

March 15, 2017 - Søren Alsbjerg Hørup

I recently re-installed a PI with NodeJS support and MariaDB support.

NodeJS is not known by apt-get (a strange beta/alpha version is present, version 0.10 or something, not what we want).

I found this guide for the job: http://thisdavej.com/beginners-guide-to-installing-node-js-on-a-raspberry-pi/

More or less, execute the script located at deb.nodesources using:

curl -sL https://deb.nodesource.com/setup\_7.x | sudo -E bash -

and then proceed with apt-get install

sudo apt-get install nodejs

Simply as that!

Tagged: linux node

USB On-The-Go

January 15, 2017 - Søren Alsbjerg Hørup

I recently acquired an USB OTG adapter for my Android devices. I wanted to see what kind of peripherals I could connect and if they would function correctly.

The first peripheral I tried was a standard HP USB Keyboard, nothing fancy. This worked on both my Galaxy Tab A 10.1 (2016) device and on my Galaxy S5 phone. I also tried a no-name wireless keyboard with a small USB dongle, this also worked fantastic. The latter has built in mouse which was also recognized by both my devices.

Next I tried a XBOX 360 Wireless controller with USB dongle. No dice on my Tab A but working fine on my Galaxy S5. My Galaxy S5 has been flashed to cyanogenmod 14 with a 3.4 kernel while the Tab A is still running an unrooted stock 6.1 with a 3.1 kernel. My guess is that the Tab A’s 3.1 kernel has not been compiled with the xpad driver needed to run the XBOX 360 wireless controller, since it seems that the dongle gets power just fine by the micro USB port.

A quick google search has confirmed this. Apparently very few Samsung devices running android 5+ support the xpad driver out of the box.

Next step in this endeavor is to root the Galaxy Tab A and get the xpad driver loaded.