<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Dinesh B</title>
    <description>The latest articles on DEV Community by Dinesh B (@dineshba).</description>
    <link>https://dev.to/dineshba</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F215859%2F739d5abe-667e-46c9-895d-44468c32ad08.jpeg</url>
      <title>DEV Community: Dinesh B</title>
      <link>https://dev.to/dineshba</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dineshba"/>
    <language>en</language>
    <item>
      <title>Which scheduler scheduled the scheduler in minikube ?</title>
      <dc:creator>Dinesh B</dc:creator>
      <pubDate>Wed, 25 Dec 2019 14:37:08 +0000</pubDate>
      <link>https://dev.to/dineshba/which-scheduler-scheduled-the-scheduler-in-minikube-2i2b</link>
      <guid>https://dev.to/dineshba/which-scheduler-scheduled-the-scheduler-in-minikube-2i2b</guid>
      <description>&lt;p&gt;In oneliner, minikube is a tool that makes it easy to run Kubernetes locally.&lt;/p&gt;

&lt;p&gt;In &lt;code&gt;kube-system&lt;/code&gt; namespace, we can see result like below,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;kubectl get pods &lt;span class="nt"&gt;-n&lt;/span&gt; kube-system &lt;span class="nt"&gt;-o&lt;/span&gt; name &lt;span class="nt"&gt;-l&lt;/span&gt; &lt;span class="nv"&gt;tier&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;control-plane
pod/etcd-minikube
pod/kube-apiserver-minikube
pod/kube-controller-manager-minikube
pod/kube-scheduler-minikube &lt;span class="c"&gt;#scheduler is running, but who scheduled ?&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Whenever we create pod(rs/deployments/sts/ds), &lt;code&gt;Scheduler&lt;/code&gt; is the one which schedules this pods into any of the available node (in minikube, there is only one).&lt;br&gt;
In minikube, &lt;code&gt;kube-scheduler-minikube&lt;/code&gt; is the one who schedules. For long time, I wondered who scheduled the &lt;code&gt;kube-scheduler-minikube&lt;/code&gt; pod to this minikube node. I assumed it as &lt;code&gt;magic&lt;/code&gt; 🤪&lt;/p&gt;

&lt;p&gt;Now, I understood how things are happening, here you go:&lt;/p&gt;

&lt;p&gt;There is something called &lt;a href="https://kubernetes.io/docs/tasks/configure-pod-container/static-pod/"&gt;static pods&lt;/a&gt; in kubernetes. Without  master components (&lt;code&gt;api-server&lt;/code&gt;, &lt;code&gt;etcd&lt;/code&gt;, &lt;code&gt;scheduler&lt;/code&gt;, &lt;code&gt;controller-manager&lt;/code&gt;), we can run pods in &lt;code&gt;kubelet&lt;/code&gt; &lt;strong&gt;directly&lt;/strong&gt;. Minikube used this to run master components and thus formed the cluster.&lt;/p&gt;
&lt;h4&gt;
  
  
  Proof:
&lt;/h4&gt;


&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;minikube ssh
&lt;span class="nv"&gt;$ &lt;/span&gt;ps aux | &lt;span class="nb"&gt;grep &lt;/span&gt;kubelet
root      3035  3.9  4.6 1377692 91476 ?       Ssl  07:27   0:06 /var/lib/minikube/binaries/v1.15.2/kubelet &lt;span class="nt"&gt;--authorization-mode&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;Webhook &lt;span class="nt"&gt;--bootstrap-kubeconfig&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/etc/kubernetes/bootstrap-kubelet.conf &lt;span class="nt"&gt;--cgroup-driver&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;cgroupfs &lt;span class="nt"&gt;--client-ca-file&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/var/lib/minikube/certs/ca.crt &lt;span class="nt"&gt;--cluster-dns&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;10.96.0.10 &lt;span class="nt"&gt;--cluster-domain&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;cluster.local &lt;span class="nt"&gt;--config&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/var/lib/kubelet/config.yaml &lt;span class="nt"&gt;--container-runtime&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;docker &lt;span class="nt"&gt;--hostname-override&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;minikube &lt;span class="nt"&gt;--kubeconfig&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/etc/kubernetes/kubelet.conf &lt;span class="nt"&gt;--node-ip&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;192.168.99.100 &lt;span class="nt"&gt;--pod-manifest-path&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/etc/kubernetes/manifests
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;In the above example, kubelet is started with &lt;code&gt;--pod-manifest-path=/etc/kubernetes/manifests&lt;/code&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: &lt;code&gt;--pod-manifest-path&lt;/code&gt; is path to the directory containing static pod files to run.&lt;br&gt;
&lt;/p&gt;


&lt;/blockquote&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="nt"&gt;-l&lt;/span&gt; /etc/kubernetes/manifests
&lt;span class="nt"&gt;-rw-r-----&lt;/span&gt; 1 root root 1532 Jan  1  0001 addon-manager.yaml.tmpl
&lt;span class="nt"&gt;-rw-------&lt;/span&gt; 1 root root 1990 Dec 25 07:27 etcd.yaml
&lt;span class="nt"&gt;-rw-------&lt;/span&gt; 1 root root 2893 Dec 25 07:27 kube-apiserver.yaml
&lt;span class="nt"&gt;-rw-------&lt;/span&gt; 1 root root 2262 Dec 25 07:27 kube-controller-manager.yaml
&lt;span class="nt"&gt;-rw-------&lt;/span&gt; 1 root root  990 Dec 25 07:27 kube-scheduler.yaml
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Thus when kubelet started, it started the master components and thus &lt;strong&gt;cluster formed&lt;/strong&gt;.&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>devops</category>
      <category>go</category>
    </item>
    <item>
      <title>Resolve vs Reach</title>
      <dc:creator>Dinesh B</dc:creator>
      <pubDate>Thu, 12 Dec 2019 16:48:10 +0000</pubDate>
      <link>https://dev.to/dineshba/resolve-vs-reach-cga</link>
      <guid>https://dev.to/dineshba/resolve-vs-reach-cga</guid>
      <description>&lt;p&gt;I have seen lot of people confuse between resolving dns vs reach IP. So this small blog.&lt;/p&gt;

&lt;p&gt;Inorder to get data from any computer we need to know the address of the computer which is IP address. Let's say we want to get some data from google and its IP is &lt;code&gt;172.217.31.196&lt;/code&gt; (currently). Its very hard to remember this IP and also they can have multiple machines(IPs) which will give the same data (horizontal scaling). So we cannot remember IPs. So we need a map (key: name, value: IP) stored in a server called DNS whose IP is configured automatically (done by DHCP server) when we connect to internet (8.8.8.8 or 1.1.1.1 or your custom dns server). &lt;/p&gt;

