Adding own service to Kubernetes Cluster Info

Last week, while going through some of the Kubernetes manifest files, I stumbled upon this label: kubernetes.io/cluster-service: “true” I searched about this in Documentation but could not find much information, so I thought of writing a small blog post about it. https://surajincloud.gumroad.com/l/own-kubectl-command When you add this label to any resource of type Kind: Service , it means it is part of cluster service, and the user needs to know when they are looking for cluster information. Hence it appears in the following command: ...

March 26, 2021 · 2 min · Suraj Narwade

Creating a Cartesian Product in Terraform

For one of my terraform tasks, I needed all the possible combinations of elements from all given sets. For example, there are two sets. set1 = ["a","b","c"] set2 = [1,2] The expected result is, [["a",1], ["a",2],["b",1],["b",2],["c",1],["c",2]] After searching about this, I learned that such a concept is called the Cartesian Product. From the Wikipedia definition, the Cartesian product of two sets A and B, denoted A × B, is the set of all ordered pairs (a, b) where a is in A and b is in B. ...

March 16, 2021 · 2 min · Suraj Narwade

Creating users on OpenShift 4

It’s always bit of confusing about OpenShift 4 :D here’s how we can add user in OpenShift 4. Create htpasswd file as below and users and their passwords, $ htpasswd -cb users.htpasswd user1 user1pass $ htpasswd -b users.htpasswd user2 user2pass Through console, login with kube:admin user, navigate to Administration > Cluster Settings > Global Configuration Click on Edit YAML in front of Oauth Click on Overview, under Identity Providers section, Click on Add and select HTPasswd ...

April 13, 2019 · 1 min · Suraj Narwade

Story of Noob Developer on OpenShift

A NodeJS developer named Warlock, recently joined his dream company as an Enterprise Developer. On day 1, his boss gave him a Code Repository & his OpenShift Platform Credentials to work his magic. Warlock got his code, git clone https://github.com/sclorg/nodejs-ex But was unclear about how to proceed as he had no idea about OpenShift. He then referred to the OpenShift docs but got confused and overwhelmed by all the new terminologies, DeploymentConfigs, Pods, Services, and Routes mentioned in it. He could barely login into the cluster using oc and thus got frustrated. ...

January 17, 2019 · 2 min · Suraj Narwade

Local Development of golang app with minikube & ko

While exploring, I came across ko tool by google & found interesting since it buids and deploy golang applications to kubernetes easily. This post is for minikube only since I am focussing on local development. Pre-Flight Checks Installing ko go get github.com/google/go-containerregistry/cmd/ko That’s it :) Verify your installation by which ko We can mention any docker registry (local or remote) using KO_DOCKER_REPO env variable, but as we are focussing on local development, we will publish images to minikube’s docker daemon ...

December 5, 2018 · 2 min · Suraj Narwade

Exploring Kubernetes: Client-Go - part-1

What’s client-go ? Where’s client-go ? you can find it in kubernetes/kubernetes/staging directory and published by bot to k8s.io/client-go, kubernetes also uses client-go. it’s interesting if you see client-go from kubernetes vendor, it has symlinks to kubernetes/kubernetes/staging In this Adventure, very first step is to see how to connect to API Server :) Connecting to API Server There are two ways to talk to cluster using any go program: outside cluster: if your program is standalone and if you have either kubeconfig file or master URL. ...

November 30, 2018 · 2 min · Suraj Narwade

Exploring Kubernetes: Client-Go - part-2

If you have kubeconfig file already in place, kubeconfig := clientcmd.NewNonInteractiveDeferredLoadingClientConfig(clientcmd.NewDefaultClientConfigLoadingRules(), &clientcmd.ConfigOverrides{}) There is one more function clientcmd.NewInteractiveDeferredLoadingClientConfig but as per code, we can use it only when password is allowed Namespace given by current context, namespace, _, err := kubeconfig.Namespace() REST config needed to operations restconfig, err := kubeconfig.ClientConfig() if you want kubeconfig as a struct clientcmdapi.Config, err := kubeconfig.RawConfig() Here, kubeconfig is interface of following type: // ClientConfig is used to make it easy to get an api server client type ClientConfig interface { // RawConfig returns the merged result of all overrides RawConfig() (clientcmdapi.Config, error) // ClientConfig returns a complete client config ClientConfig() (*restclient.Config, error) // Namespace returns the namespace resulting from the merged // result of all overrides and a boolean indicating if it was // overridden Namespace() (string, bool, error) // ConfigAccess returns the rules for loading/persisting the config. ConfigAccess() ConfigAccess } structs NewNonInteractiveDeferredLoadingClientConfig & inClusterClientConfig implements above interface and can be used as per requirements whether inside of cluster or outside.

November 30, 2018 · 1 min · Suraj Narwade

Exploring Kubernetes: Client-Go - part-3

we got restConfig and namespace, connection is set up Yay From this restconfig, Now we need to create respective clients for further operations we will need following package: import k8s.io/client-go/kubernetes create basic kubernetes client: kubeClient, err := kubernetes.NewForConfig(restConfig) it returns clients for APIgroups like: Apps CoreV1 Batch StorageV1 If you have some custom controller, generated code will have NewForConfig function which you have call separately, For example, In case of service catalog, ...

November 30, 2018 · 1 min · Suraj Narwade

nmcli 101

To check devices: nmcli device status Overall status of NetworkManager: nmcli general status Display connections: nmcli connection show display only active connections: nmcli connection show --active WI-FI Check wifi status nmcli radio wifi Turn on the wifi nmcli radio wifi on Turn off the wifi nmcli radio wifi off List available wifi access points nmcli device wifi list Refresh the access point list nmcli device wifi rescan Connect to wifi nmcli device wifi connect <SSID> Connect to password protected access point nmcli device wifi connect <SSID> password <password>

November 15, 2018 · 1 min · Suraj Narwade

Journey to the CKA

Hello Folks, I appeared for the exam on 19th October 2018 and yesterday(20th Oct 2018), I got the result & I scored 92%, Yay :) I got so many request about How to prepare for the exam, Here’s my experience with preparation for the exam. A bit about Exam: Duration: 3 hours (which is fair time if you do lot of practice, I completed in 2 hours 15 mins) Questions: 24 Clusters: 6 After clearing 9 certs to become RHCA (Red Hat Certified Architect), exam environment was kind of familiar to me. ...

October 21, 2018 · 4 min · Suraj Narwade