nutanix-cloud-native / ndb-operator

Nutanix NDB Kubernetes Operator
Apache License 2.0
13 stars 24 forks source link

Support for Engine Specific Inputs in DB Provisioning #156

Closed mazin-s closed 1 year ago

mazin-s commented 1 year ago

ERA 30093

What this PR does / why we need it Provides support for Engine Specific Inputs in DB Provisioning. Below are the allowed additional arguments the user can specify

# PostGres
additionalArguments:
  listener_port: "1111"                            # Default: "5432"

# MySQL
additionalArguments:
  listener_port: "1111"                            # Default: "3306" 

# MongoDB
additionalArguments:
  listener_port: "1111"                            # Default: "27017"
  log_size: "150"                                  # Default: "100"
  journal_size: "150"                              # Default: "100"

# MSSQL
additionalArguments:
  sql_user_name: "mazin"                           # Defualt: "sa".
  authentication_mode: "mixed"                     # Default: "windows". Options are "windows" or "mixed". Must specify sql_user.
  server_collation: "<server-collation>"           # Default: "SQL_Latin1_General_CP1_CI_AS".
  database_collation:  "<server-collation>"        # Default: "SQL_Latin1_General_CP1_CI_AS".
  dbParameterProfileIdInstance: "<id-instance>"    # Default: Fetched from profile.
  vm_dbserver_admin_password: "<admin-password>"   # Default: Fetched from database secret.
  sql_user_password:         "<sq-user-password>"  # NO Default. Must specify authentication_mode as "mixed".
  windows_domain_profile_id: <domain-profile-id>   # NO Default. Must specify vm_db_server_user.
  vm_db_server_user: <vm-db-server-use>            # NO Default. Must specify windows_domain_profile_id.
  vm_win_license_key: <licenseKey>                 # NO Default.

How Has This Been Tested?:

  1. Added automated web-hook validation tests for optional 'additionalArguments'. As of now, all additionalArguments are actionArguments.
  2. Verified appender logic is correct when additionalArguments are specified, and when they are not
  3. Manually ran provisioning tests for each database engine. Below you'll find 4 yaml files and proof of success.

PostGres DB Yaml

apiVersion: ndb.nutanix.com/v1alpha1
kind: Database
metadata:
  name: db-pg-proof2
spec:
  ndb:
    clusterId: 600d54a1-af63-4af3-b252-51b4d5cba64f
    credentialSecret: ndb-secret-name
    server: https://10.51.140.71:8443/era/v0.9
    skipCertificateVerification: true
  databaseInstance:
    databaseInstanceName: db-pg-proof2
    databaseNames:
      - database_one
      - database_two
      - database_three
    credentialSecret: db-instance-secret-name
    size: 100
    timezone: "UTC"
    profiles: 
      compute:
        name: ""
        id: ""
      # A Software profile is a mandatory input for proprietary (closed-source) engines such as SQL Server & Oracle
      software:
        name: ""
        id: ""
      network:
        name: ""
        id: ""
      dbParam:
        name: ""
        id: ""
      dbParamInstance:
        name: ""
        id: ""
    timeMachine:
      sla : "NONE"
      dailySnapshotTime:   "12:34:56"   # Time for daily snapshot in hh:mm:ss format
      snapshotsPerDay:     4            # Number of snapshots per day
      logCatchUpFrequency: 90           # Frequency (in minutes)
      weeklySnapshotDay:   "WEDNESDAY"  # Day of the week for weekly snapshot
      monthlySnapshotDay:  24           # Day of the month for monthly snapshot
      quarterlySnapshotMonth: "Jan"     # Start month of the quarterly snapshot
    type: postgres
    additionalArguments:
      listener_port: "1111"

MYSQL DB Yaml

apiVersion: ndb.nutanix.com/v1alpha1
kind: Database
metadata:
  name: db-mysql-proof2
