Bug 1838298 - oc serviceaccounts create-kubeconfig does not honor context correctly
Summary: oc serviceaccounts create-kubeconfig does not honor context correctly
Keywords:
Status: CLOSED DUPLICATE of bug 1827463
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: oc
Version: 4.4
Hardware: All
OS: All
unspecified
medium
Target Milestone: ---
: ---
Assignee: Maciej Szulik
QA Contact: zhou ying
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-05-20 19:56 UTC by Steve Kuznetsov
Modified: 2020-05-20 19:59 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-05-20 19:59:49 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

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 ***


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