Friday, May 10, 2019

Running Minikube in Win10 Hyper-V without admin privileges

I wanted to try out minikube, and have access to a Windows 10 computer. Windows 10 has the MS hypervisor Hyper-V built in. There are several blog entries on getting minikube running in such an environment, but all of them that I found assume or explicitly state that you must run as an administrator on the Win10 host. Desktop security is part of my job, so I wanted to try and run minikube as a normal user. Here is how I got it working.

My Environment

  • Windows 10 1809
  • physical machine (not a VM, since we want to run a hypervisor)
  • minikube version 1.0.1
  • I log in and run things as an account that is only in .\Users, but I do have access to another account that is in .\Administrators (this is needed only for a couple of the setup steps)

Grant yourself permissions to manage Hyper-V

Win10 has a local group named "Hyper-V Administrators". All you need to do is ensure your normal, non-admin account is a member of this group.

NAT and DHCP on Win10

Hyper-V on Win10 only has three networking options for the VMs, at least that is all you see in the GUI. None of the options are NAT, which is what I want to use. There are powershell commands to create a NAT environment, but it still does not have a built-in DHCP service, like other hypervisors do. Here is how I got all of that running.

Create a NAT'd vSwitch

This command will create a new vSwitch (named "NAT") in HyperV


C:\Users\daves> New-VMSwitch -SwitchName "NAT" -SwitchType Internal

Name SwitchType NetAdapterInterfaceDescription
---- ---------- ------------------------------
NAT  Internal

You will need the ifIndex of the new switch's interface in a later step, so here is how to get it.


C:\Users\daves> get-netadapter | ft -Property Name,ifIndex

Name                         ifIndex
----                         -------
vEthernet (MinikubeLAN)           21
vEthernet (NAT)                   60
Wi-Fi                             15
Bluetooth Network Connection      14
Ethernet 2                         9
vEthernet (MinikubeWIFI)           8
vEthernet (Default Switch)        53
Ethernet                           5
Network Bridge                     3
In my case, the ifIndex of the interface is 60.

Configure the NAT gateway

Use the ifIndex from the adapter assigned to the new vSwitch (60 in my case). I am using private network 192.168.7.0/24 (GW will use 192.168.7.1).
This has to be run in an elevated powershell instance.

PS C:\WINDOWS\system32> New-NetIPAddress -IPAddress 192.168.7.1 -PrefixLength 24 -InterfaceIndex 60 


IPAddress         : 192.168.7.1
InterfaceIndex    : 60
InterfaceAlias    : vEthernet (NAT)
AddressFamily     : IPv4
Type              : Unicast
PrefixLength      : 24
PrefixOrigin      : Manual
SuffixOrigin      : Manual
AddressState      : Tentative
ValidLifetime     : Infinite ([TimeSpan]::MaxValue)
PreferredLifetime : Infinite ([TimeSpan]::MaxValue)
SkipAsSource      : False
PolicyStore       : ActiveStore

IPAddress         : 192.168.7.1
InterfaceIndex    : 60
InterfaceAlias    : vEthernet (NAT)
AddressFamily     : IPv4
Type              : Unicast
PrefixLength      : 24
PrefixOrigin      : Manual
SuffixOrigin      : Manual
AddressState      : Invalid
ValidLifetime     : Infinite ([TimeSpan]::MaxValue)
PreferredLifetime : Infinite ([TimeSpan]::MaxValue)
SkipAsSource      : False
PolicyStore       : PersistentStore


Create the NAT configuration. You will need to know the CIDR formatted network you selected from above (192.168.7.0/24 for me).
This also has to be run in an elevated powershell instance.

PS C:\WINDOWS\system32> New-NetNat -Name MyNATnetwork -InternalIPInterfaceAddressPrefix 192.168.7.0/24


