Manage Kubernetes with Visual Studio Code

Summary

This is a walkthrough to setup Visual Studio Code (VSCode) to manage an external Kubernetes cluster. In this example, VSCode will be connected to a Kubernetes Cluster running on Raspberry Pi. The VSCode extension provides visual object navigation of the cluster and terminal execution of kubectl to modify cluster objects.

Prerequisites

Description

The following steps will reference a Linux Kubernetes cluster as the source system and a Windows environment as the target system. For these steps there is an assumption that the Kubernetes configuration file (kubeconfig) has been added to the user profile of the master node on the Linux cluster.

pirate – is the Linux user profile (based on the Hypriot distribution)
192.168.0.20 / k8spiblue – is the Linux master node IP / hostname
192.168.0.21 / k8spiblack – is a Linux worker node IP / hostname
192.168.0.22 / k8spiyellow – is a Linux worker node IP / hostname
torben – is the Windows user profile

Steps

From the Windows target system, copy the Kubernetes configuration file (kubeconfig) from the Linux user profile to the Windows user profile.

C:\Users\Torben>scp pirate@192.168.0.20:/home/pirate/.kube/config ./.kube/config

Enter a password for the user (pirate) when prompted and perform a directory listing for verification

Copy kubeconfig

Launch VSCode, click Extensions on the Activity bar and search the Marketplace for ‘Kubernetes’.
Click ‘Install’ and install any dependencies if required, such as Kubectl and Helm.

VSCode Kubernetes

When installation is complete, select ‘Kubernetes’ from the Activity bar to open.

K8s Extension Installed

In the Kubernetes side bar, hover over Clusters and click the ellipses ‘…’ to select ‘Set kubeconfig’.
Select ‘+ Add new kubeconfig’ and navigate to the config file copied previously (%USERPROFILE%\.kube\config).
The Clusters node should now be connected to the remote cluster and the nodes can be expanded to show the cluster hosts.

K8s Cluster Configured

Expand a node to see the pods.

K8s Cluster Nodes

In the Terminal window, execute kubectl get nodes to get listing of the cluster nodes

K8s kubectl nodes

Select Explorer extension on the Activity pane and we can now edit object files and apply them with kubectl directly from Windows.

K8s File Explorer

Blinkt! Rainbow on Pi Kubernetes

Summary

Blinkt! is an LED light strip attachable to the GPIO extension on Raspberry Pi’s. Sealsystems provides a rainbow container that creates a rainbow of the LEDs and can be orchestrated on a Docker cluster using the Swarm orchestrator. This is a description of how to run the rainbow on a Kubernetes cluster.

Rainbow Pi Cluster

Prerequisites

Description

The Rainbow container uses the node package (npm), node-blinkt, to interact with the LEDs through the host GPIO. To access the GPIO, the container will need access to the host’s /sys directory which acts as a virtual filesystem for the system devices (/sys/devices/gpiochip2/gpio/). Mount the host’s /sys directory to the container and the Blinkt! package will be able to access the GPIO.

        containers:
             - name: rainbow
               image: sealsystems/rainbow:latest
               volumeMounts:
                       - name: sys
                         mountPath: /sys
        volumes:
             - name: sys
               hostPath: 
                   path: /sys

There is only one GPIO and Blinkt! light per host so running the rainbow container as a DaemonSet will ensure that only one (1) container is run on each host in the cluster.

apiVersion: apps/v1
kind: DaemonSet
metadata:
    name: rainbow

By default the master node will be excluded from cluster nodes in the DaemonSet so in a 5-node cluster, only the (four) 4 worker nodes will light up.

Rainbow Pi Cluster
Default DaemonSet on 5-node cluster

Use tolerations to enable the DaemonSet to to run on the master node.

spec:
# this toleration is to have a daemonset run or not run on the master node
# key - node key to identify master node
# effect - specifies whether to run (NoSchedule) or not run (NoExecute)
    tolerations:
         - key: node-role.kubernetes.io/master
           effect: NoSchedule
Rainbow Pi Cluster
DaemonSet on 5-node cluster with NoSchedule tolerations

