mongodb / mongodb-atlas-kubernetes

MongoDB Atlas Kubernetes Operator - Manage your MongoDB Atlas clusters from Kubernetes
http://www.mongodb.com/cloud/atlas
Apache License 2.0
146 stars 75 forks source link

`atlas kubernetes ...` cli generate manifest issues #851

Closed zelig81 closed 1 year ago

zelig81 commented 1 year ago

What did you do to encounter the bug? Steps to reproduce the behavior:

What did you expect?

  1. result of command atlas kubernetes config generate --targetNamespace atlas --projectId <project-id> when there is deployed a serverless deployment: I expect to get k8s manifests of project only (without serverless DB)
  2. result of command atlas kubernetes config generate --targetNamespace atlas --projectId <project-id> --clusterName <cluster-id>: I expect to get k8s manifests that I can deploy from scratch (as disaster recovery)

What happened instead? 1 . result of command - failure Error: cluster not found: ServerlessInstance0(63cf7301530d116214820fc4)

  1. result of command - k8s manifests with all values that include:
    • default values (makes manifest to be big without a reason)
    • read only attributes which makes an operator to fail to apply the changes (in case of free tier DB)
    • mix of cidrBlock and ipAddress which makes an operator to fail to apply the changes
    • irrelevant .metadata.creationTimestamp and .status
    • get error related to diskSizeGB

Operator Information

Kubernetes Cluster Information

Additional context Add any other context about the problem here.

