Bug 1306414 - Unable to create a .kube/config for oc command with only the servername
Summary: Unable to create a .kube/config for oc command with only the servername
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: oc
Version: 3.1.0
Hardware: Unspecified
OS: Linux
unspecified
low
Target Milestone: ---
: ---
Assignee: Fabiano Franz
QA Contact: Wei Sun
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-02-10 19:03 UTC by saurabh sharma
Modified: 2016-05-25 12:07 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-02-11 18:32:24 UTC
Target Upstream Version:


Attachments (Terms of Use)

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


Note You need to log in before you can comment on or make changes to this bug.