Name                             : MyNATnetwork
ExternalIPInterfaceAddressPrefix :
InternalIPInterfaceAddressPrefix : 192.168.7.0/24
IcmpQueryTimeout                 : 30
TcpEstablishedConnectionTimeout  : 1800
TcpTransientConnectionTimeout    : 120
TcpFilteringBehavior             : AddressDependentFiltering
UdpFilteringBehavior             : AddressDependentFiltering
UdpIdleSessionTimeout            : 120
UdpInboundRefresh                : False
Store                            : Local
Active                           : True


Create and configure a DHCP service for you VMs


Installation is easy, and the download comes with a good readme. Here is a high-level summary of how I configured it.


  • Extract the files to C:\Program Files\DHCP\
  • From that folder, run dhcpwiz.exe
    • Select the NAT ethernet adapter created abovce for the NIC on which to run DHCP
      • Mine was labeled "vEthernet (NAT)"
    • Save the settings in an INI file
    • Enabling the HTTP web server will help you troubleshoot - go to http://127.0.0.1/dhcpstatus.xml to check the services status
    • Set your DNS server
      • I used OpenDNS
    • enter your network range
    • Under [Advanced] you can specify DNS and other services to be sent to DHCP clients
    • Use [Write INI file] to save your settings to C:\Program Files\DHCP\dhcpsrv.ini
    • Use the [Admin] button to install a Windows Service to run DHCP
      • The service will be named "dhcpServer" (Display name is "DHCP Server")
  • User powershell or the services control panel to start and stop the service. The service must be running when you start your minikube VM, or it won't get an IP address
Here is what my copy of dhcpsrv.ini looks like:


[SETTINGS]
IPPOOL_1=192.168.7.1-254
IPBIND_1=192.168.7.1
AssociateBindsToPools=1
Trace=1
DeleteOnRelease=0
ExpiredLeaseTimeout=3600

[GENERAL]
LEASETIME=31104000
NODETYPE=8
SUBNETMASK=255.255.255.0
NEXTSERVER=192.168.7.1
DNS_0=208.67.222.222
ROUTER_0=192.168.7.1

[DNS-SETTINGS]
EnableDNS=1
FORWARD=208.67.222.222

[TFTP-SETTINGS]
EnableTFTP=0
ROOT=C:\Program Files\DHCP\wwwroot
WritePermission=0

[HTTP-SETTINGS]
EnableHTTP=1
ROOT=C:\Program Files\DHCP\wwwroot


As the service leases addresses, they will show up in this file as well.


Install minikube

Install kubectl through the powershell gallery

https://kubernetes.io/docs/tasks/tools/install-kubectl/

I want my minikube related executables in c:\bin\ (which is in the systems PATH env variable)

C:\Users\daves> Install-Script -Name install-kubectl -Scope CurrentUser -Force

C:\Users\daves> install-kubectl.ps1 -Downloadlocation "C:\bin\"
==>analyzing Downloadlink
==>starting 'C:\users\daves\AppData\bin\kubectl.exe version'
Client Version: version.Info{Major:"1", Minor:"14", GitVersion:"v1.14.0", GitCommit:"641856db18352033a0d96dbc99153fa3b27298e5", GitTreeState:"clean", BuildDate:"2019-03-25T15:53:57Z", GoVersion:"go1.12.1", Compiler:"gc", Platform:"windows/amd64"}
Unable to connect to the server: dial tcp [::1]:8080: connectex: No connection could be made because the target machine actively refused it.

You can now start kubectl from C:\bin\kubectl.exe

copy your remote kubernetes cluster information to C:\Users\daves\.kube/config

Install minikube


To install Minikube manually on Windows, download minikube-windows-amd64, rename it to minikube.exe, and add it to your path. I installed it to C:\bin\

Configure user environment variables for minikube

In a powershell, as the non-admin user you want to run minikube as, add an env variable named "MINIKUBE_HOME". This is a single command, and you will need to reload your shell when done.

C:\Users\daves> [System.Environment]::SetEnvironmentVariable('MINIKUBE_HOME', 'C:\Users\daves\.minikube', [System.EnvironmentVariableTarget]::User)

