2015-07-12 12:04:52 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								<!--  BEGIN MUNGE: UNVERSIONED_WARNING  --> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								<!--  BEGIN STRIP_FOR_RELEASE  --> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-07-17 01:02:26 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								< img  src = "http://kubernetes.io/img/warning.png"  alt = "WARNING" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								     width="25" height="25">
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								< img  src = "http://kubernetes.io/img/warning.png"  alt = "WARNING" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								     width="25" height="25">
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								< img  src = "http://kubernetes.io/img/warning.png"  alt = "WARNING" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								     width="25" height="25">
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								< img  src = "http://kubernetes.io/img/warning.png"  alt = "WARNING" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								     width="25" height="25">
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								< img  src = "http://kubernetes.io/img/warning.png"  alt = "WARNING" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								     width="25" height="25">
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								< h2 > PLEASE NOTE: This document applies to the HEAD of the source tree< / h2 > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								If you are using a released version of Kubernetes, you should
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								refer to the docs that go with that version.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								< strong > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								The latest 1.0.x release of this document can be found
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[here ](http://releases.k8s.io/release-1.0/docs/user-guide/kubeconfig-file.md ).
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								Documentation for other releases can be found at
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[releases.k8s.io ](http://releases.k8s.io ).
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								< / strong > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								--
							 
						 
					
						
							
								
									
										
										
										
											2015-07-14 06:15:35 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-07-12 12:04:52 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								<!--  END STRIP_FOR_RELEASE  --> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								<!--  END MUNGE: UNVERSIONED_WARNING  --> 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-18 06:35:41 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-05-06 02:36:22 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								# kubeconfig files
 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-18 06:35:41 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-05-06 02:36:22 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								In order to easily switch between multiple clusters, a kubeconfig file was defined.  This file contains a series of authentication mechanisms and cluster connection information associated with nicknames.  It also introduces the concept of a tuple of authentication information (user) and cluster connection information called a context that is also associated with a nickname.
							 
						 
					
						
							
								
									
										
										
										
											2015-01-08 04:59:22 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-05-19 07:28:57 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								Multiple kubeconfig files are allowed.  At runtime they are loaded and merged together along with override options specified from the command line (see rules below).
							 
						 
					
						
							
								
									
										
										
										
											2015-01-08 04:59:22 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								## Related discussion
 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-18 06:35:41 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-08-06 09:08:26 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								http://issue.k8s.io/1755
							 
						 
					
						
							
								
									
										
										
										
											2015-01-08 04:59:22 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-05-06 02:36:22 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								## Example kubeconfig file
 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-17 10:01:02 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-07-19 07:29:49 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								```yaml
							 
						 
					
						
							
								
									
										
										
										
											2014-12-17 21:03:03 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								apiVersion: v1
							 
						 
					
						
							
								
									
										
										
										
											2015-01-08 04:59:22 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								clusters:
							 
						 
					
						
							
								
									
										
										
										
											2014-12-17 21:03:03 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								-  cluster:
							 
						 
					
						
							
								
									
										
										
										
											2015-06-06 03:47:15 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    api-version: v1
							 
						 
					
						
							
								
									
										
										
										
											2014-12-17 21:03:03 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    server: http://cow.org:8080
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  name: cow-cluster
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								-  cluster:
							 
						 
					
						
							
								
									
										
										
										
											2015-01-08 04:59:22 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    certificate-authority: path/to/my/cafile
							 
						 
					
						
							
								
									
										
										
										
											2014-12-17 21:03:03 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    server: https://horse.org:4443
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  name: horse-cluster
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								-  cluster:
							 
						 
					
						
							
								
									
										
										
										
											2015-01-08 04:59:22 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    insecure-skip-tls-verify: true
							 
						 
					
						
							
								
									
										
										
										
											2014-12-17 21:03:03 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    server: https://pig.org:443
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  name: pig-cluster
							 
						 
					
						
							
								
									
										
										
										
											2015-01-08 04:59:22 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								contexts:
							 
						 
					
						
							
								
									
										
										
										
											2014-12-17 21:03:03 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								-  context:
							 
						 
					
						
							
								
									
										
										
										
											2015-01-08 04:59:22 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    cluster: horse-cluster
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    namespace: chisel-ns
							 
						 
					
						
							
								
									
										
										
										
											2014-12-17 21:03:03 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    user: green-user
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  name: federal-context
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								-  context:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    cluster: pig-cluster
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    namespace: saw-ns
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    user: black-user
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  name: queen-anne-context
							 
						 
					
						
							
								
									
										
										
										
											2015-01-08 04:59:22 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								current-context: federal-context
							 
						 
					
						
							
								
									
										
										
										
											2014-12-17 21:03:03 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								kind: Config
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								preferences:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  colors: true
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								users:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								-  name: blue-user
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  user:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    token: blue-token
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								-  name: green-user
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  user:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    client-certificate: path/to/my/client/cert
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    client-key: path/to/my/client/key
							 
						 
					
						
							
								
									
										
										
										
											2015-01-08 04:59:22 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								## Loading and merging rules
 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-18 06:35:41 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-05-06 02:36:22 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								The rules for loading and merging the kubeconfig files are straightforward, but there are a lot of them.  The final config is built in this order:
							 
						 
					
						
							
								
									
										
										
										
											2015-04-10 20:54:22 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								  1.   Get the kubeconfig  from disk.  This is done with the following hierarchy and merge rules:
							 
						 
					
						
							
								
									
										
										
										
											2015-05-06 02:36:22 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-03-05 06:16:04 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-04-10 20:54:22 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								      If the CommandLineLocation (the value of the `kubeconfig`  command line option) is set, use this file only.  No merging.  Only one instance of this flag is allowed.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-05-06 02:36:22 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								      Else, if EnvVarLocation (the value of $KUBECONFIG) is available, use it as a list of files that should be merged.
							 
						 
					
						
							
								
									
										
										
										
											2015-04-10 20:54:22 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								      Merge files together based on the following rules.
							 
						 
					
						
							
								
									
										
										
										
											2015-01-08 04:59:22 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								      Empty filenames are ignored.  Files with non-deserializable content produced errors.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      The first file to set a particular value or map key wins and the value or map key is never changed.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      This means that the first file to set CurrentContext will have its context preserved.  It also means that if two files specify a "red-user", only values from the first file's red-user are used.  Even non-conflicting entries from the second file's "red-user" are discarded.
							 
						 
					
						
							
								
									
										
										
										
											2015-04-10 20:54:22 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      Otherwise, use HomeDirectoryLocation (~/.kube/config) with no merging.
							 
						 
					
						
							
								
									
										
										
										
											2015-01-08 04:59:22 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								  1.   Determine the context to use based on the first hit in this chain
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      1.   command line argument - the value of the `context`  command line option
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      1.   current-context from the merged kubeconfig file
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      1.   Empty is allowed at this stage
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  1.   Determine the cluster info and user to use.  At this point, we may or may not have a context.  They are built based on the first hit in this chain.  (run it twice, once for user, once for cluster)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      1.   command line argument - `user`  for user name and `cluster`  for cluster name
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      1.   If context is present, then use the context's value
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      1.   Empty is allowed
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  1.   Determine the actual cluster info to use.  At this point, we may or may not have a cluster info.  Build each piece of the cluster info based on the chain (first hit wins):
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      1.   command line arguments - `server` , `api-version` , `certificate-authority` , and `insecure-skip-tls-verify` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      1.   If cluster info is present and a value for the attribute is present, use it.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      1.   If you don't have a server location, error.
							 
						 
					
						
							
								
									
										
										
										
											2015-03-05 06:16:04 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								  1.   Determine the actual user info to use. User is built using the same rules as cluster info, EXCEPT that you can only have one authentication technique per user.
							 
						 
					
						
							
								
									
										
										
										
											2015-05-09 04:26:27 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								      1.  Load precedence is 1) command line flag, 2) user fields from kubeconfig
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      1.  The command line flags are: `client-certificate` , `client-key` , `username` , `password` , and `token` .
							 
						 
					
						
							
								
									
										
										
										
											2015-03-05 06:16:04 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								      1.  If there are two conflicting techniques, fail.
							 
						 
					
						
							
								
									
										
										
										
											2015-01-08 04:59:22 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								  1.   For any information still missing, use default values and potentially prompt for authentication information
							 
						 
					
						
							
								
									
										
										
										
											2014-12-17 21:03:03 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-05-06 02:36:22 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								## Manipulation of kubeconfig via `kubectl config <subcommand>`
 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-18 06:35:41 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-05-06 02:36:22 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								In order to more easily manipulate kubeconfig files, there are a series of subcommands to `kubectl config`  to help.
							 
						 
					
						
							
								
									
										
										
										
											2015-07-15 00:37:37 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								See [kubectl/kubectl_config.md ](kubectl/kubectl_config.md ) for help.
							 
						 
					
						
							
								
									
										
										
										
											2014-12-17 21:03:03 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								### Example
 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-17 10:01:02 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-07-19 07:29:49 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								```console
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								$ kubectl config set-credentials myself --username=admin --password=secret
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								$ kubectl config set-cluster local-server --server=http://localhost:8080
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								$ kubectl config set-context default-context --cluster=local-server --user=myself
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								$ kubectl config use-context default-context
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								$ kubectl config set contexts.default-context.namespace the-right-prefix
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								$ kubectl config view
							 
						 
					
						
							
								
									
										
										
										
											2014-12-17 21:03:03 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2015-07-17 10:01:02 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-12-17 21:03:03 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								produces this output
							 
						 
					
						
							
								
									
										
										
										
											2015-07-17 10:01:02 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-07-19 07:29:49 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								```yaml
							 
						 
					
						
							
								
									
										
										
										
											2014-12-17 21:03:03 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								clusters:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  local-server:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    server: http://localhost:8080
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								contexts:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  default-context:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    cluster: local-server
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    namespace: the-right-prefix
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    user: myself
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								current-context: default-context
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								preferences: {}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								users:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  myself:
							 
						 
					
						
							
								
									
										
										
										
											2015-05-06 02:36:22 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    username: admin
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    password: secret
							 
						 
					
						
							
								
									
										
										
										
											2014-12-17 21:03:03 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2015-07-17 10:01:02 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-05-06 02:36:22 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								and a kubeconfig file that looks like this
							 
						 
					
						
							
								
									
										
										
										
											2015-07-17 10:01:02 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-07-19 07:29:49 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								```yaml
							 
						 
					
						
							
								
									
										
										
										
											2014-12-17 21:03:03 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								apiVersion: v1
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								clusters:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								-  cluster:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    server: http://localhost:8080
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  name: local-server
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								contexts:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								-  context:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    cluster: local-server
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    namespace: the-right-prefix
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    user: myself
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  name: default-context
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								current-context: default-context
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								kind: Config
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								preferences: {}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								users:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								-  name: myself
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  user:
							 
						 
					
						
							
								
									
										
										
										
											2015-05-06 02:36:22 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    username: admin
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    password: secret
							 
						 
					
						
							
								
									
										
										
										
											2014-12-17 21:03:03 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								#### Commands for the example file
 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-17 10:01:02 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-07-19 07:29:49 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								```console
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								$ kubectl config set preferences.colors true
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								$ kubectl config set-cluster cow-cluster --server=http://cow.org:8080 --api-version=v1
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								$ kubectl config set-cluster horse-cluster --server=https://horse.org:4443 --certificate-authority=path/to/my/cafile
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								$ kubectl config set-cluster pig-cluster --server=https://pig.org:443 --insecure-skip-tls-verify=true
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								$ kubectl config set-credentials blue-user --token=blue-token
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								$ kubectl config set-credentials green-user --client-certificate=path/to/my/client/cert --client-key=path/to/my/client/key
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								$ kubectl config set-context queen-anne-context --cluster=pig-cluster --user=black-user --namespace=saw-ns
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								$ kubectl config set-context federal-context --cluster=horse-cluster --user=green-user --namespace=chisel-ns
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								$ kubectl config use-context federal-context
							 
						 
					
						
							
								
									
										
										
										
											2015-03-05 06:16:04 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2015-05-15 06:12:45 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-07-14 08:13:09 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								<!--  BEGIN MUNGE: GENERATED_ANALYTICS  --> 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-15 00:37:37 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[]()
							 
						 
					
						
							
								
									
										
										
										
											2015-07-14 08:13:09 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								<!--  END MUNGE: GENERATED_ANALYTICS  -->