&lt;p&gt;So when we do &lt;code&gt;www.google.com&lt;/code&gt; in browser&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1) Check which dns server to use in `/etc/resolve.conf`
2) Use that dns server to get the `ip address` of www.google.com
3) Use that IP address to connect and transfer data
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;First two steps&lt;/strong&gt; is &lt;code&gt;resolve&lt;/code&gt; and &lt;strong&gt;third step&lt;/strong&gt; is &lt;code&gt;reach&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Example:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Let's say we have private network and to access machines inside that network, we have to connect to the VPN. There is an application running in that network in machine &lt;code&gt;172.11.11.11&lt;/code&gt;. We can add entry in dns. Key is &lt;code&gt;www.myapplication.com&lt;/code&gt; and value is &lt;code&gt;172.11.11.11&lt;/code&gt;. Once that is done, anybody can &lt;strong&gt;resolve&lt;/strong&gt; &lt;code&gt;www.myapplication.com&lt;/code&gt; to &lt;code&gt;172.11.11.11&lt;/code&gt; as we added entry in public dns server. But it is reachable only to people who are connected to the VPN.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Let's say I want to expose/transfer some data to my colleagues. And my ip is &lt;code&gt;192.168.1.4&lt;/code&gt; which is private and will be accessible only to the people whose is in my network. Instead of asking my colleagues to use this IP, we can put an entry in public DNS server (8.8.8.8 or 1.1.1.1). Key is &lt;code&gt;www.dineshba.com&lt;/code&gt; and value is &lt;code&gt;192.168.1.4&lt;/code&gt;. Once that is done, anybody can &lt;strong&gt;resolve&lt;/strong&gt; &lt;code&gt;www.dineshba.com&lt;/code&gt; to &lt;code&gt;192.168.1.4&lt;/code&gt; as we added entry in public dns server. But it is reachable only to people in my network.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>devops</category>
      <category>distributedsystems</category>
    </item>
    <item>
      <title>How I am using fzf for every 5 min of my programming life</title>
      <dc:creator>Dinesh B</dc:creator>
      <pubDate>Wed, 21 Aug 2019 03:52:48 +0000</pubDate>
      <link>https://dev.to/dineshba/how-i-am-using-fzf-for-every-5-min-of-my-programming-life-1lh8</link>
      <guid>https://dev.to/dineshba/how-i-am-using-fzf-for-every-5-min-of-my-programming-life-1lh8</guid>
      <description>&lt;h4&gt;
  
  
  Installation for new users
&lt;/h4&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;brew &lt;span class="nb"&gt;install &lt;/span&gt;fzf
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;brew &lt;span class="nt"&gt;--prefix&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;/opt/fzf/install &lt;span class="c"&gt;# useful key bindings and fuzzy completion&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Note: Its better to use key bindings and fuzzy completion&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4&gt;
  
  
  Default options that I use
&lt;/h4&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;FZF_DEFAULT_OPTS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'--height 40% --reverse --border'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h4&gt;
  
  
  My usages
&lt;/h4&gt;

&lt;h5&gt;
  
  
  To Search in command history:
&lt;/h5&gt;

&lt;p&gt;CTRL + R&lt;/p&gt;

&lt;h5&gt;
  
  
  To Change directory:
