Add rke1 cloud provider for harvester

This commit is contained in:
n313893254 2021-11-24 14:59:56 +08:00
parent f553d2758e
commit 0334d00d0e
4 changed files with 52 additions and 1 deletions

View File

@ -207,6 +207,7 @@
@clusterTemplateRevision={{model.clusterTemplateRevision}}
@questions={{model.clusterTemplateRevision.questions}}
@addOverride={{action "addOverride"}}
@model={{model}}
/>
</div>
</div>

View File

@ -229,6 +229,7 @@ export default Component.extend({
let selectedCloudProvider = get(this, 'selectedCloudProvider');
let cluster = get(this, 'cluster');
let config = get(cluster, 'rancherKubernetesEngineConfig') || set(cluster, 'rancherKubernetesEngineConfig', {});
let harvesterCluster = {}
switch (selectedCloudProvider) {
case 'azure':
@ -269,6 +270,26 @@ export default Component.extend({
break;
case 'harvester':
harvesterCluster = this.getHarvesterCluster()
set(config, 'cloudProvider', get(this, 'globalStore').createRecord({
type: 'cloudProvider',
name: 'harvester',
}));
set(this, 'configAnswers', nue);
harvesterCluster.doAction('generateKubeconfig')
.then((obj) => {
set(config, 'cloudProvider.harvesterCloudProvider.cloudConfig', get(obj, 'config'))
})
.catch((err) => {
this.get('growl').fromError('Error getting kubeconfig file', err);
})
break;
case 'external':
set(config, 'cloudProvider', get(this, 'globalStore').createRecord({
@ -299,5 +320,12 @@ export default Component.extend({
throw new Error('addOverride action is required!');
},
getHarvesterCluster() {
const cloudCredentialId = get(this, 'model.nodeTemplates.firstObject.cloudCredentialId')
const cloudCredential = get(this, 'globalStore').getById('cloudCredential', cloudCredentialId)
const clusterId = get(cloudCredential, 'harvestercredentialConfig.clusterId')
const harvesterCluster = get(this, 'globalStore').getById('cluster', clusterId)
return harvesterCluster
},
});

View File

@ -96,7 +96,27 @@
</div>
{{/if}}
{{/if}}
{{#if (and (not-eq driver "amazonec2") (not-eq driver "azure"))}}
{{#if (eq driver "harvester")}}
{{#if (and applyClusterTemplate (eq selectedCloudProvider "harvester"))}}
<div class="radio">
<label>
{{t "cloudProvider.harvester.label"}}
</label>
</div>
{{else if isCreateClusterOrClusterTemplate}}
<div class="radio">
<label>
{{radio-button
selection=selectedCloudProvider
value="harvester"
}} {{t "cloudProvider.harvester.label"}}
</label>
</div>
{{/if}}
{{/if}}
{{#if (and (not-eq driver "amazonec2") (not-eq driver "azure") (not-eq driver "harvester"))}}
{{#if (and applyClusterTemplate (eq selectedCloudProvider "generic"))}}
<div class="radio">
<label>

View File

@ -3173,6 +3173,8 @@ cloudProvider:
label: Custom (In-Tree)
notInList: 'If your cloud provider is not listed, please use the <b>Custom</b> option.'
helpText: 'Please edit the YAML to add in any other <a href="http://rancher.com/docs/rke/v0.1.x/en/config-options/cloud-providers/" target="_blank" rel="nofollow noopener noreferrer">cloud providers</a>'
harvester:
label: Harvester (Out-of-tree)
helpText: |
Read more about the state of the <a href="https://kubernetes.io/blog/2019/04/17/the-future-of-cloud-providers-in-kubernetes/" target="_blank" rel="nofollow noopener noreferrer">Kubernetes in-tree cloud providers</a>