mirror of https://github.com/rancher/ui.git
Add CA Certificate to kubeconfig
This commit is contained in:
parent
1b9cd1b2d2
commit
d3a9ca064a
|
|
@ -23,11 +23,11 @@ export default Component.extend(ModalBase, NewOrEdit, {
|
||||||
},
|
},
|
||||||
|
|
||||||
displayEndpoint: function() {
|
displayEndpoint: function() {
|
||||||
return this.get('endpointService.api.display.account.current');
|
return this.get('endpointService.api.display.current');
|
||||||
}.property(),
|
}.property(),
|
||||||
|
|
||||||
linkEndpoint: function() {
|
linkEndpoint: function() {
|
||||||
return this.get('endpointService.api.auth.account.current');
|
return this.get('endpointService.api.auth.current');
|
||||||
}.property(),
|
}.property(),
|
||||||
|
|
||||||
didInsertElement() {
|
didInsertElement() {
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,7 @@ clusters:
|
||||||
- name: "%clusterName%"
|
- name: "%clusterName%"
|
||||||
cluster:
|
cluster:
|
||||||
server: "%baseUrl%/k8s/clusters/%clusterId%"
|
server: "%baseUrl%/k8s/clusters/%clusterId%"
|
||||||
api-version: v1%maybeInsecure%%maybeCertificate%
|
api-version: v1%maybeCertificate%
|
||||||
certificate-authority-data: %clusterCert%
|
|
||||||
|
|
||||||
users:
|
users:
|
||||||
- name: "%username%"
|
- name: "%username%"
|
||||||
|
|
@ -37,6 +36,7 @@ export default Component.extend(ModalBase, {
|
||||||
access: service(),
|
access: service(),
|
||||||
growl: service(),
|
growl: service(),
|
||||||
scope: service(),
|
scope: service(),
|
||||||
|
settings: service(),
|
||||||
modalService: service('modal'),
|
modalService: service('modal'),
|
||||||
|
|
||||||
token: null,
|
token: null,
|
||||||
|
|
@ -47,19 +47,30 @@ export default Component.extend(ModalBase, {
|
||||||
|
|
||||||
replaceVariables(str) {
|
replaceVariables(str) {
|
||||||
let base = window.location.origin;
|
let base = window.location.origin;
|
||||||
let insecure = false;
|
|
||||||
if ( base.indexOf('http://') === 0 ) {
|
if ( base.indexOf('http://') === 0 ) {
|
||||||
base = base.replace(/^http:\/\//,'https://');
|
base = base.replace(/^http:\/\//,'https://');
|
||||||
if ( ! window.location.port ) {
|
if ( ! window.location.port ) {
|
||||||
base += ':80';
|
base += ':80';
|
||||||
}
|
}
|
||||||
insecure = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const me = get(this, 'access.me');
|
const me = get(this, 'access.me');
|
||||||
const cluster = get(this, 'scope.currentCluster');
|
const cluster = get(this, 'scope.currentCluster');
|
||||||
const tokenObj = get(this, 'token');
|
const tokenObj = get(this, 'token');
|
||||||
const certificate = get(this, `settings.${C.SETTING.CA_CERTS}`);
|
|
||||||
|
let cert = get(this, `settings.${C.SETTING.CA_CERTS}`);
|
||||||
|
let wrapped;
|
||||||
|
if ( cert && cert.length ) {
|
||||||
|
let ary = [];
|
||||||
|
cert = btoa(cert);
|
||||||
|
let split = 45;
|
||||||
|
while ( cert.length ) {
|
||||||
|
ary.push(cert.substr(0,split))
|
||||||
|
cert = cert.substr(split);
|
||||||
|
split=72;
|
||||||
|
}
|
||||||
|
wrapped = ary.join('\\\n ').trim();
|
||||||
|
}
|
||||||
|
|
||||||
let token = '';
|
let token = '';
|
||||||
if ( tokenObj ) {
|
if ( tokenObj ) {
|
||||||
|
|
@ -68,10 +79,9 @@ export default Component.extend(ModalBase, {
|
||||||
|
|
||||||
return str
|
return str
|
||||||
.replace(/%baseUrl%/g, base)
|
.replace(/%baseUrl%/g, base)
|
||||||
.replace(/%maybeInsecure%/g,(insecure ? '\n insecure-skip-tls-verify: true' : ''))
|
|
||||||
.replace(/%clusterId%/g, get(cluster, 'id'))
|
.replace(/%clusterId%/g, get(cluster, 'id'))
|
||||||
.replace(/%clusterName%/g, get(cluster, 'displayName'))
|
.replace(/%clusterName%/g, get(cluster, 'displayName'))
|
||||||
.replace(/%maybeCertificate%/g, (certificate ? '\n certificate-authority-data: ' + certificate : ''))
|
.replace(/%maybeCertificate%/g, (wrapped ? '\n certificate-authority-data: "' + wrapped + '"': ''))
|
||||||
.replace(/%username%/g, get(me, 'username'))
|
.replace(/%username%/g, get(me, 'username'))
|
||||||
.replace(/%token%/g, token);
|
.replace(/%token%/g, token);
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if (eq step 2)}}
|
{{#if (eq step 2)}}
|
||||||
<p>{{t 'k8sPage.configFile.usage.helpText' htmlSafe=true}}</p>
|
<p>{{t 'k8sPage.configFile.usage.helpText' htmlSafe=true}}</p>
|
||||||
<pre><code>{{kubeconfig}}</code></pre>
|
{{code-block language="yaml" code=kubeconfig}}
|
||||||
{{copy-to-clipboard tooltipText="" buttonText="copyToClipboard.tooltip" clipboardText=kubeconfig class="with-clip"}}
|
{{copy-to-clipboard tooltipText="" buttonText="copyToClipboard.tooltip" clipboardText=kubeconfig class="with-clip"}}
|
||||||
<p class="mt-10 mb-0">{{t 'k8sPage.configFile.usage.downloadText' downloadUrl=downloadUrl htmlSafe=true}}</p>
|
<p class="mt-10 mb-0">{{t 'k8sPage.configFile.usage.downloadText' downloadUrl=downloadUrl htmlSafe=true}}</p>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
|
||||||
|
|
@ -423,7 +423,7 @@ var C = {
|
||||||
WINDOWS: 'cli-url-windows',
|
WINDOWS: 'cli-url-windows',
|
||||||
LINUX: 'cli-url-linux',
|
LINUX: 'cli-url-linux',
|
||||||
},
|
},
|
||||||
CA_CERTS: 'ca-certs',
|
CA_CERTS: 'cacerts',
|
||||||
API_HOST: 'api-host',
|
API_HOST: 'api-host',
|
||||||
ENGINE_URL: 'engine-install-url',
|
ENGINE_URL: 'engine-install-url',
|
||||||
SUPPORTED_DOCKER: 'engine-supported-range',
|
SUPPORTED_DOCKER: 'engine-supported-range',
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue