Skip to content

Commit

Permalink
manual backport of vsphere secret sync
Browse files Browse the repository at this point in the history
  • Loading branch information
Mo Mesgin authored and richard-cox committed Oct 9, 2024
1 parent ccc6034 commit 67b818c
Show file tree
Hide file tree
Showing 4 changed files with 294 additions and 37 deletions.
53 changes: 26 additions & 27 deletions shell/assets/translations/en-us.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -355,9 +355,8 @@ addClusterMemberDialog:
title: Add Cluster Member

addonConfigConfirmation:
title: Add-On Config Reset
body: Changing the Kubernetes Version can reset the Add-On Config values. You should check that the values are as expected before continuing.

title: Add-On Reset
body: Changing the Kubernetes Version can reset Add-On values. You should check that the values are as expected before continuing.
addProjectMemberDialog:
title: Add Project Member

Expand Down Expand Up @@ -1108,38 +1107,38 @@ cis:
cluster:
addonChart:
rancher-vsphere-cpi:
label: vSphere CPI
configuration: vSphere CPI Configuration
label: "Add-on: vSphere CPI"
configuration: vSphere CPI
rancher-vsphere-csi:
label: vSphere CSI
configuration: vSphere CSI Configuration
label: "Add-on: vSphere CSI"
configuration: vSphere CSI
rke2-calico:
label: Calico
configuration: Calico Configuration
label: "Add-on: Calico"
configuration: Calico
rke2-calico-crd:
label: Calico
configuration: Calico Configuration
label: "Add-on: Calico"
configuration: Calico
rke2-canal:
label: Canal
configuration: Canal Configuration
label: "Add-on: Canal"
configuration: Canal
rke2-cilium:
label: Cilium
configuration: Cilium Configuration
label: "Add-on: Cilium"
configuration: Cilium
rke2-coredns:
label: CoreDNS
configuration: CoreDNS Configuration
label: "Add-on: CoreDNS"
configuration: CoreDNS
rke2-ingress-nginx:
label: NGINX
configuration: NGINX Ingress Configuration
label: "Add-on: NGINX"
configuration: NGINX Ingress
rke2-kube-proxy:
label: Kube Proxy
configuration: Kube Proxy Configuration
label: "Add-on: Kube Proxy"
configuration: Kube Proxy
rke2-metrics-server:
label: Metrics Server
configuration: Metrics Server Configuration
label: "Add-on: Metrics Server"
configuration: Metrics Server
rke2-multus:
label: Multus
configuration: Multus Configuration
label: "Add-on: Multus"
configuration: Multus
agentEnvVars:
label: Agent Environment
detail: Add additional environment variables to the agent container. This is most commonly useful for configuring a HTTP proxy.
Expand All @@ -1155,7 +1154,7 @@ cluster:
label: Google
rancher-vsphere:
label: vSphere
note: '<b>Important:</b> Configure the vSphere Cloud Provider and Storage Provider options in the tabs on the left.'
note: '<b>Important:</b> Configure the vSphere Cloud Provider and Storage Provider options in the Add-on tabs.'
harvester:
label: Harvester
copyConfig: Copy KubeConfig to Clipboard
Expand Down Expand Up @@ -1655,7 +1654,7 @@ cluster:
serverOs:
label: OS
addOns:
dependencyBanner: Add-On Configurations can vary between Kubernetes versions. Changing the Kubernetes version may reset the values below.
dependencyBanner: Add-On Configuration can vary between Kubernetes versions. Changing the Kubernetes version may reset the values below.
additionalManifest:
title: Additional Manifest
tooltip: 'Additional Kubernetes Manifest YAML to be applied to the cluster on startup.'
Expand Down
39 changes: 30 additions & 9 deletions shell/edit/provisioning.cattle.io.cluster/rke2.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ import MemberRoles from '@shell/edit/provisioning.cattle.io.cluster/MemberRoles'
import Basics from '@shell/edit/provisioning.cattle.io.cluster/Basics';
import AddOnConfig from '@shell/edit/provisioning.cattle.io.cluster/tabs/AddOnConfig';
import AddOnAdditionalManifest from '@shell/edit/provisioning.cattle.io.cluster/tabs/AddOnAdditionalManifest';
import VsphereUtils from '@shell/utils/v-sphere';
const HARVESTER = 'harvester';
const HARVESTER_CLOUD_PROVIDER = 'harvester-cloud-provider';
Expand Down Expand Up @@ -839,6 +840,8 @@ export default {
created() {
this.registerBeforeHook(this.saveMachinePools, 'save-machine-pools', 1);
this.registerBeforeHook(this.setRegistryConfig, 'set-registry-config');
this.registerBeforeHook(this.handleVsphereCpiSecret, 'sync-vsphere-cpi');
this.registerBeforeHook(this.handleVsphereCsiSecret, 'sync-vsphere-csi');
this.registerAfterHook(this.cleanupMachinePools, 'cleanup-machine-pools');
this.registerAfterHook(this.saveRoleBindings, 'save-role-bindings');
Expand All @@ -851,6 +854,13 @@ export default {
methods: {
set,
async handleVsphereCpiSecret() {
return VsphereUtils.handleVsphereCpiSecret(this);
},
async handleVsphereCsiSecret() {
return VsphereUtils.handleVsphereCsiSecret(this);
},
/**
* Initialize all the cluster specs
*/
Expand Down Expand Up @@ -1387,6 +1397,13 @@ export default {
// We cannot use the hook, because it is triggered on YAML toggle without restore initialized data
this.agentConfigurationCleanup();
// TODO: RC
// Shows `Changing the Kubernetes Version can reset the Add-On Config values. You should check that the values are as expected before continuing.`
// if editing cluster and kube version has changed
// 2. rancher-vsphere:
// 3: addOns:
// dependencyBanner:
const isEditVersion = this.isEdit && this.liveValue?.spec?.kubernetesVersion !== this.value?.spec?.kubernetesVersion;
const hasPspManuallyAdded = !!this.value.spec.rkeConfig?.machineGlobalConfig?.['kube-apiserver-arg'];
Expand Down Expand Up @@ -1481,16 +1498,18 @@ export default {
return await this.extensionProvider?.saveCluster(this.value, this.schema);
}
if ( this.isCreate ) {
url = url || this.schema.linkFor('collection');
const res = await this.value.save({ url });
throw new Error('oh no....'); // TODO: RC
if (res) {
Object.assign(this.value, res);
}
} else {
await this.value.save();
}
// if ( this.isCreate ) {
// url = url || this.schema.linkFor('collection');
// const res = await this.value.save({ url });
// if (res) {
// Object.assign(this.value, res);
// }
// } else {
// await this.value.save();
// }
},
// create a secret to reference the harvester cluster kubeconfig in rkeConfig
Expand Down Expand Up @@ -1596,6 +1615,8 @@ export default {
const fromUser = this.userChartValuesTemp[name];
const different = diff(fromChart, fromUser);
console.warn(name, different, fromChart, this.userChartValues); // TODO: RC
this.userChartValues[this.chartVersionKey(name)] = different;
}, 250, { leading: true }),
Expand Down
2 changes: 1 addition & 1 deletion shell/utils/cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export function abbreviateClusterName(input) {

export function labelForAddon(name, configuration = true) {
const addon = camelToTitle(name.replace(/^(rke|rke2|rancher)-/, ''));
const fallback = `${ addon } ${ configuration ? 'Configuration' : '' }`;
const fallback = `${ configuration ? '' : 'Add-on: ' }${ addon }`;
const key = `cluster.addonChart."${ name }"${ configuration ? '.configuration' : '.label' }`;

return this.$store.getters['i18n/withFallback'](key, null, fallback);
Expand Down
Loading

0 comments on commit 67b818c

Please sign in to comment.