&lt;/h5&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; + &lt;span class="o"&gt;(&lt;/span&gt;CTRL + T&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="c"&gt;# type cd and then press CTRL plus T&lt;/span&gt;
or
&lt;span class="nb"&gt;cd&lt;/span&gt; &lt;span class="k"&gt;**&lt;/span&gt; + TAB
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h5&gt;
  
  
  To find and open files in vim(or any editor):
&lt;/h5&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;vim &lt;span class="si"&gt;$(&lt;/span&gt;fzf&lt;span class="si"&gt;)&lt;/span&gt;
vim + &lt;span class="o"&gt;(&lt;/span&gt;CTRL + T&lt;span class="o"&gt;)&lt;/span&gt;
vim &lt;span class="k"&gt;**&lt;/span&gt; + TAB
vim &lt;span class="si"&gt;$(&lt;/span&gt;fzf &lt;span class="nt"&gt;--preview&lt;/span&gt; &lt;span class="s1"&gt;'cat {}'&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;You can even search and open multiple files using tab&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h5&gt;
  
  
  To kill a process:
&lt;/h5&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;kill&lt;/span&gt; + TAB
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Note: Think about the normal way. We have to ps aux to list processes and grep the required process then copy the correct column for pid, then call kill. Here just one step.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h5&gt;
  
  
  To ssh into a machine:
&lt;/h5&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;ssh &lt;span class="k"&gt;**&lt;/span&gt; + TAB
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h5&gt;
  
  
  To get the glimse of a file
&lt;/h5&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;fzf &lt;span class="nt"&gt;--preview&lt;/span&gt; &lt;span class="s1"&gt;'cat {}'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h4&gt;
  
  
  Extensibility
&lt;/h4&gt;

&lt;p&gt;Fzf's usage is &lt;strong&gt;limitless&lt;/strong&gt;. We can use it wherever &lt;strong&gt;we want to search and select one(or many) from a list&lt;/strong&gt;&lt;/p&gt;

&lt;h5&gt;
  
  
  Case 1:
&lt;/h5&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;How will you jump to different directory?
- cd /path/to/your/project/path/to/your/service
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h5&gt;
  
  
  Fzf way:
&lt;/h5&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;alias goproject="cd $(find path/to/your/project -type d -maxdepth 2 | fzf)"
goproject
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;You can have multiple alias for multiple projects or directories&lt;/p&gt;

&lt;h5&gt;
  
  
  Case 2:
&lt;/h5&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;How will you switch git branch? (select one branch from many)
    - git branch -a
    - copy the branch name
    - git checkout $new_branch_name
    or
    - git checkout + TAB (auto completion feature)

    Both the above approches are not O(1) :-P. How can we optimize?
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h5&gt;
  
  
  Fzf way:
&lt;/h5&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;alias gcx="git checkout \$(git branch -a | sed 's/remotes\/origin\///' | grep -v '\*|HEAD' | sort |uniq | fzf --select-1)"
gcx
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Note: try in your terminal and feel the difference&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h5&gt;
  
  
  Case 3:
&lt;/h5&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;How will you tmux workspaces? We are using tmuxp tool to do that.
- tmuxp load workspace_name
or
- tmuxp load ~/.tmuxp/workspace_name.yaml

First involes rembembering all workspace_names (Space Complexity != O(1)) and type correct and fastly (Time Complexity != O(1)). Second involes lot of TABs or searching from commit history (Time Complexity != O(1))

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h5&gt;
  
  
  Fzf way:
&lt;/h5&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;alias &lt;/span&gt;&lt;span class="nv"&gt;ktx&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'tmuxp load $(ls ~/.tmuxp/*.yaml | grep ".*/.tmuxp/" -r "" | grep "\.yaml" -r "" | fzf) --yes'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h5&gt;
  
  
  Case 4:
&lt;/h5&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Okay we created tmux workspaces easily using Case 3. How will kill tmux workspaces now?
- tmux kill-session workspace_name
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h5&gt;
  
  
  Fzf way:
&lt;/h5&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;alias &lt;/span&gt;&lt;span class="nv"&gt;tkill&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"for s in &lt;/span&gt;&lt;span class="se"&gt;\$&lt;/span&gt;&lt;span class="s2"&gt;(tmux list-sessions | awk '{print &lt;/span&gt;&lt;span class="se"&gt;\$&lt;/span&gt;&lt;span class="s2"&gt;1}' | rg ':' -r '' | fzf -m); do tmux kill-session -t &lt;/span&gt;&lt;span class="se"&gt;\$&lt;/span&gt;&lt;span class="s2"&gt;s; done;"&lt;/span&gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;tkill
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Note: We are giving &lt;code&gt;fzf -m&lt;/code&gt; which means we can select multiple and pass to next stage (basically killing multiple sessions)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h5&gt;
  
  
  Other tools which use fzf effectively
&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;kubectx&lt;/li&gt;
&lt;li&gt;kubens&lt;/li&gt;
&lt;li&gt;lazy-connect&lt;/li&gt;
&lt;li&gt;may be your tool&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;replace grep with &lt;a href="https://github.com/BurntSushi/ripgrep"&gt;rg&lt;/a&gt; for better experience&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4&gt;
  
  
  Summary:
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Wherever&lt;/strong&gt; we want &lt;strong&gt;search and select one/many from a list&lt;/strong&gt;, then we can &lt;strong&gt;use fzf&lt;/strong&gt;. So the options to use is limitless. If you are &lt;strong&gt;using fzf in a different way&lt;/strong&gt;, please &lt;strong&gt;raise an issue or a PR &lt;a href="https://github.com/dineshba/til/blob/master/misc/fzf.md"&gt;here&lt;/a&gt;&lt;/strong&gt; so that we can learn that. Thanks.&lt;/p&gt;

</description>
      <category>productivity</category>
      <category>github</category>
      <category>fzf</category>
      <category>commandlinetools</category>
    </item>
  </channel>
</rss>