output of atlas cli ```yaml --- apiVersion: atlas.mongodb.com/v1 kind: AtlasProject metadata: creationTimestamp: null name: poc2 namespace: atlas spec: alertConfigurations: - enabled: true eventTypeName: REPLICATION_OPLOG_WINDOW_RUNNING_OUT metricThreshold: threshold: "" notifications: - delayMin: 0 emailEnabled: true intervalMin: 60 roles: - GROUP_OWNER smsEnabled: false typeName: GROUP threshold: operator: LESS_THAN threshold: "1.000000" units: HOURS - enabled: true eventTypeName: NO_PRIMARY metricThreshold: threshold: "" notifications: - delayMin: 15 emailEnabled: true intervalMin: 60 roles: - GROUP_OWNER smsEnabled: false typeName: GROUP threshold: {} - enabled: true eventTypeName: CLUSTER_MONGOS_IS_MISSING metricThreshold: threshold: "" notifications: - delayMin: 15 emailEnabled: true intervalMin: 60 roles: - GROUP_OWNER smsEnabled: false typeName: GROUP threshold: {} - enabled: true eventTypeName: OUTSIDE_METRIC_THRESHOLD metricThreshold: metricName: CONNECTIONS_PERCENT mode: AVERAGE operator: GREATER_THAN threshold: "80.000000" units: RAW notifications: - delayMin: 0 emailEnabled: true intervalMin: 60 roles: - GROUP_OWNER smsEnabled: false typeName: GROUP threshold: {} - enabled: true eventTypeName: OUTSIDE_METRIC_THRESHOLD metricThreshold: metricName: DISK_PARTITION_SPACE_USED_DATA mode: AVERAGE operator: GREATER_THAN threshold: "90.000000" units: RAW notifications: - delayMin: 0 emailEnabled: true intervalMin: 60 roles: - GROUP_OWNER smsEnabled: false typeName: GROUP threshold: {} - enabled: true eventTypeName: OUTSIDE_METRIC_THRESHOLD metricThreshold: metricName: QUERY_TARGETING_SCANNED_OBJECTS_PER_RETURNED mode: AVERAGE operator: GREATER_THAN threshold: "1000.000000" units: RAW notifications: - delayMin: 10 emailEnabled: true intervalMin: 60 roles: - GROUP_OWNER smsEnabled: false typeName: GROUP threshold: {} - enabled: true eventTypeName: CREDIT_CARD_ABOUT_TO_EXPIRE metricThreshold: threshold: "" notifications: - delayMin: 0 emailEnabled: true intervalMin: 1440 roles: - GROUP_OWNER smsEnabled: false typeName: GROUP threshold: {} - enabled: true eventTypeName: OUTSIDE_METRIC_THRESHOLD metricThreshold: metricName: NORMALIZED_SYSTEM_CPU_USER mode: AVERAGE operator: GREATER_THAN threshold: "95.000000" units: RAW notifications: - delayMin: 0 emailEnabled: true intervalMin: 60 roles: - GROUP_OWNER smsEnabled: false typeName: GROUP threshold: {} - enabled: true eventTypeName: HOST_HAS_INDEX_SUGGESTIONS metricThreshold: threshold: "" notifications: - delayMin: 10 emailEnabled: true intervalMin: 60 roles: - GROUP_OWNER smsEnabled: false typeName: GROUP threshold: {} - enabled: true eventTypeName: HOST_MONGOT_CRASHING_OOM metricThreshold: threshold: "" notifications: - delayMin: 0 emailEnabled: true intervalMin: 60 roles: - GROUP_OWNER smsEnabled: false typeName: GROUP threshold: {} - enabled: true eventTypeName: OUTSIDE_SERVERLESS_METRIC_THRESHOLD metricThreshold: metricName: SERVERLESS_CONNECTIONS_PERCENT mode: AVERAGE operator: GREATER_THAN threshold: "80.000000" units: RAW notifications: - delayMin: 0 emailEnabled: true intervalMin: 60 roles: - GROUP_OWNER smsEnabled: false typeName: GROUP threshold: {} - enabled: true eventTypeName: OUTSIDE_SERVERLESS_METRIC_THRESHOLD metricThreshold: metricName: SERVERLESS_DATA_SIZE_TOTAL mode: AVERAGE operator: GREATER_THAN threshold: "0.750000" units: TERABYTES notifications: - delayMin: 0 emailEnabled: true intervalMin: 60 roles: - GROUP_OWNER smsEnabled: false typeName: GROUP threshold: {} - enabled: true eventTypeName: OUTSIDE_SERVERLESS_METRIC_THRESHOLD metricThreshold: metricName: SERVERLESS_TOTAL_READ_UNITS mode: AVERAGE operator: GREATER_THAN threshold: "0.250000" units: MILLION_RPU notifications: - delayMin: 30 emailEnabled: true intervalMin: 720 roles: - GROUP_OWNER smsEnabled: false typeName: GROUP threshold: {} - enabled: true eventTypeName: OUTSIDE_SERVERLESS_METRIC_THRESHOLD metricThreshold: metricName: SERVERLESS_TOTAL_READ_UNITS mode: AVERAGE operator: GREATER_THAN threshold: "1.000000" units: MILLION_RPU notifications: - delayMin: 5 emailEnabled: true intervalMin: 120 roles: - GROUP_OWNER smsEnabled: false typeName: GROUP threshold: {} - enabled: true eventTypeName: HOST_NOT_ENOUGH_DISK_SPACE metricThreshold: threshold: "" notifications: - delayMin: 0 emailEnabled: true intervalMin: 60 roles: - GROUP_OWNER smsEnabled: false typeName: GROUP threshold: {} - enabled: true eventTypeName: OUTSIDE_METRIC_THRESHOLD metricThreshold: metricName: SEARCH_MAX_NUMBER_OF_LUCENE_DOCS mode: AVERAGE operator: GREATER_THAN threshold: "1.000000" units: BILLION notifications: - delayMin: 0 emailEnabled: true intervalMin: 60 roles: - GROUP_OWNER smsEnabled: false typeName: GROUP threshold: {} - enabled: true eventTypeName: JOINED_GROUP metricThreshold: threshold: "" notifications: - delayMin: 0 emailEnabled: true intervalMin: 60 smsEnabled: false typeName: GROUP threshold: {} auditing: auditAuthorizationSuccess: false enabled: false connectionSecretRef: name: "" encryptionAtRest: awsKms: enabled: false valid: false azureKeyVault: enabled: false googleCloudKms: enabled: false maintenanceWindow: {} name: poc2 projectIpAccessList: - cidrBlock: 0.0.0.0/0 settings: isCollectDatabaseSpecificsStatisticsEnabled: true isDataExplorerEnabled: true isPerformanceAdvisorEnabled: true isRealtimePerformancePanelEnabled: true isSchemaAdvisorEnabled: true status: conditions: [] --- apiVersion: v1 data: orgId: "" privateApiKey: "" publicApiKey: "" kind: Secret metadata: creationTimestamp: null labels: atlas.mongodb.com/type: credentials name: poc2-credentials namespace: atlas --- apiVersion: atlas.mongodb.com/v1 kind: AtlasDeployment metadata: creationTimestamp: null name: cluster0 namespace: atlas spec: advancedDeploymentSpec: backupEnabled: true biConnector: enabled: false readPreference: secondary clusterType: REPLICASET encryptionAtRestProvider: NONE name: Cluster0 paused: false pitEnabled: false replicationSpecs: - numShards: 1 regionConfigs: - analyticsSpecs: instanceSize: M10 nodeCount: 0 autoScaling: compute: enabled: false scaleDownEnabled: false diskGB: enabled: true electableSpecs: instanceSize: M10 nodeCount: 3 priority: 7 providerName: GCP readOnlySpecs: instanceSize: M10 nodeCount: 0 regionName: CENTRAL_US zoneName: Zone 1 rootCertType: ISRGROOTX1 versionReleaseSystem: LTS backupRef: name: cluster0-backupschedule namespace: atlas processArgs: javascriptEnabled: true minimumEnabledTlsProtocol: TLS1_2 noTableScan: false projectRef: name: poc2 namespace: atlas status: conditions: [] --- apiVersion: atlas.mongodb.com/v1 kind: AtlasBackupSchedule metadata: creationTimestamp: null name: cluster0-backupschedule namespace: atlas spec: export: exportBucketId: "" frequencyType: "" policy: name: cluster0-backuppolicy namespace: atlas referenceHourOfDay: 8 referenceMinuteOfHour: 26 restoreWindowDays: 7 status: {} --- apiVersion: atlas.mongodb.com/v1 kind: AtlasBackupPolicy metadata: creationTimestamp: null name: cluster0-backuppolicy namespace: atlas spec: items: - frequencyInterval: 6 frequencyType: hourly retentionUnit: days retentionValue: 2 - frequencyInterval: 1 frequencyType: daily retentionUnit: days retentionValue: 7 - frequencyInterval: 6 frequencyType: weekly retentionUnit: weeks retentionValue: 4 - frequencyInterval: 40 frequencyType: monthly retentionUnit: months retentionValue: 12 status: {} --- ```
expected output of atlas cli (look for commented out strings) ```yaml --- apiVersion: atlas.mongodb.com/v1 kind: AtlasProject metadata: # creationTimestamp: null name: poc2 namespace: atlas annotations: # at least it will be good to have it commented in the output of `atlas kubernetes generate ...` output in order not to remove accidentally a project mongodb.com/atlas-resource-policy: "keep" spec: alertConfigurations: - enabled: true eventTypeName: REPLICATION_OPLOG_WINDOW_RUNNING_OUT metricThreshold: threshold: "" notifications: - delayMin: 0 emailEnabled: true intervalMin: 60 roles: - GROUP_OWNER smsEnabled: false typeName: GROUP threshold: operator: LESS_THAN threshold: "1.000000" units: HOURS - enabled: true eventTypeName: NO_PRIMARY metricThreshold: threshold: "" notifications: - delayMin: 15 emailEnabled: true intervalMin: 60 roles: - GROUP_OWNER smsEnabled: false typeName: GROUP threshold: {} - enabled: true eventTypeName: CLUSTER_MONGOS_IS_MISSING metricThreshold: threshold: "" notifications: - delayMin: 15 emailEnabled: true intervalMin: 60 roles: - GROUP_OWNER smsEnabled: false typeName: GROUP threshold: {} - enabled: true eventTypeName: OUTSIDE_METRIC_THRESHOLD metricThreshold: metricName: CONNECTIONS_PERCENT mode: AVERAGE operator: GREATER_THAN threshold: "80.000000" units: RAW notifications: - delayMin: 0 emailEnabled: true intervalMin: 60 roles: - GROUP_OWNER smsEnabled: false typeName: GROUP threshold: {} - enabled: true eventTypeName: OUTSIDE_METRIC_THRESHOLD metricThreshold: metricName: DISK_PARTITION_SPACE_USED_DATA mode: AVERAGE operator: GREATER_THAN threshold: "90.000000" units: RAW notifications: - delayMin: 0 emailEnabled: true intervalMin: 60 roles: - GROUP_OWNER smsEnabled: false typeName: GROUP threshold: {} - enabled: true eventTypeName: OUTSIDE_METRIC_THRESHOLD metricThreshold: metricName: QUERY_TARGETING_SCANNED_OBJECTS_PER_RETURNED mode: AVERAGE operator: GREATER_THAN threshold: "1000.000000" units: RAW notifications: - delayMin: 10 emailEnabled: true intervalMin: 60 roles: - GROUP_OWNER smsEnabled: false typeName: GROUP threshold: {} - enabled: true eventTypeName: CREDIT_CARD_ABOUT_TO_EXPIRE metricThreshold: threshold: "" notifications: - delayMin: 0 emailEnabled: true intervalMin: 1440 roles: - GROUP_OWNER smsEnabled: false typeName: GROUP threshold: {} - enabled: true eventTypeName: OUTSIDE_METRIC_THRESHOLD metricThreshold: metricName: NORMALIZED_SYSTEM_CPU_USER mode: AVERAGE operator: GREATER_THAN threshold: "95.000000" units: RAW notifications: - delayMin: 0 emailEnabled: true intervalMin: 60 roles: - GROUP_OWNER smsEnabled: false typeName: GROUP threshold: {} - enabled: true eventTypeName: HOST_HAS_INDEX_SUGGESTIONS metricThreshold: threshold: "" notifications: - delayMin: 10 emailEnabled: true intervalMin: 60 roles: - GROUP_OWNER smsEnabled: false typeName: GROUP threshold: {} - enabled: true eventTypeName: HOST_MONGOT_CRASHING_OOM metricThreshold: threshold: "" notifications: - delayMin: 0 emailEnabled: true intervalMin: 60 roles: - GROUP_OWNER smsEnabled: false typeName: GROUP threshold: {} - enabled: true eventTypeName: OUTSIDE_SERVERLESS_METRIC_THRESHOLD metricThreshold: metricName: SERVERLESS_CONNECTIONS_PERCENT mode: AVERAGE operator: GREATER_THAN threshold: "80.000000" units: RAW notifications: - delayMin: 0 emailEnabled: true intervalMin: 60 roles: - GROUP_OWNER smsEnabled: false typeName: GROUP threshold: {} - enabled: true eventTypeName: OUTSIDE_SERVERLESS_METRIC_THRESHOLD metricThreshold: metricName: SERVERLESS_DATA_SIZE_TOTAL mode: AVERAGE operator: GREATER_THAN threshold: "0.750000" units: TERABYTES notifications: - delayMin: 0 emailEnabled: true intervalMin: 60 roles: - GROUP_OWNER smsEnabled: false typeName: GROUP threshold: {} - enabled: true eventTypeName: OUTSIDE_SERVERLESS_METRIC_THRESHOLD metricThreshold: metricName: SERVERLESS_TOTAL_READ_UNITS mode: AVERAGE operator: GREATER_THAN threshold: "0.250000" units: MILLION_RPU notifications: - delayMin: 30 emailEnabled: true intervalMin: 720 roles: - GROUP_OWNER smsEnabled: false typeName: GROUP threshold: {} - enabled: true eventTypeName: OUTSIDE_SERVERLESS_METRIC_THRESHOLD metricThreshold: metricName: SERVERLESS_TOTAL_READ_UNITS mode: AVERAGE operator: GREATER_THAN threshold: "1.000000" units: MILLION_RPU notifications: - delayMin: 5 emailEnabled: true intervalMin: 120 roles: - GROUP_OWNER smsEnabled: false typeName: GROUP threshold: {} - enabled: true eventTypeName: HOST_NOT_ENOUGH_DISK_SPACE metricThreshold: threshold: "" notifications: - delayMin: 0 emailEnabled: true intervalMin: 60 roles: - GROUP_OWNER smsEnabled: false typeName: GROUP threshold: {} - enabled: true eventTypeName: OUTSIDE_METRIC_THRESHOLD metricThreshold: metricName: SEARCH_MAX_NUMBER_OF_LUCENE_DOCS mode: AVERAGE operator: GREATER_THAN threshold: "1.000000" units: BILLION notifications: - delayMin: 0 emailEnabled: true intervalMin: 60 roles: - GROUP_OWNER smsEnabled: false typeName: GROUP threshold: {} - enabled: true eventTypeName: JOINED_GROUP metricThreshold: threshold: "" notifications: - delayMin: 0 emailEnabled: true intervalMin: 60 smsEnabled: false typeName: GROUP threshold: {} # auditing: # auditAuthorizationSuccess: false # enabled: false connectionSecretRef: name: "mongodb-atlas-operator-api-key" # my changes # encryptionAtRest: # awsKms: # enabled: false # valid: false # azureKeyVault: # enabled: false # googleCloudKms: # enabled: false # maintenanceWindow: {} name: poc2 projectIpAccessList: - cidrBlock: 0.0.0.0/0 settings: isCollectDatabaseSpecificsStatisticsEnabled: true isDataExplorerEnabled: true isPerformanceAdvisorEnabled: true isRealtimePerformancePanelEnabled: true isSchemaAdvisorEnabled: true # status: # conditions: [] --- apiVersion: v1 data: orgId: "" privateApiKey: "" publicApiKey: "" kind: Secret metadata: # creationTimestamp: null labels: atlas.mongodb.com/type: credentials name: poc2-credentials namespace: atlas --- apiVersion: atlas.mongodb.com/v1 kind: AtlasDeployment metadata: # creationTimestamp: null name: cluster0 namespace: atlas annotations: # at least it will be good to have it commented in the output of `atlas kubernetes generate ...` output in order not to remove accidentally a project mongodb.com/atlas-resource-policy: "keep" spec: advancedDeploymentSpec: backupEnabled: true # biConnector: # enabled: false # readPreference: secondary clusterType: REPLICASET # encryptionAtRestProvider: NONE name: Cluster0 # paused: false # pitEnabled: false replicationSpecs: - numShards: 1 regionConfigs: - analyticsSpecs: instanceSize: M10 nodeCount: 0 autoScaling: compute: enabled: false scaleDownEnabled: false diskGB: enabled: true electableSpecs: instanceSize: M10 nodeCount: 3 priority: 7 providerName: GCP readOnlySpecs: instanceSize: M10 nodeCount: 0 regionName: CENTRAL_US zoneName: Zone 1 rootCertType: ISRGROOTX1 versionReleaseSystem: LTS backupRef: name: cluster0-backupschedule namespace: atlas processArgs: javascriptEnabled: true minimumEnabledTlsProtocol: TLS1_2 noTableScan: false projectRef: name: poc2 namespace: atlas # status: # conditions: [] --- apiVersion: atlas.mongodb.com/v1 kind: AtlasBackupSchedule metadata: # creationTimestamp: null name: cluster0-backupschedule namespace: atlas spec: export: exportBucketId: "" frequencyType: "MONTHLY" policy: name: cluster0-backuppolicy namespace: atlas referenceHourOfDay: 8 referenceMinuteOfHour: 26 restoreWindowDays: 7 # status: {} --- apiVersion: atlas.mongodb.com/v1 kind: AtlasBackupPolicy metadata: # creationTimestamp: null name: cluster0-backuppolicy namespace: atlas spec: items: - frequencyInterval: 6 frequencyType: hourly retentionUnit: days retentionValue: 2 - frequencyInterval: 1 frequencyType: daily retentionUnit: days retentionValue: 7 - frequencyInterval: 6 frequencyType: weekly retentionUnit: weeks retentionValue: 4 - frequencyInterval: 40 frequencyType: monthly retentionUnit: months retentionValue: 12 # status: {} --- ```
error of diskSizeGB `{"level":"INFO","time":"2023-01-24T07:47:05.189Z","msg":"Status update","atlasdeployment":"atlas/cluster0","lastCondition":{"type":"DeploymentReady","status":"False","lastTransitionTime":null,"reason":"InternalError","message":"json: cannot unmarshal number 0.5 into Go struct field AdvancedDeploymentSpec.diskSizeGB of type int"}}`
error of cidrBlock and ipAddress together `{"level":"INFO","time":"2023-01-24T08:26:29.867Z","msg":"Status update","atlasproject":"atlas/poc2","lastCondition":{"type":"IPAccessListReady","status":"False","lastTransitionTime":null,"reason":"ProjectIPAccessListInvalid","message":"only one of the 'awsSecurityGroup', 'cidrBlock' or 'ipAddress' is required be specified"}}`
error of backup schedule with unsupported value `The AtlasBackupSchedule "cluster0-backupschedule" is invalid: spec.export.frequencyType: Unsupported value: "": supported values: "MONTHLY"`
igor-karpukhin commented 1 year ago

