From 61bec70dac98e074a58cc966f8d6852c97d7f9e6 Mon Sep 17 00:00:00 2001 From: David Hoese <david.hoese@ssec.wisc.edu> Date: Mon, 21 Dec 2020 10:01:02 -0600 Subject: [PATCH] Add initial changes to add postgres to production site --- .gitlab-ci.yml | 2 +- ...kubekorner_geosphere_prometheus_rules.yaml | 4 +- ci_gcp/gitlab-ci.yaml | 2 +- ci_geosphere-test/gitlab-ci.yaml | 2 +- ci_geosphere-test/values-mapcache.yaml | 6 +++ ci_geosphere/gitlab-ci.yaml | 51 ++++++++++++++----- ci_geosphere/postgres-pvc.yaml | 12 +++++ ci_geosphere/values-mapcache.yaml | 6 +++ ci_geosphere/values-postgis.yaml | 3 ++ ci_geosphere/values-tile-gen-g16-radc.yaml | 6 +++ ci_geosphere/values-tile-gen-g16-radf.yaml | 7 ++- ci_geosphere/values-tile-gen-g16-radm1.yaml | 6 +++ ci_geosphere/values-tile-gen-g16-radm2.yaml | 6 +++ ci_tests/run_basic_postgres_test.sh | 2 +- 14 files changed, 96 insertions(+), 19 deletions(-) create mode 100644 ci_geosphere/postgres-pvc.yaml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index eba71e6..35085b0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,7 +3,7 @@ stages: - build prereqs - test - create storage - - deploy rabbit + - deploy infrastructure - deploy GRB - deploy G2G - deploy tile gen diff --git a/admin/kubekorner_geosphere_prometheus_rules.yaml b/admin/kubekorner_geosphere_prometheus_rules.yaml index abafad6..225ade0 100644 --- a/admin/kubekorner_geosphere_prometheus_rules.yaml +++ b/admin/kubekorner_geosphere_prometheus_rules.yaml @@ -220,14 +220,14 @@ spec: summary: "Host unusual disk read rate (instance {{ $labels.instance }})" description: "Disk is probably reading too much data (> 150 MB/s)\n VALUE = {{ $value }}\n LABELS: {{ $labels }}" - alert: HostUnusualDiskWriteRate - expr: sum by (instance) (irate(node_disk_written_bytes_total[5m])) / 1024 / 1024 > 150 + expr: sum by (instance) (irate(node_disk_written_bytes_total[5m])) / 1024 / 1024 > 300 for: 5m labels: severity: warning ruleGroup: geosphere-node annotations: summary: "Host unusual disk write rate (instance {{ $labels.instance }})" - description: "Disk is probably writing too much data (> 150 MB/s)\n VALUE = {{ $value }}\n LABELS: {{ $labels }}" + description: "Disk is probably writing too much data (> 300 MB/s)\n VALUE = {{ $value }}\n LABELS: {{ $labels }}" - alert: HostOutOfDiskSpace expr: (node_filesystem_avail_bytes{mountpoint="/"} * 100) / node_filesystem_size_bytes{mountpoint="/"} < 10 for: 5m diff --git a/ci_gcp/gitlab-ci.yaml b/ci_gcp/gitlab-ci.yaml index 85ab31f..c8e79c5 100644 --- a/ci_gcp/gitlab-ci.yaml +++ b/ci_gcp/gitlab-ci.yaml @@ -84,7 +84,7 @@ gcp deploy rabbit: name: geosphere url: http://geosphere.ssec.wisc.edu extends: .helm_based_job - stage: deploy rabbit + stage: deploy infrastructure script: - ./helpers/deploy_rabbitmq.sh ci_geosphere # this job doesn't actually need any artifacts from previous jobs diff --git a/ci_geosphere-test/gitlab-ci.yaml b/ci_geosphere-test/gitlab-ci.yaml index 4e32c61..872a41c 100644 --- a/ci_geosphere-test/gitlab-ci.yaml +++ b/ci_geosphere-test/gitlab-ci.yaml @@ -37,7 +37,7 @@ gstest deploy rabbit: name: geosphere-test url: http://geosphere-test.ssec.wisc.edu extends: .helm_based_job - stage: deploy rabbit + stage: deploy infrastructure script: - ./helpers/deploy_rabbitmq.sh ci_geosphere-test # this job doesn't actually need any artifacts from previous jobs diff --git a/ci_geosphere-test/values-mapcache.yaml b/ci_geosphere-test/values-mapcache.yaml index b638940..15a3e0d 100644 --- a/ci_geosphere-test/values-mapcache.yaml +++ b/ci_geosphere-test/values-mapcache.yaml @@ -13,6 +13,12 @@ cache: cleanup: # every 6 hours schedule: "0 */6 * * *" +database: + postgresHost: "geosphere-postgis-postgresql" + postgresPort: 5432 + postgresDatabaseName: "postgres" + postgresUser: "postgres" + postgresPasswordSecret: "geosphere-postgis-postgresql-production" seed: images: false overlays: false diff --git a/ci_geosphere/gitlab-ci.yaml b/ci_geosphere/gitlab-ci.yaml index c04a9e3..cf3676d 100644 --- a/ci_geosphere/gitlab-ci.yaml +++ b/ci_geosphere/gitlab-ci.yaml @@ -12,10 +12,20 @@ gs create geotiff storage: stage: create storage script: - ns=$(./helpers/get_namespace.sh) - # copy secret kubeconfig to the mounted (pwd) directory - - cp $kubekorner_k3s_config . - - kubeconfig=$(basename $kubekorner_k3s_config) - - ./helpers/create_pvc.sh "$ns" "ci_geosphere/geotiff-pvc.yaml" "cspp-geo-geo2grid" "$kubeconfig" + - ./helpers/create_pvc.sh "$ns" "ci_geosphere/geotiff-pvc.yaml" "cspp-geo-geo2grid" + # this job doesn't actually need any artifacts from previous jobs + dependencies: [] + rules: + - if: $CI_COMMIT_TAG !~ /^r[0-9]+_[0-9]+/ + when: never + - if: $CREATE_STORAGE + +gs create postgres storage: + extends: .helm_based_job + stage: create storage + script: + - ns=$(./helpers/get_namespace.sh) + - ./helpers/create_pvc.sh "$ns" "ci_geosphere/postgres-pvc.yaml" "geosphere-postgis" # this job doesn't actually need any artifacts from previous jobs dependencies: [] rules: @@ -28,10 +38,7 @@ gs create shapefile storage: stage: create storage script: - ns=$(./helpers/get_namespace.sh) - # copy secret kubeconfig to the mounted (pwd) directory - - cp $kubekorner_k3s_config . - - kubeconfig=$(basename $kubekorner_k3s_config) - - ./helpers/create_pvc.sh "$ns" "ci_geosphere/shapefiles-pvc.yaml" "geosphere-tile-gen-shapefiles" "$kubeconfig" + - ./helpers/create_pvc.sh "$ns" "ci_geosphere/shapefiles-pvc.yaml" "geosphere-tile-gen-shapefiles" # this job doesn't actually need any artifacts from previous jobs dependencies: [] rules: @@ -47,13 +54,11 @@ gs deploy rabbit: name: geosphere url: http://geosphere.ssec.wisc.edu extends: .helm_based_job - stage: deploy rabbit + stage: deploy infrastructure script: - ./helpers/deploy_rabbitmq.sh ci_geosphere - - cp ${kubekorner_k3s_config} . - - kubeconfig=$(basename ${kubekorner_k3s_config}) - |- - kubectl get secret --kubeconfig "${kubeconfig}" geosphere-rabbit-rabbitmq --namespace=geosphere -oyaml | grep -v '^\s*namespace:\s' | grep -v "[Hh]elm" | grep -v "[tT]ime" | grep -v "selfLink" | grep -v "uid" | grep -v "resourceVersion" | sed 's/ name: .*/ name: geosphere-rabbit-rabbitmq-production/' | kubectl apply --kubeconfig "${kubeconfig}" --namespace=geosphere-test -f - + kubectl get secret geosphere-rabbit-rabbitmq --namespace=geosphere -oyaml | grep -v '^\s*namespace:\s' | grep -v "[Hh]elm" | grep -v "[tT]ime" | grep -v "selfLink" | grep -v "uid" | grep -v "resourceVersion" | sed 's/ name: .*/ name: geosphere-rabbit-rabbitmq-production/' | kubectl apply --namespace=geosphere-test -f - # this job doesn't actually need any artifacts from previous jobs dependencies: [] rules: @@ -66,6 +71,28 @@ gs deploy rabbit: - ci_geosphere/values-geosphere-rabbit.yaml - if: $DEPLOY_RABBIT +gs deploy postgres: + environment: + name: geosphere + url: http://geosphere.ssec.wisc.edu + extends: .helm_based_job + stage: deploy infrastructure + script: + - ./helpers/deploy_postgis.sh ci_geosphere + - |- + kubectl get secret geosphere-postgis-postgresql --namespace=geosphere -oyaml | grep -v '^\s*namespace:\s' | grep -v "[Hh]elm" | grep -v "[tT]ime" | grep -v "selfLink" | grep -v "uid" | grep -v "resourceVersion" | sed 's/ name: .*/ name: geosphere-postgis-postgresql-production/' | kubectl apply --namespace=geosphere-test -f - + # this job doesn't actually need any artifacts from previous jobs + dependencies: [] + rules: + - if: $CI_COMMIT_TAG !~ /^r[0-9]+_[0-9]+/ + when: never + # no need to build if another project triggered us + - if: $CI_PIPELINE_SOURCE == "pipeline" + when: never + - changes: + - ci_geosphere/values-postgis.yaml + - if: $DEPLOY_POSTGIS + gs deploy g16 grb: # environment: # name: geosphere diff --git a/ci_geosphere/postgres-pvc.yaml b/ci_geosphere/postgres-pvc.yaml new file mode 100644 index 0000000..bdf13e8 --- /dev/null +++ b/ci_geosphere/postgres-pvc.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: geosphere-postgis + labels: {} +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 8Gi + storageClassName: "longhorn" diff --git a/ci_geosphere/values-mapcache.yaml b/ci_geosphere/values-mapcache.yaml index ca8afa3..82827b0 100644 --- a/ci_geosphere/values-mapcache.yaml +++ b/ci_geosphere/values-mapcache.yaml @@ -14,6 +14,12 @@ cache: # every 6 hours schedule: "0 */6 * * *" age: "+2" +database: + postgresHost: "geosphere-postgis-postgresql" + postgresPort: 5432 + postgresDatabaseName: "postgres" + postgresUser: "postgres" + postgresPasswordSecret: "geosphere-postgis-postgresql" seed: images: true overlays: true diff --git a/ci_geosphere/values-postgis.yaml b/ci_geosphere/values-postgis.yaml index 688dd52..73cd7cd 100644 --- a/ci_geosphere/values-postgis.yaml +++ b/ci_geosphere/values-postgis.yaml @@ -1,3 +1,6 @@ +persistence: + enabled: true + existingClaim: "geosphere-postgis" metrics: enabled: true serviceMonitor: diff --git a/ci_geosphere/values-tile-gen-g16-radc.yaml b/ci_geosphere/values-tile-gen-g16-radc.yaml index f622126..0c0ef0c 100644 --- a/ci_geosphere/values-tile-gen-g16-radc.yaml +++ b/ci_geosphere/values-tile-gen-g16-radc.yaml @@ -15,3 +15,9 @@ destination: enabled: true storageClass: "longhorn" existingClaim: "geosphere-tile-gen-shapefiles" +database: + postgresHost: "geosphere-postgis-postgresql" + postgresPort: 5432 + postgresDatabaseName: "postgres" + postgresUser: "postgres" + postgresPasswordSecret: "geosphere-postgis-postgresql" diff --git a/ci_geosphere/values-tile-gen-g16-radf.yaml b/ci_geosphere/values-tile-gen-g16-radf.yaml index 7438d4c..81ca710 100644 --- a/ci_geosphere/values-tile-gen-g16-radf.yaml +++ b/ci_geosphere/values-tile-gen-g16-radf.yaml @@ -15,4 +15,9 @@ destination: enabled: true storageClass: "longhorn" existingClaim: "geosphere-tile-gen-shapefiles" - +database: + postgresHost: "geosphere-postgis-postgresql" + postgresPort: 5432 + postgresDatabaseName: "postgres" + postgresUser: "postgres" + postgresPasswordSecret: "geosphere-postgis-postgresql" diff --git a/ci_geosphere/values-tile-gen-g16-radm1.yaml b/ci_geosphere/values-tile-gen-g16-radm1.yaml index 98c4408..0235b39 100644 --- a/ci_geosphere/values-tile-gen-g16-radm1.yaml +++ b/ci_geosphere/values-tile-gen-g16-radm1.yaml @@ -15,3 +15,9 @@ destination: enabled: true storageClass: "longhorn" existingClaim: "geosphere-tile-gen-shapefiles" +database: + postgresHost: "geosphere-postgis-postgresql" + postgresPort: 5432 + postgresDatabaseName: "postgres" + postgresUser: "postgres" + postgresPasswordSecret: "geosphere-postgis-postgresql" diff --git a/ci_geosphere/values-tile-gen-g16-radm2.yaml b/ci_geosphere/values-tile-gen-g16-radm2.yaml index b9c8c46..81f8e20 100644 --- a/ci_geosphere/values-tile-gen-g16-radm2.yaml +++ b/ci_geosphere/values-tile-gen-g16-radm2.yaml @@ -15,3 +15,9 @@ destination: enabled: true storageClass: "longhorn" existingClaim: "geosphere-tile-gen-shapefiles" +database: + postgresHost: "geosphere-postgis-postgresql" + postgresPort: 5432 + postgresDatabaseName: "postgres" + postgresUser: "postgres" + postgresPasswordSecret: "geosphere-postgis-postgresql" diff --git a/ci_tests/run_basic_postgres_test.sh b/ci_tests/run_basic_postgres_test.sh index c07b54b..1c1bdd3 100755 --- a/ci_tests/run_basic_postgres_test.sh +++ b/ci_tests/run_basic_postgres_test.sh @@ -20,7 +20,7 @@ install_basic_postgres_charts "ci_tests/basic_postgres" # give kubernetes a bit to create the resources debug "Waiting for Kubernetes to deploy and schedule components..." -sleep 60 +sleep 90 debug "Done waiting" debug "Getting GRB pod name" -- GitLab