Bug 1827463
| Summary: | [oc-cli]oc-sa-create-kubeconfig command does not work with `--context` | ||
|---|---|---|---|
| Product: | OpenShift Container Platform | Reporter: | Hongkai Liu <hongkliu> |
| Component: | oc | Assignee: | Jan Chaloupka <jchaloup> |
| Status: | CLOSED ERRATA | QA Contact: | zhou ying <yinzhou> |
| Severity: | medium | Docs Contact: | |
| Priority: | unspecified | ||
| Version: | 4.5 | CC: | aos-bugs, jokerman, mfojtik, skuznets, yinzhou |
| Target Milestone: | --- | ||
| Target Release: | 4.5.0 | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
| Whiteboard: | |||
| Fixed In Version: | Doc Type: | Bug Fix | |
| Doc Text: |
Cause: oc sa create-kubeconfig did not respect --context option
Consequence: oc sa create-kubeconfig created kubeconfig from the current context only
Fix: have oc sa create-kubeconfig respect --context option
Result: oc sa create-kubeconfig creates kubeconfig with --context as the current context if provided
|
Story Points: | --- |
| Clone Of: | Environment: | ||
| Last Closed: | 2020-07-13 17:30:56 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: | |||
With `oc --context zhouy/api-pdhamdhe-vsp18-qe-devcluster-openshift-com:6443/testuser-6 sa create-kubeconfig default`, I expect the generated kubeconfig to have api-pdhamdhe-vsp18-qe-devcluster-openshift-com:6443 in the cluster name, not api-yinzhou18-qe-gcp-devcluster-openshift-com:6443. Can you please re-verify again? *** Bug 1838298 has been marked as a duplicate of this bug. *** oc version --client
Client Version: 4.5.0-202005220507-44354e2
oc config get-contexts
CURRENT NAME CLUSTER AUTHINFO NAMESPACE
api.ci api-ci-openshift-org:443 hongkailiu/api-ci-openshift-org:443 hongkliu-test
* app.ci api-ci-l2s4-p1-openshiftapps-com:6443 hongkailiu/api-ci-l2s4-p1-openshiftapps-com:6443 hongkliu-test
build01 api-build01-ci-devcluster-openshift-com:6443 hongkailiu/api-build01-ci-devcluster-openshift-com:6443 hongkliu-test
build02 api-build02-gcp-ci-openshift-org:6443 hongkailiu/api-build02-gcp-ci-openshift-org:6443 hongkliu-test
oc --context build01 sa create-kubeconfig default
apiVersion: v1
clusters:
- cluster:
server: https://api.build01.ci.devcluster.openshift.com:6443
name: api-build01-ci-devcluster-openshift-com:6443
contexts:
- context:
cluster: api-build01-ci-devcluster-openshift-com:6443
namespace: hongkliu-test
user: default
name: default
current-context: default
kind: Config
preferences: {}
users:
- name: default
user:
token: XXX
Thanks for the fix.
[root@dhcp-140-138 ~]# oc config get-contexts
CURRENT NAME CLUSTER AUTHINFO NAMESPACE
/api-ugdci28074134-qe-azure-devcluster-openshift-com:6443/testuser-49 api-ugdci28074134-qe-azure-devcluster-openshift-com:6443 testuser-49
/api-yinzhou27-qe-gcp-devcluster-openshift-com:6443/testuser-30 api-yinzhou27-qe-gcp-devcluster-openshift-com:6443 testuser-30
* testzy/api-ugdci28074134-qe-azure-devcluster-openshift-com:6443/testuser-49 api-ugdci28074134-qe-azure-devcluster-openshift-com:6443 testuser-49 testzy
zhouy/api-yinzhou27-qe-gcp-devcluster-openshift-com:6443/testuser-30 api-yinzhou27-qe-gcp-devcluster-openshift-com:6443 testuser-30 zhouy
[root@dhcp-140-138 ~]# oc --context zhouy/api-yinzhou27-qe-gcp-devcluster-openshift-com:6443/testuser-30 sa create-kubeconfig default
apiVersion: v1
clusters:
- cluster:
insecure-skip-tls-verify: true
server: https://api.yinzhou27.qe.gcp.devcluster.openshift.com:6443
name: api-yinzhou27-qe-gcp-devcluster-openshift-com:6443
contexts:
- context:
cluster: api-yinzhou27-qe-gcp-devcluster-openshift-com:6443
namespace: zhouy
user: default
name: default
current-context: default
kind: Config
preferences: {}
users:
- name: default
user:
.....
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHBA-2020:2409 |
oc version --client Client Version: 4.5.0-202004231620-ae3e321 oc config get-contexts CURRENT NAME CLUSTER AUTHINFO NAMESPACE build01 api-build01-ci-devcluster-openshift-com:6443 hongkailiu/api-build01-ci-devcluster-openshift-com:6443 hongkliu-test * default api-ci-openshift-org:443 hongkailiu/api-ci-openshift-org:443 hongkliu-test oc --context build01 sa create-kubeconfig default 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: hongkliu-test user: default name: default current-context: default kind: Config preferences: {} users: - name: default user: token: bar