Steps

Create yaml file, rainbow.yml

apiVersion: apps/v1
kind: DaemonSet
metadata:
    name: rainbow
spec:
    selector:
        matchLabels:
            name: rainbow
    template:
        metadata:
            labels:
                name: rainbow
        spec:
            tolerations:
                 - key: node-role.kubernetes.io/master
                   effect: NoSchedule
            containers:
                 - name: rainbow
                   image: sealsystems/rainbow:latest
                   volumeMounts:
                           - name: sys
                             mountPath: /sys
            volumes:
                 - name: sys
                   hostPath: 
                       path: /sys

Apply to cluster:
kubectl apply -f rainbow.yml

Content Caching

Bookqueue II and Moviequeue v1.16 introduced content caching. As previously outlined in Bookqueue, we have a problem, the new update is intended to help increase availability of content. The content caching is On by default but can be turned Off in the Settings under Amazon. Look for the Content Caching section.

Content Caching in Windows
Content Caching on Android

When turning Content Caching Off, the change will not be immediate but takes effect the next time the application is restarted.

Caching is limited in size to approximately 1MB on the device. If the cache gets larger, it will automatically delete its cache to make room for new content.

The Future of Bookqueue

A new chapter is about to start for Bookqueue!  As highlighted in a previous post – “Bookqueue, we have a problem”, new challenges presents new opportunities. How the journey will end is unknown as of this writing, but at this time Bookqueue is continuing on.

Bookqueue was originally created to serve my family since its inception in 2012. The family and community has been great supporters of the application over the years and finding this new challenge has not made anyone particularly happy.  Especially my spouse and you probably know what they say “When Mommy isn’t happy…”. So, we are going to work on getting Bookqueue back to making everyone happy!

Short-term

There are short-term bug fixes and updates that will come to Bookqueue to remove crashes and provide better error information. This will include removal of localized Amazon countries where Bookqueue usage was low and subsequently blocked. The outcome of these changes should bring some stability to the application although its capabilities will be limited in nature under current constraints.

Mid/Long-term

Ideas are starting as to how we can bring Bookqueue capabilities back to full throttle. These include ways for how our family and community members can help drive advertising revenue activity within a continuous 30-day timespan to satisfy the Amazon Efficiency Guidelines and not be throttled. We are still seeking to limit the ‘book sell’ feature of Bookqueue but may have to move from a passive to a semi-active process to meet Amazon guidelines.   Alternatives to utilizing the Amazon advertising system as the content provider are being considered but at a low priority as Bookqueue’s value has been directly attributed to Amazon’s backend systems.

I plan to provide periodic updates when available, but welcome community feedback if you have suggestions as to how Bookqueue can thrive in the new norm. Happy reading!

Bookqueue, we have a problem

Bookqueue, we have a problem. I have recently observed and been notified by Bookqueue users of crashes and error messages stating that it is submitting requests too quickly. Initial symptoms indicated a bug in the application but once I started to debug I discovered that (beyond bugs) the issue runs much deeper.

The main problem that has come up is that Amazon has changed its request throttling logic as of January 23rd, 2019 based on new Efficiency Guidelines. Though the change in Amazon’s guidelines has directly impacted the usability of Bookqueue, I want to stress this is NOT Amazon’s fault.  Instead, the impact is caused by opposing design intents between Bookqueue and Amazon.

To give some history, Bookqueue, came about in 2012 based on a family need to help better find and manage books. We were/are avid eBook readers (particularly my spouse) using Amazon Kindles and found ourselves buying books on a continuous basis. The continuous basis ended up creating a pre-purchased queue of books for future reading. This ‘pre-purchased queue’ created an opportunity to not only help our bank account but also our mental buyers remorse of not reading a previously purchased book when coming across a new book of greater interest. Many applications were available at the time to solve this, such as goodreads, but we were interested in something more targeted to our needs. Hence the first release of Bookqueue for Windows Phone 7 in 2012.

Bookqueue v1

First Bookqueue release on Windows Phone 7

Bookqueue Information Architecture

Original Information Architecture design for Bookqueue

As we were targeting Amazon’s Kindle book catalog, Bookqueue takes advantage of a public application programming interface that Amazon utilizes for its affiliate partners to advertise its full product catalog, not just books. It is this interface that is impacted by the new Efficiency Guidelines. Back in 2012 and up until January 23, 2019, there has always been an effective throttle limit adhered to by Bookqueue as to how frequently it could call the interface for book searches, descriptions, author searches, similar book searches, etc.

Until now, frequency, has been the only factor applied to the throttle limit for using the advertising interface. The new guidelines adds a second factor in the form of – generated advertising revenue. This advertising revenue is generated by Bookqueue if a user chooses to go through Bookqueue’s link to view the book on Amazon and subsequently purchases the book on the Amazon website.

Some Bookqueue users have utilized this feature to purchase books in the past which provided small advertising revenue to buy a book every now and then and has been greatly appreciated. However, direct advertising revenue was not a driver for Bookqueue because its primary design function was to create value for the book reader, not selling books. Selling for revenue was the lowest priority of Bookqueue, hence the reason it started out and remains free of in-app ads.

This brings us back to the beginning of how Bookqueue is impacted by the new Amazon efficiency guidelines. As the new guidelines are in effect, Bookqueue has not generated advertising revenue in 30-days which has triggered the multi-factor throttle limit on requests. Additionally, inactivity (no usage) in countries with localized Amazon regions has caused the advertising interface to be closed completely.

Now what?

Without doubt, Bookqueue’s value for the past many years has been completely attributed to Amazon’s incredible product advertising system. It is also understandable that Amazon has to manage their operational efficiencies and balance the cost of supporting an advertising system against its generated revenue. This balance places Bookqueue in a challenging position to its future as to whether it can be successful under these constraints.

I don’t have an answer yet – but will offer the following suggestions to existing Bookqueue users:

  1. The Future of Bookqueue – outlines current thinking to what changes Bookqueue will see should you choose to follow us further in the reader journey
  2. Export your Bookqueue books – provides a step-by-step guide as to how you can retrieve all your books from the app in case your Bookqueue journey ends now

Regardless of your decision to continue or leave Bookqueue, I would like to thank the community for the incredible feedback and support you have provided through the years. Our family’s reader experience has benefited from your many feature suggestions and input. As always, your comments/feedback to this post and the future of Bookqueue is much appreciated.

Thank you!

Note: this article also applies to Bookqueue’s sister application, Moviequeue.

Export your Bookqueue books

Bookqueue and Bookqueue II provide an “Export to File” feature that creates a comma separated file of all your queued books.  This feature is convenient if you wish to have an offline backup or need to transfer your books to a different application.  The following steps illustrate how to use the “Export to File” feature.

Windows 10 & Windows 10 Mobile

Step 1) Select the hamburger menu in the top-left corner of the application

Bookqueue Home Screen

Step 2) Select the “Settings” menu item

Step 3) Select the “Export to File” button

Step 4) Select “Save” in the Save As dialog

Step 5) Select “OK” at the Export Confirmation dialog

Step 6) Open the “Bookqueue.csv” file in Excel, Notepad, or equivalent to view your book list

Android

Step 1) Select the hamburger menu in the top-left corner of the application

Step 2) Select the “Settings” menu item

Step 3) Select the “Export to File” button

Step 4) Select “Save” in the Save As dialog

Step 5) Select “OK” at the Export Confirmation dialog

Step 7) Use “My Files” or equivalent to browse device files

Step 7) Browse to the export location (Internal storage > Download) and select “Bookqueue.csv” file

Step 8) Bookqueue.csv file will open in Excel (if installed) to view your book list

 

 

Moviequeue Released

Moviequeue logoWith the recent release of Bookqueue II, it was a good opportunity to bring a sister application online, Moviequeue.  Moviequeue follows its older sister’s objective and features of finding and queuing movies for reference and/or later viewing.  The application is integrated with Amazon Video for searching the Amazon video catalog and ability to filter based on online or physical movie media.