Hi @zelig81. I think there is an issue with documentation. If you don't specify any clusters to export, AtlasDeployment resources will be generated for all existing clusters for this project. Could you please also provide a version of the Atlas CLI?

igor-karpukhin commented 1 year ago

Hi @zelig81.

zelig81 commented 1 year ago
atlas --version
atlascli version: 1.4.0
git version: homebrew-release
Go version: go1.19.3
   os: darwin
   arch: arm64
   compiler: gc
zelig81 commented 1 year ago

Hi @igor-karpukhin, thank you for the answer.

About output of atlas cli, I open an issue in the relevant repo

So generally your answer helped my needs regarding mongodb-atlas-kubernetes and this issue can be closed here.

igor-karpukhin commented 1 year ago

I'm reopening this one, as the DiskSizeGB issue is not fixed on the operator side yet

zelig81 commented 1 year ago

Ouch - sorry

zelig81 commented 1 year ago

@igor-karpukhin in that case - DiskSizeGB is not the only issue of operator side. I got it while generating k8s manifest via atlas cli from free tier DB. Additional issues are readonly fields (like bi reporting / tenant something and additional something that Ialready don't recall) that operator asks to fix

github-actions[bot] commented 1 year ago

This issue has gone 30 days without any activity and meets the project’s definition of 'stale'. This will be auto-closed if there is no new activity over the next 60 days. If the issue is still relevant and active, you can simply comment with a 'bump' to keep it open. Thanks for keeping our repository healthy!