Skip to content

Commit

Permalink
fix(getInCluster): Use ca.crt correctly (#87)
Browse files Browse the repository at this point in the history
The ca.crt file inside a pod is the 'certificate authority', not a 'client certificate'.
  • Loading branch information
ankon authored and silasbw committed Feb 25, 2017
1 parent b7fa06f commit 3c18ebf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const fs = require('fs');
const path = require('path');
const yaml = require('js-yaml');

const certPath = '/var/run/secrets/kubernetes.io/serviceaccount/ca.crt';
const caPath = '/var/run/secrets/kubernetes.io/serviceaccount/ca.crt';
const tokenPath = '/var/run/secrets/kubernetes.io/serviceaccount/token';
const namespacePath = '/var/run/secrets/kubernetes.io/serviceaccount/namespace';

Expand All @@ -27,13 +27,13 @@ function getInCluster () {
' and KUBERNETES_SERVICE_PORT must be defined');
}

const cert = fs.readFileSync(certPath, 'utf8');
const ca = fs.readFileSync(caPath, 'utf8');
const bearer = fs.readFileSync(tokenPath, 'utf8');
const namespace = fs.readFileSync(namespacePath, 'utf8');

return {
url: `https://${host}:${port}`,
cert,
ca,
auth: { bearer },
namespace
};
Expand Down
4 changes: 2 additions & 2 deletions test/config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('Config', () => {

fsReadFileSync
.withArgs('/var/run/secrets/kubernetes.io/serviceaccount/ca.crt')
.returns('my-cert')
.returns('my-ca')

fsReadFileSync
.withArgs('/var/run/secrets/kubernetes.io/serviceaccount/token')
Expand All @@ -44,7 +44,7 @@ describe('Config', () => {
const configInCluster = config.getInCluster();
assume(configInCluster).eqls({
auth: { bearer: 'my-token' },
cert: 'my-cert',
ca: 'my-ca',
namespace: 'my-namespace',
url: 'https://myhost:443'
});
Expand Down

0 comments on commit 3c18ebf

Please sign in to comment.