Features
– Find movies by type (Amazon Video, All Movies)
– Queued movies automatically added to your Queue shelf
– Manage movies across multiple shelves, such as Watching and Archive
– Sort and order moves by priority and title
– Add reminders for pre-release titles so you get notified on the date of its release
– Customize shelves by adding your own shelf title (for example, Fiction vs. Non-Fiction, Documentaries, etc.)
– Direct link to Amazon for full movie details
– Easily search similar movies for movie recommendations
– Find latest Bestsellers
– Synchronize your device movies to OneDrive for backup and/or sharing across devices

Platform Availability
Moviequeue is available for Windows 10 and Android via the Windows and Google Play app stores.

Bookqueue II Released

Bookqueue II imageThe holidays brought a little downtime to get a long overdue successor to Bookqueue released to the store, Bookqueue II. The purpose of Bookqueue II remains the same as Bookqueue, queueing books for later, but the implementation has changed significantly which created a brand new version rather than an evolution of the original Bookqueue app.

What’s changed?
Bookqueue was optimized for Windows 8.x and Windows Phone 8.x.   Although application behavior was similar between the full desktop and phone, they were for all purposes treated as two (2) separate applications.
Bookqueue II is optimized for Windows 10 which provides a unified experience for Windows 10, Windows 10 Mobile and other supported device types in the Windows 10 family.  The benefit this provides is a single application and experience across the Windows 10 desktop/laptop/tablet/mobile devices.

What about other platforms?
By community request, there is now a version of Bookqueue II available for Android.Get it on Google Play  Bookqueue II for Android will contain feature parity with the Windows versions of Bookqueue II, and provides queue synchronization across devices. This means that if you opt in for synchronization  to your OneDrive storage, Bookqueue II for Android and Bookqueue II for Windows will be able to synchronize and share books across devices.

Running both Bookqueue and Bookqueue II
As Bookqueue and Bookqueue II are independent applications, they can be run side-by-side on supported systems, such as Windows 10.  The recommendation is to choose the version that fits your devices best.  If Bookqueue II is an option, it contains an ‘import’ feature that allows you to copy your current Bookqueue books (and shelf associations) to Bookqueue II.  You can then use Bookqueue II from that point forward.  The ‘import’ feature is not a synchronization, so you can run it multiple times without risk of deleting any books queued in Bookqueue or Bookqueue II.
Note: You cannot synchronize books across Bookqueue (original) and Bookqueue II (latest) as the synchronization feature is independent between them.

What’s next?
As Bookqueue II is a new implementation it does not have feature parity with Bookqueue.  I will be closing the gap between the two (2) versions and will be adding new capabilities to Bookqueue II going forward.  If you have a feature request, please feel free to contact me: torben.pedersen@outlook.com, always appreciate the feedback.

Librarians and Bots

It’s been a while and time to get going again! Been looking into Bots which has recently been a conversation topic of Facebook and Microsoft.
LibrarianBot
The underlying idea is that a Bot could be used as an assistant to help answer or do different tasks on your behalf. Looking at the history of Bookqueue it made me consider what is one of the primary capabilities of the application, searching for books. Before we had Personal PC’s, I would go the Library for a similar capability and ask my local librarian if she could find a book for me. Hence, the birth of the LibrarianBot.

Take it for trial run and ask it some questions you would have asked your librarian before the Personal PC:

'Find books by George R. Martin'
'Lookup ISBN 1439501661'


Should you get stuck, try entering ‘help’ to get instructions of phrases the bot can understand. Give it a try and please leave your feedback.

LiveSDK.Android – a Xamarin library for accessing SkyDrive

skydrive logoI have recently been looking closer into  cross-platform development and found myself rooted in Xamarin.  The first adventure is Xamarin.Android and porting Bookqueue to the Android environment.  Microsoft has made accessing SkyDrive simple with its LiveSDK for Android.  To help make the native java libraries available to .NET, Xamarin has provided a nice Android Java Binding library that allows creation of runtime callable wrappers.

My first dive into this adventure went pretty smooth and is available at GitHub – LiveSDK.Android