Configure minikube to use Hyper-V and your NAT'd switch by default

While you can specify the hypervisor and switch in command arguments, I like to set defaults.

C:\Users\daves> minikube config set vm-driver hyperv
!   These changes will take effect upon a minikube delete and then a minikube start
C:\Users\daves> minikube config set hyperv-virtual-switch NAT

Start minikube

Be sure your dhcpServer service is running!

This takes a few minutes, so be patient. You can troubleshoot by making the output more verbose with the arguments "--v=7 --alsologtostderr". You can also watch some of the progress in the Hyper-V admin console.

C:\Users\daves> minikube start
o   minikube v1.0.1 on windows (amd64)
$   Downloading Kubernetes v1.14.1 images in the background ...
>   Creating hyperv VM (CPUs=2, Memory=2048MB, Disk=20000MB) ...
-   "minikube" IP address is 192.168.7.5
-   Configuring Docker as the container runtime ...
-   Version of container runtime is 18.06.3-ce
:   Waiting for image downloads to complete ...
-   Preparing Kubernetes environment ...
-   Pulling images required by Kubernetes v1.14.1 ...
-   Launching Kubernetes v1.14.1 using kubeadm ...
:   Waiting for pods: apiserver proxy etcd scheduler controller dns
-   Configuring cluster permissions ...
-   Verifying component health .....
+   kubectl is now configured to use "minikube"
=   Done! Thank you for using minikube!

Now you can experiment with kubectl and minicube commands against your minikube instance.

Clean up

Stopping the minikube VM doesn't work with the default command for me. Here is a discussion on the topic

The command "minikube stop" should stop the VM, but doesn't in my current lab. This command works fine:

C:\Users\daves> minikube ssh "sudo shutdown -h now"

If you are done, you can delete the minikube VM.

C:\Users\daves> minikube delete
x   Deleting "minikube" from hyperv ...
-   The "minikube" cluster has been deleted.






Friday, November 2, 2018

Filtering MIDI volume and expression with an Arduino

I need a MIDI filter that simply filters volume and expression CC messages. I use a Hammond XK3c for organ and as a controller for a Yamaha Motif-Rack ES. The organ has two manuals, so in many cases I am playing organ on one and synth on the other. In such cases, I need to be able to change the organ's volume, but I don't want the synth to change volume (at least not the same as the organ). Thanks to Arduino community,  the awesome SparkFunMIDI tutorial, and other places on the Web, I came up with the working code below. This controls an Arduino and the MIDI Shield very well. I'm happy with the functionality.

#include
/*
* MIDI_FilterExp.ino 
* David Summers
* 2018.01.03

* Reads MIDI IN, passes every message except
* CC mnessages for Expression (CC11) and Volume (CC04).
* Useful for controllers that send such data, 
* but you wish for the controlled tone module to ignore it. 
* I use this to control a Yamaha Motif-Rack ES from 
* a Hammond XK3c; I want my expression pedal to
* effect the organ, but not anything on the Motif.
*/
MIDI_CREATE_DEFAULT_INSTANCE();
static const unsigned ledPinG = 6;      // LED pin on Arduino Uno
static const unsigned ledPinR = 7;      // LED pin on Arduino Uno

void setup() 
{
  pinMode(ledPinG, OUTPUT);
  pinMode(ledPinR, OUTPUT);
  MIDI.begin(MIDI_CHANNEL_OMNI);
  digitalWrite(ledPinG, LOW);
  digitalWrite(ledPinR, HIGH);
  MIDI.turnThruOff();
}

void loop()
{
  //digitalWrite(ledPinR, LOW);
  if (MIDI.read())
  {
    
    switch(MIDI.getType()) // Get the type of the message we caught
    {
      //Capture Control Change messages     
      case midi::ControlChange :
        
        //Capture Expression OR Volume CC messages
        if (MIDI.getData1() == 11 || MIDI.getData1() == 4)
        {
          //Don't pass data
          digitalWrite(ledPinR, LOW);
        }
        //All other CC messages
        else
        {
          MIDI.sendControlChange(MIDI.getData1(), MIDI.getData2(), MIDI.getChannel());
        }
        delay(0);
        digitalWrite(ledPinR, HIGH);
      break;
      
      default:
        //digitalWrite(ledPinR, LOW);
        MIDI.send(MIDI.getType(),
                   MIDI.getData1(),
                   MIDI.getData2(),
                   MIDI.getChannel());
        delay(0);
        //digitalWrite(ledPinR, HIGH);
      break;  
      
    }
  }
}

Thursday, June 19, 2014

'69 beetle and the turn signal indicator that wanted to be grounded

I found that the light bulb assembly for my turn signal indicator was wired in a non-standard way. Somebody in the past had soldered a wire to the metal jacket and hard wired it to ground. They also wrapped it in rubber insulation so that the assembly would not conduct through the socket in the speedometer. The generator and oil lights remain unmolested and work as the should. My inner picture-straightener took over, and I began to undo this - I want close to stock electrical and the assembly did not fit inside the socket very well anyway (which caused a dim turn signal indicator). With the light assembly returned to normal, the light no longer flashes with the turn signals (they work fine, by the way). I confirmed that there is good conductivity by testing with a DVM and swapping light assemblies. The generator light assembly, when moved as a whole into the socket for the turn signal, works as expected; the turn signal assembly, when moved to the generator's socket, does not work.

The wiring between the speedometer and the top of the fuse box seems to be correct, per Bentley. There is a single wire coming from all three indicator lights going into the left-most (front is front) two fuses.

My turn signals work as expected regardless of how the indicator light is wired.

The flasher is part  DNI 0214 S4. Here is a photo:

And here is a schematic:
http://www.dni.com.br/media/Manual_DNI_0412S4.pdf


I found this hint:
"NOTE! If the Turn Signal Indicator Bulb does not blink when the turn signals are on, move the wire from the KBL terminal to the 49a terminal (use a piggyback or jumper connection) with the Black/White/Green wire."
here:
http://www.jbugs.com/product/211953215C.html?Category_Code=vw-bug-switches-flashers-relays-1968-70

I hookled the light up to terminal 49a and it is working fine.


Here is a nice wiring diagram:
http://www.oldvolkshome.com/6870turnswitcht1_OVH.pdf

Glutamoto has a great explanation at:
http://www.thesamba.com/vw/forum/archive/index.php/o-t--t-508609--.html

Friday, September 20, 2013

How to be a keyboardist in a band

A friend asked if I would teach his classically trained pianist daughter how to play in a band. I said "no"....

Actually I declined because I don't have any time and I don't think I have very much to teach. I want to share what I do know though.


  1. Learn your chords. Sight reading is great, but doesn't help you communicate with a lot of amateur musicians. Most of them will know their chords though and so should you. First know all the simple triads, both minor and major. Next learn the dominant chords, with the lowered 7th. Next learn what diminished and augmented chords are. Finally, learn the rest such as 13th, b9 major 7th, etc. I won't go into what these are here. It is incredibly valuable to be able to instantly recall any of these. This skill will be used in many of the following points.

  2. Chart out the tunes you will be playing. When you know what songs you will be playing, get a copy of each and listen to them. Listen to them again, paying attention to the general structure like verse 1, chorus, verse 2, chorus, bridge, chorus (I prefer simple section labels like "A", "B", "I" for intro, etc.). Listen for where sections can be defined and where they are repeated. Write this down, and then study each section. Determine what the chord changes are (more on this later), where you'll play what, articulations, etc. Marking sections first saves you time because once you've figured out how one section goes, you don't have to do so again for the repeats. With the cart, you can see the flow of the song and what to play when. Write it all down and use it to rehearse until you have memorized the song.

    Many amateur musicians do not do this - maybe even most; they rely on their memory of when they heard the song over the radio or in their car. Many of them are very good at doing it this way, and many of them are not as good at this as they think they are. Charting forces you to study the tune and helps you play it correctly and consistently.

  3. Be prepared and able to change a song. Don't feel frustrated if you spent time charting a song only to have another band member argue that it is wrong. There could be many reasons for this, such as different recordings or maybe that person has played it a different way for years and is more comfortable. Be a team player, discuss the implications of playing the song one way or another, and come to an agreement. It is easy to become adamant about a way a song should be played, but this makes the band less fun. If you feel strongly about how a song should go, make your case in a friendly way and allow the majority to win.

    Related to this, you should also be adept at transposing songs. Many keyboards have a built in transpose function; that is alright if you are careful to set it back when you are done. I've forgotten to do this enough times that i just avoid using the transpose button. You'll be a valuable asset to any band if you can transpose on the fly, especially to vocalists.

  4. Don't always play. You don't have to fill every empty space of a song. If you don't hear keyboard parts in a section, try staying out of it. Amateur musicians have a hard time with this and with dynamics in general, but it is a critical part of music.

  5. Steal solos. This is related to number 2, but I don't do this at the same time. Listen to, write out, and memorize solos that you enjoy. I use a program called trascribe! to help me with this. It allows you to slow down a song to help you figure it out (it does much more as well - I highly recommended this tool).
