Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1838298

Summary: oc serviceaccounts create-kubeconfig does not honor context correctly
Product: OpenShift Container Platform Reporter: Steve Kuznetsov <skuznets>
Component: ocAssignee: Maciej Szulik <maszulik>
Status: CLOSED DUPLICATE QA Contact: zhou ying <yinzhou>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 4.4CC: aos-bugs, jokerman, mfojtik
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-05-20 19:59:49 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:
Embargoed:

Description Steve Kuznetsov 2020-05-20 19:56:30 UTC
If you run `oc serviceaccounts create-kubeconfig` with `--context`, the `--context` is used when reading the serviceaccount token but the output KUBECONFIG uses whatever the current context is in your local KUEBCONFIG.

Comment 1 Steve Kuznetsov 2020-05-20 19:58:29 UTC
The `cvp-trigger` ServiceAccount only exists in the `app.ci` context:

$ oc config current-context
api.ci
$ oc --as system:admin --context api.ci --namespace ci serviceaccounts create-kubeconfig cvp-trigger
Error from server (NotFound): serviceaccounts "cvp-trigger" not found
$ oc --as system:admin --context app.ci --namespace ci serviceaccounts create-kubeconfig cvp-trigger
apiVersion: v1
clusters:
- cluster:
    server: https://api.ci.openshift.org:443
  name: api-ci-openshift-org:443
contexts:
- context:
    cluster: api-ci-openshift-org:443
    namespace: ci
    user: cvp-trigger
  name: cvp-trigger
current-context: cvp-trigger
kind: Config
preferences: {}
users:
- name: cvp-trigger
  user:
    token: xxx

Comment 2 Steve Kuznetsov 2020-05-20 19:59:49 UTC

*** This bug has been marked as a duplicate of bug 1827463 ***