spec:
  ndb:
    clusterId: 600d54a1-af63-4af3-b252-51b4d5cba64f
    credentialSecret: ndb-secret-name
    server: https://10.51.140.71:8443/era/v0.9
    skipCertificateVerification: true
  databaseInstance:
    databaseInstanceName:  db-mysql-proof2
    databaseNames:
      - database_one
    credentialSecret: db-instance-secret-name
    size: 20
    timezone: UTC
    type: mysql
    profiles: 
      compute:
        name: ""
        id: ""
      # A Software profile is a mandatory input for proprietary (closed-source) engines such as SQL Server & Oracle
      software:
        name: ""
        id: ""
      network:
        name: ""
        id: ""
      dbParam:
        name: ""
        id: ""
      dbParamInstance:
        name: ""
        id: ""
    timeMachine:
      sla : "NONE"
      dailySnapshotTime:   "12:34:56"   # Time for daily snapshot in hh:mm:ss format
      snapshotsPerDay:     4            # Number of snapshots per day
      logCatchUpFrequency: 90           # Frequency (in minutes)
      weeklySnapshotDay:   "WEDNESDAY"  # Day of the week for weekly snapshot
      monthlySnapshotDay:  24           # Day of the month for monthly snapshot
      quarterlySnapshotMonth: "Jan"     # Start month of the quarterly snapshot
    additionalArguments:
      listener_port: "1111"

Mongo DB Yaml

apiVersion: ndb.nutanix.com/v1alpha1
kind: Database
metadata:
  name: db-mongo-proof2
spec:
  ndb:
    clusterId: 600d54a1-af63-4af3-b252-51b4d5cba64f
    credentialSecret: ndb-secret-name
    server: https://10.51.140.71:8443/era/v0.9
    skipCertificateVerification: true
  databaseInstance:
    databaseInstanceName: db-mongo-proof2
    databaseNames:
      - database_one
    credentialSecret: db-instance-secret-name
    size: 20
    timezone: "UTC"
    type: mongodb
    profiles: 
      compute:
        name: ""
        id: ""
      # A Software profile is a mandatory input for proprietary (closed-source) engines such as SQL Server & Oracle
      software:
        name: ""
        id: ""
      network:
        name: ""
        id: ""
      dbParam:
        name: ""
        id: ""
      dbParamInstance:
        name: ""
        id: ""
    timeMachine:
      sla : "NONE"
      dailySnapshotTime:   "12:34:56"   # Time for daily snapshot in hh:mm:ss format
      snapshotsPerDay:     4            # Number of snapshots per day
      logCatchUpFrequency: 90           # Frequency (in minutes)
      weeklySnapshotDay:   "WEDNESDAY"  # Day of the week for weekly snapshot
      monthlySnapshotDay:  24           # Day of the month for monthly snapshot
      quarterlySnapshotMonth: "Jan"     # Start month of the quarterly snapshot
    additionalArguments:
      listener_port: "1111"
      log_size: "100"
      journal_size: "100"

MSSQL DB Yaml

apiVersion: ndb.nutanix.com/v1alpha1
kind: Database
metadata:
  name: db-mssql-proof2
spec:
  ndb:
    clusterId: 600d54a1-af63-4af3-b252-51b4d5cba64f
    credentialSecret: ndb-secret-name
    server: https://10.51.140.71:8443/era/v0.9
    skipCertificateVerification: true
  databaseInstance:
    databaseInstanceName: db-mssql-proof2
    databaseNames:
      - database_one
    credentialSecret: db-instance-secret-name
    size: 20
    timezone: UTC
    type: mssql
    profiles:
      compute:
        name: ""
        id: ""
      # A Software profile is a mandatory input for closed-source engines: SQL Server & Oracle
      software:
        name: MSSQL-MAZIN2
        # id: "7281c9a9-1639-4cbd-a9cc-f0b0422ba90a"
      dbParam:
        name: DEFAULT_SQLSERVER_INSTANCE_PARAMS
      dbParamInstance: 
        name: DEFAULT_SQLSERVER_INSTANCE_PARAMS
    timeMachine:
      sla : "NONE"
      dailySnapshotTime:   "12:34:56"   # Time for daily snapshot in hh:mm:ss format
      snapshotsPerDay:     4            # Number of snapshots per day
      logCatchUpFrequency: 90           # Frequency (in minutes)
      weeklySnapshotDay:   "WEDNESDAY"  # Day of the week for weekly snapshot
      monthlySnapshotDay:  24           # Day of the month for monthly snapshot
      quarterlySnapshotMonth: "Jan"     # Start month of the quarterly snapshot
    additionalArguments:
      authentication_mode: "mixed"
      server_collation: "SQL_Latin1_General_CPI_CI_AS"
      database_collation: "SQL_Latin1_General_CPI_CI_AS"

image image image image image

Postgres listener port correctly changed: image

MongoDB listener port correctly changed (also sum of database size, log size, and journal size is 299. Expected 300. Success. image

MYSQL listener port correct changed image

MSSQL "mixed" auth set image