That's what I can think of for now.

Tuesday, May 10, 2011

10 years

Today University of Idaho is holding a Staff Appreciation ceremony. If I were to go, they'd give me a mug or something for 10 years of being employed at UI (it's actually been longer, I don't know how they calculate it). This isn't where I imagined I'd be when I would day dream of my future life as a teenager; but it pays the bills I suppose. I hope they will mail my mug to me, because I'm a bit too busy with work to attend the ceremony.

Tuesday, April 19, 2011

Motorcycling - Spring 2011

I got my motorcycle out and rode it to work this morning.

Now I am torn. I had convinced myself that I would sell the ninja to help pay off my keyboard. Also, there are things I just don't like about the ninja.

This morning's ride reminded me how much I enjoy riding. It's going to be hard to convince myself to go ahead and sell the ninja.

Monday, March 7, 2011

Repairing the vibrato in my Hammond A100

Recently and suddenly, the quality of the vibrato and chorus on my Hammond A100 went bad.

I posted questions at the Hammond Zone yahoo group and Keyboard magazine forums and got some great advice.

Using this advice, I tested the wires that connect the scanner to the vibrato filter box and the switches. These all tested good.
There appears to be evidence that someone has (poorly) resoldered these wires in the past:



























Here is an image of the scanner in the A100. It is the round thing on the left:



Googling the issue led me to learn about zinc dendrites that tend to grow in some of the electronics in these old organs.

I used a continuity tester to see if there was a connection between any of the brass screw connectors on the scanner and the scanner case (which is grounded). As you can see in the video below, there indeed was a connection on one of them.

Since the connections proved to be sound, my options were to either open the scanner up to clean or try the "zap" method to fry the zinc dendrites that tend to grow in these old organs.

On the Web there seem to be two lines of thought: zapping is too risky and zapping is fine (with proper precautions).

I really didn't want to open the scanner up, since there are fragile parts such as the oiling wicks and the axle.

After reading about the zapping method, and learning more about how the scanner works and what connections it has, I decided I was comfortable trying it.

The idea is that you apply a voltage across the dendrite, effectively turning it into a fuse which you "blow". In my case, I used a pair of 9 volt batteries in series to achieve an 18 volt source.




























I used an alligator clip to connect the positive post of the battery to the scanner body:


























With a wire connected to the negative post of the battery, I touched the brass screw on the scanner that allowed current through when previously tested with the continuity tester. There was no spark or pop etc. Continuity test failed after this, proving the dendrite was no longer conducting electricity.

After disconnecting the battery, I turned the organ on and the vibrato was back to its old self!

Here's a video I shot of the sound and testing for the dendrite:


And here are the photos I took during the operation:
https://picasaweb.google.com/davyyd/FixedA100Vibrato#