Change namespaces in Kubernetes

There is no easy way to change namespace in Kubernetes using kubectl command line utility. But here are some commands that you can alias in your bashrc file so that itโ€™s just a single command that you can use to change the namespace in the Kubernetes cluster. Change namespace Letโ€™s see step by step what goes in to change the namespace. So the first step is to find the context. A context element in a kubeconfig file is used to group access parameters under a convenient name. Each context has three parameters: cluster, namespace, and user. By default, the kubectl command-line tool uses parameters from the current context to communicate with the cluster. Read more. ...

July 2, 2018 ยท 3 min ยท Suraj Deshmukh

Prometheus with existing application on OpenShift

This post is very specific to OpenShift and how you can have an application exposing prometheus metrics to be scraped by a prometheus running in the same cluster. Requirements Setting up cluster I have done it using the oc cluster up, read about how to do this here. You could also setup a local OpenShift cluster by running minishift, read about setting up minishift here. Downloading Kedge The configurations defined for setting up this cluster is written in a format that is understood by a tool called Kedge. This makes configuration easier to understand and edit. So for using this setup download Kedge and put it in your path as explained here. ...

April 4, 2018 ยท 2 min ยท Suraj Deshmukh

Notes on talk - Advanced testing in golang by Mitchell Hashimoto

Test Fixtures โ€œgo testโ€ sets pwd as package directory Test Helpers should never return an error they should access to the *testing.T object call t.Helper() in the beginning (works only for go1.9+) for things reqiuiring clean up return closures Configurability Unconfigurable behavior is often a point of difficulty for tests. e.g. ports, timeouts, paths. Over-parameterize structs to allow tests to fine-tune their behavior Itโ€™s ok to make these configs unexported so only tests can set them. Slides Video GopherCon 2017: Mitchell Hashimoto - Advanced Testing with Go by Mitchell Hashimoto

March 7, 2018 ยท 1 min ยท Suraj Deshmukh

Methods that satisfy interfaces in golang

Pointer receiver For a struct User with a method Work with pointer receiver. type User struct { Name string Period int } func (u *User) Work() { fmt.Println(u.Name, "has worked for", u.Period, "hrs.") } func main() { uval := User{"UserVal", 5} uval.Work() pval := &User{"UserPtr", 6} pval.Work() } See on go playground. output: UserVal has worked for 5 hrs. UserPtr has worked for 6 hrs. If we call this method on value type object uval it works, and obviously it works with pointer type object pval. Value receiver Now we change the method receiver from pointer to value. ...

February 23, 2018 ยท 3 min ยท Suraj Deshmukh

vscode Shortcuts

This post has shortcuts that are generic and golang specific as well. This post will edited from time to time. Shortcuts Toggle side bar Ctrl + B Project explorer in side bar Ctrl + Shift + E Project wide search in side bar Ctrl + Shift + F Source control in side bar Ctrl + Shift + G Copy entire line Ctrl + C (without any selection) Delete entire line Ctrl + Shift + K ...

February 22, 2018 ยท 3 min ยท Suraj Deshmukh

Using private container registries from minikube

I am doing Kubernetes native development using minikube. And for doing that I had to download a Container image that is available in internally hosted private container registry. On the configuration side of doing that you will need to create Kubernetes Secret of type docker-registry. And now refer that secret you just created in your Pod manifest under pod.spec.imagePullSecrets. For more info follow the tutorial in Kubernetes docs on Pull an Image from a Private Registry. ...

October 6, 2017 ยท 2 min ยท Suraj Deshmukh

Static Pods using Kubelet on Fedora

I wanted to try out Standalone Kubelet Tutorial of Kelsey Hightower by myself but I could not follow it as it is, because it was firstly on GCE and secondly it uses CoreOS, but since I am very familiar to Fedora I thought of following that tutorial on it. To get a quick setup of a fresh Fedora machine use Vagrant. I have used Vagrantfile available here. This blog is only replacement of section Install the Standalone Kubelet in tutorial. ...

September 23, 2017 ยท 2 min ยท Suraj Deshmukh