New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using kubeconfig from Rancher does not work #32
Comments
Hi, what I can see from your provided Kubeconfig, the problem is within the first cluster ( For desktop this should be fixed in #25. For the mobile version of kubenav, I will come up with a PR for the next version where the |
Hi @matt-canty-dragon, on desktop you can try out the nightly builds where the fix for your issue is included. |
I downloaded https://storage.googleapis.com/kubenav/2020-03-01/kubenav-1.2.0-darwin-amd64.dmg I get this in the clusters page |
Mh currently I have no idea, whats going wrong there. There are some open issues regarding certificates in the http://github.com/kubernetes-client/javascript repo, but I do not know if they are related. Do you have node installed and can run the following, this would be super helpful to see if the error is within kubenav or the used client library: mkdir test
cd test
cat <<EOF >> package.json
{
"name": "test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"@kubernetes/client-node": "^0.11.1",
"request": "^2.88.2"
}
}
EOF
cat <<EOF >> index.js
const request = require('request');
const k8s = require('@kubernetes/client-node');
const kc = new k8s.KubeConfig();
kc.loadFromDefault();
const opts = {
url: kc.getCluster(kc.getContextObject(kc.getCurrentContext()).cluster).server + '/api/v1/namespaces',
method: 'GET',
};
kc.applyToRequest(opts);
request(opts, (error, response, body) => {
if (error) {
console.log('ERROR');
console.log(error);
} else {
if (!(response.statusCode >= 200 && response.statusCode < 300)) {
console.log('ERROR');
console.log(body);
} else {
console.log('SUCCESS');
console.log(body)
}
}
});
EOF
npm install
node index.js The script uses the current context from your Kubeconfig file and returns all Namespaces. If there is an error the error will be printed. |
Hey so it's working now. I did the following: given some KUBECONFIGs apiVersion: v1
kind: Config
clusters:
- name: "cluster-1"
cluster:
server: "https://rancher.REDACTED"
- name: "cluster-1-fqdn"
cluster:
server: "https://internal-REDACTED"
certificate-authority-data: "REDACTED"
users:
- name: "u-abcd123-cluster-1"
user:
token: "kubeconfig-REDACTED"
contexts:
- name: "cluster-1"
context:
user: "u-abcd123-cluster-1"
cluster: "cluster-1"
- name: "cluster-1-fqdn"
context:
user: "u-abcd123-cluster-1"
cluster: "cluster-1-fqdn"
current-context: "cluster-1" apiVersion: v1
kind: Config
clusters:
- name: "cluster-2"
cluster:
server: "https://rancher.REDACTED"
- name: "cluster-2-fqdn"
cluster:
server: "https://internal-REDACTED"
certificate-authority-data: "REDACTED"
users:
- name: "u-abcd123-cluster-2"
user:
token: "kubeconfig-REDACTED"
contexts:
- name: "cluster-2"
context:
user: "u-abcd123-cluster-2"
cluster: "cluster-2"
- name: "cluster-2-fqdn"
context:
user: "u-abcd123-cluster-2"
cluster: "cluster-2-fqdn"
current-context: "cluster-2" I merged them and removed the fqdn cluster definitions apiVersion: v1
clusters:
- cluster:
server: https://rancher.REDACTED
name: cluster-1
- cluster:
server: https://rancher.REDACTED
name: cluster-2
contexts:
- context:
cluster: cluster-1
namespace: card-service
user: u-abcd123-cluster-1
name: cluster-1
- context:
cluster: cluster-2
namespace: monitoring
user: u-abcd123-cluster-2
name: cluster-2
current-context: cluster-1
kind: Config
preferences: {}
users:
- name: u-abcd123-cluster-1
user:
token: kubeconfig-REDACTED
- name: u-abcd123-cluster-2
user:
token: kubeconfig-REDACTED This works for cluster selection, however now I have another issue: How do I switch namespaces? |
Nice. I really like it. So lean. Bravo 👏 |
I tried using the kubeconfig approach to using kubenav. The Add Clusters popup includes a note to say:
My kubeconfig contains `certificate-authority-data` however it is on a fqdn cluster...:
alas...
Appreciate what you have done, it looks great. I look forward to checking back another time!
The text was updated successfully, but these errors were encountered: