Bug 1306414

Summary: Unable to create a .kube/config for oc command with only the servername
Product: OpenShift Container Platform Reporter: saurabh sharma <saurap>
Component: ocAssignee: Fabiano Franz <ffranz>
Status: CLOSED WONTFIX QA Contact: Wei Sun <wsun>
Severity: low Docs Contact:
Priority: unspecified    
Version: 3.1.0CC: aos-bugs, deads, jokerman, mmccomas
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-02-11 18:32:24 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description saurabh sharma 2016-02-10 19:03:11 UTC
Description of problem:
I am trying to create a generic .kube/config for all the users in a system so that the users dont have to know the api endpoint to connect to the server. When i pass the servername in the .kube/config, oc still picks https://localhost:8443

Version-Release number of selected component (if applicable):
OSE 3.1.1
oc v3.1.0.4-16-g112fcc4
kubernetes v1.1.0-origin-1107-g4c8e6f4


How reproducible:
Always

Steps to Reproduce:
1. create a .kube/config
apiVersion: v1
clusters:
- cluster:
    insecure-skip-tls-verify: true
    server: https://osshift-vip01:8443
  name: osshift-vip01:8443

2. Use the .kube/config to login

3. Actual results:# oc login
Server [https://localhost:8443]:


Expected results:oc login
Server [https://osshift-vip01:8443]


Additional info:

It works if i create a context by logging once with my userid, edit the .kube/config and remove my usernames from the file and distribute it. Add the below after the cluster info in the above .kube/config.

contexts:
- context:
    cluster: osshift-vip01:8443
    user: /osshift-vip01:8443
  name: /osshift-vip01:8443/
current-context: /osshift-vip01:8443/


But if someone uses this file, the server is now found and for the user a new context along with the above empty one is created. 

I expect to only pass the servername in the .kube/config and populate/generate more info after user connects to the server using 'oc login'. I expect that the user does not have to know the servername when he connects to this host to run the oc command.

Comment 1 Fabiano Franz 2016-02-11 18:32:24 UTC
That's working as designed. What defines which server is going to be used in .kube/config is the 'current-context' entry, which point to one of the 'contexts' entry which in turn points to one of the 'clusters' entry, by its name. 

So although you don't need the 'user' section in the working example you provided, a minimal version of a .kube/config file you could use would be something like:

apiVersion: v1
clusters:
- cluster:
    insecure-skip-tls-verify: true
    server: https://osshift-vip01:8443/
  name: osshift-vip-server
contexts:
- context: 
    cluster: osshift-vip-server
  name: osshift-vip-context
current-context: osshift-vip-context