Skip to content

Commit

Permalink
Adds supports for external Postgres for noobaa
Browse files Browse the repository at this point in the history
Signed-off-by: vbadrina <[email protected]>
  • Loading branch information
vbnrh committed Nov 13, 2023
1 parent e71d640 commit ebc2e7b
Show file tree
Hide file tree
Showing 7 changed files with 376 additions and 5 deletions.
12 changes: 11 additions & 1 deletion locales/en/plugin__odf-console.json
Original file line number Diff line number Diff line change
Expand Up @@ -615,10 +615,21 @@
"Data Foundation will use a StorageClass provided by the Local Storage Operator (LSO) on top of your attached drives. This option is available on any platform with devices attached to nodes.": "Data Foundation will use a StorageClass provided by the Local Storage Operator (LSO) on top of your attached drives. This option is available on any platform with devices attached to nodes.",
"Connect an external storage platform": "Connect an external storage platform",
"Data Foundation will create a dedicated StorageClass.": "Data Foundation will create a dedicated StorageClass.",
"Use external postgres": "Use external postgres",
"Allow Noobaa to connect to an external postgres server": "Allow Noobaa to connect to an external postgres server",
"NFS is currently not supported for external storage type. To proceed with an external storage type, disable this option.": "NFS is currently not supported for external storage type. To proceed with an external storage type, disable this option.",
"NFS is currently not supported for external storage type.": "NFS is currently not supported for external storage type.",
"Enable network file system (NFS)": "Enable network file system (NFS)",
"Allow NFS to use low resources by default.": "Allow NFS to use low resources by default.",
"Server": "Server",
"Port": "Port",
"Database name": "Database name",
"Enable TLS/SSL": "Enable TLS/SSL",
"Enable this for encrytion on flight with the Postgres server": "Enable this for encrytion on flight with the Postgres server",
"Allow self-signed certificates": "Allow self-signed certificates",
"Adding this option will allow the postgres server to use a self-signed certificates.": "Adding this option will allow the postgres server to use a self-signed certificates.",
"Enable client-side certificates": "Enable client-side certificates",
"Select this option to upload and use your client side certificates": "Select this option to upload and use your client side certificates",
"Deploys MultiCloud Object Gateway without block and file services.": "Deploys MultiCloud Object Gateway without block and file services.",
"Deploys Data Foundation with block, shared fileSystem and object services.": "Deploys Data Foundation with block, shared fileSystem and object services.",
"Deployment type": "Deployment type",
Expand Down Expand Up @@ -782,7 +793,6 @@
"Please enter a URL": "Please enter a URL",
"Please enter a valid port": "Please enter a valid port",
"Address": "Address",
"Port": "Port",
"Client certificate": "Client certificate",
"CA certificate": "CA certificate",
"Client private key": "Client private key",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ import {
Radio,
Alert,
AlertVariant,
Checkbox,
} from '@patternfly/react-core';
import { ErrorHandler } from '../../error-handler';
import { WizardState, WizardDispatch } from '../../reducer';
import { EnableNFS } from './enable-nfs';
import { PostgresConnectionDetails } from './enable-noobaa-postgres-tls';
import { SelectDeployment } from './select-deployment';
import { SetCephRBDStorageClassDefault } from './set-rbd-sc-default';
import './backing-storage-step.scss';
Expand Down Expand Up @@ -188,6 +190,8 @@ export const BackingStorage: React.FC<BackingStorageProps> = ({
isRBDStorageClassDefault,
externalStorage,
deployment,
externalPostgres,
useExternalPostgres,
} = state;

const { t } = useCustomTranslation();
Expand Down Expand Up @@ -359,6 +363,34 @@ export const BackingStorage: React.FC<BackingStorageProps> = ({
/>
</>
)}
<Checkbox
id="use-external-postgress"
label={t('Use external postgres')}
description={t(
'Allow Noobaa to connect to an external postgres server'
)}
isChecked={useExternalPostgres}
onChange={() =>
dispatch({
type: 'backingStorage/useExternalPostgres',
payload: !useExternalPostgres,
})
}
className="odf-backing-store__radio--margin-bottom"
/>
{useExternalPostgres && (
<PostgresConnectionDetails
dispatch={dispatch}
tlsEnabled={externalPostgres.TLS.enabled}
allowSelfSignedCerts={externalPostgres.TLS.allowSelfSignedCerts}
username={externalPostgres.username}
password={externalPostgres.password}
serverName={externalPostgres.serverName}
databaseName={externalPostgres.databaseName}
port={externalPostgres.port}
enableClientSideCerts={externalPostgres.TLS.enableClientSideCerts}
/>
)}
</Form>
</ErrorHandler>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
import * as React from 'react';
import { useCustomTranslation } from '@odf/shared/useCustomTranslationHook';
import {
FormGroup,
Checkbox,
TextInput,
Form,
GridItem,
Grid,
Text,
TextVariants,
Stack,
} from '@patternfly/react-core';
import { WizardDispatch, WizardState } from '../../reducer';
import './backing-storage-step.scss';

export const PostgresConnectionDetails: React.FC<PostgresConnectionDetails> = ({
dispatch,
username,
password,
serverName,
port,
databaseName,
tlsEnabled,
allowSelfSignedCerts,
enableClientSideCerts,
}) => {
const { t } = useCustomTranslation();

return (
<Form>
<Text component={TextVariants.h4}>Connection details</Text>
<Grid hasGutter md={12}>
<GridItem md={8} span={2}>
<FormGroup label={t('Username')} fieldId="username-tls" isRequired>
<TextInput
id="username-input"
type="text"
value={username}
onChange={(newUsername: string) => {
dispatch({
type: 'backingStorage/externalPostgres/setUsername',
payload: newUsername,
});
}}
isRequired
/>
</FormGroup>
</GridItem>
<GridItem md={8} span={2}>
<FormGroup label={t('Password')} fieldId="password-tls" isRequired>
<TextInput
id="password-input"
type="password"
value={password}
onChange={(newPassword: string) => {
dispatch({
type: 'backingStorage/externalPostgres/setPassword',
payload: newPassword,
});
}}
isRequired
/>
</FormGroup>
</GridItem>
<GridItem md={6} span={10}>
<FormGroup label={t('Server')} fieldId="server-tls" isRequired>
<TextInput
id="server-input"
type="text"
value={serverName}
onChange={(newServer: string) => {
dispatch({
type: 'backingStorage/externalPostgres/setServerName',
payload: newServer,
});
}}
isRequired
/>
</FormGroup>
</GridItem>
<GridItem md={6} span={2}>
<FormGroup label={t('Port')} fieldId="port-tls" isRequired>
<TextInput
id="port-input"
type="number"
value={port}
onChange={(newPort: string) => {
dispatch({
type: 'backingStorage/externalPostgres/setPort',
payload: newPort,
});
}}
isRequired
/>
</FormGroup>
</GridItem>
<GridItem md={8} span={2}>
<FormGroup
label={t('Database name')}
fieldId="database-tls"
isRequired
>
<TextInput
id="database-input"
type="text"
value={databaseName}
onChange={(newDatabase: string) => {
dispatch({
type: 'backingStorage/externalPostgres/setDatabaseName',
payload: newDatabase,
});
}}
isRequired
/>
</FormGroup>
</GridItem>
</Grid>
<FormGroup fieldId="enable-tls">
<Checkbox
id="enable-tls"
label={t('Enable TLS/SSL')}
description={t(
'Enable this for encrytion on flight with the Postgres server'
)}
isChecked={tlsEnabled}
onChange={() => {
const isTLSEnabled = !tlsEnabled;
dispatch({
type: 'backingStorage/externalPostgres/TLS/enableTLS',
payload: !tlsEnabled,
});

dispatch({
type: 'backingStorage/externalPostgres/TLS/allowSelfSignedCerts',
payload:
!isTLSEnabled && allowSelfSignedCerts
? false
: allowSelfSignedCerts,
});

dispatch({
type: 'backingStorage/externalPostgres/TLS/enableClientSideCerts',
payload:
!isTLSEnabled && enableClientSideCerts
? false
: enableClientSideCerts,
});
}}
className="odf-backing-store__radio--margin-bottom"
/>
{tlsEnabled && (
<Stack hasGutter>
<Checkbox
id="allow-self-signed-certs"
label={t('Allow self-signed certificates')}
description={t(
'Adding this option will allow the postgres server to use a self-signed certificates.'
)}
isChecked={allowSelfSignedCerts}
onChange={() =>
dispatch({
type: 'backingStorage/externalPostgres/TLS/allowSelfSignedCerts',
payload: !allowSelfSignedCerts,
})
}
/>
<Checkbox
id="enable-client-side-certs"
label={t('Enable client-side certificates')}
description={t(
'Select this option to upload and use your client side certificates'
)}
isChecked={enableClientSideCerts}
onChange={() =>
dispatch({
type: 'backingStorage/externalPostgres/TLS/enableClientSideCerts',
payload: !enableClientSideCerts,
})
}
/>
</Stack>
)}
</FormGroup>
</Form>
);
};

type PostgresConnectionDetails = {
dispatch: WizardDispatch;
username: WizardState['backingStorage']['externalPostgres']['username'];
password: WizardState['backingStorage']['externalPostgres']['password'];
serverName: WizardState['backingStorage']['externalPostgres']['serverName'];
port: WizardState['backingStorage']['externalPostgres']['port'];
databaseName: WizardState['backingStorage']['externalPostgres']['databaseName'];
tlsEnabled: WizardState['backingStorage']['externalPostgres']['TLS']['enabled'];
allowSelfSignedCerts: WizardState['backingStorage']['externalPostgres']['TLS']['allowSelfSignedCerts'];
enableClientSideCerts: WizardState['backingStorage']['externalPostgres']['TLS']['enableClientSideCerts'];
};
16 changes: 14 additions & 2 deletions packages/odf/components/create-storage-system/payloads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,16 @@ export const createStorageCluster = async (state: WizardState) => {
enableSingleReplicaPool,
} = capacityAndNodes;
const { encryption, publicNetwork, clusterNetwork, kms } = securityAndNetwork;
const { type, enableNFS, isRBDStorageClassDefault, deployment } =
backingStorage;
const {
type,
enableNFS,
deployment,
isRBDStorageClassDefault,
useExternalPostgres,
externalPostgres: {
TLS: { allowSelfSignedCerts, enableClientSideCerts },
},
} = backingStorage;
const { enableRDRPreparation } = dataProtection;

const isNoProvisioner = storageClass?.provisioner === NO_PROVISIONER;
Expand Down Expand Up @@ -110,7 +118,11 @@ export const createStorageCluster = async (state: WizardState) => {
shouldSetCephRBDAsDefault,
isSingleReplicaPoolEnabled: enableSingleReplicaPool,
enableRDRPreparation,
useExternalPostgres,
allowNoobaaPostgresSelfSignedCerts: allowSelfSignedCerts,
enableNoobaaClientSideCerts: enableClientSideCerts,
});

return k8sCreate({ model: OCSStorageClusterModel, data: payload });
};

Expand Down
Loading

0 comments on commit ebc2e7b

Please sign in to comment.