{"id":3685,"date":"2019-02-07T16:10:55","date_gmt":"2019-02-07T22:10:55","guid":{"rendered":"http:\/\/benincosa.com\/?p=3685"},"modified":"2019-02-07T16:10:55","modified_gmt":"2019-02-07T22:10:55","slug":"kubernetes-contexts","status":"publish","type":"post","link":"https:\/\/benincosa.com\/?p=3685","title":{"rendered":"Kubernetes contexts"},"content":{"rendered":"<p>Today we had to work on switching between two kubernetes clusters.\u00a0 The commands of the day are:<\/p>\n<pre class=\"lang:sh decode:true \">kubectl config get-contexts\r\nkubectl config use-context &lt;context&gt;<\/pre>\n<p>It&#8217;s surprisingly not so simple.\u00a0 Perhaps there are tools out there that people know of to make it easier?\u00a0 What I&#8217;ve been doing is taking to ~\/.kube\/config files and concatenating them together.\u00a0 As an example, my config file looks as follows:<\/p>\n<pre class=\"lang:yaml decode:true \">apiVersion: v1\r\nclusters:\r\n- cluster:\r\n    certificate-authority-data: blahblah... \r\n    server: https:\/\/172.28.225.133:6443\r\n  name: bm\r\n- cluster:\r\n    certificate-authority-data: blahblah... \r\n    server: https:\/\/10.93.140.127:6443\r\n  name: ccp\r\n\r\ncontexts:\r\n- context:\r\n    cluster: bm\r\n    user: kubernetes-admin\r\n  name: bm\r\n- context:\r\n    cluster: ccp\r\n    user: kubernetes-admin1\r\n  name: ccp\r\ncurrent-context: ccp\r\nkind: Config\r\npreferences: {}\r\nusers:\r\n- name: kubernetes-admin\r\n  user:\r\n    client-certificate-data: blahblah...\r\n    client-key-data: blahblah...\r\n    token: blahblah...\r\n- name: kubernetes-admin1\r\n  user:\r\n    client-certificate-data: blahblah...\r\n    client-key-data: blahblah...\r\n    token: blahblah...\r\n<\/pre>\n<p>Notice how we combine them together.\u00a0 Then I can switch contexts using the commands above.\u00a0 I&#8217;ll have ccp or bm.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today we had to work on switching between two kubernetes clusters.\u00a0 The commands of the day are: kubectl config get-contexts kubectl config use-context &lt;context&gt; It&#8217;s surprisingly not so simple.\u00a0 Perhaps there are tools out there that people know of to make it easier?\u00a0 What I&#8217;ve been doing is taking to ~\/.kube\/config files and concatenating them&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[797],"tags":[798],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/benincosa.com\/index.php?rest_route=\/wp\/v2\/posts\/3685"}],"collection":[{"href":"https:\/\/benincosa.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/benincosa.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/benincosa.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/benincosa.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3685"}],"version-history":[{"count":1,"href":"https:\/\/benincosa.com\/index.php?rest_route=\/wp\/v2\/posts\/3685\/revisions"}],"predecessor-version":[{"id":3686,"href":"https:\/\/benincosa.com\/index.php?rest_route=\/wp\/v2\/posts\/3685\/revisions\/3686"}],"wp:attachment":[{"href":"https:\/\/benincosa.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3685"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/benincosa.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3685"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/benincosa.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3685"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}