From 546e9bdbec4ebdabdf39ea5e70c625fb5a53ca4b Mon Sep 17 00:00:00 2001 From: Sergey Melnikov Date: Tue, 18 Oct 2022 15:52:15 +0300 Subject: [PATCH] Deploy storage into new account and migrate to management API v2 (#2619) Deploy storage into new account Migrate safekeeper and pageserver initialisation to management api v2 --- .github/ansible/deploy.yaml | 6 +-- .github/ansible/neon-stress.hosts.yaml | 13 +++--- .github/ansible/production.hosts.yaml | 12 ++--- .github/ansible/scripts/init_pageserver.sh | 9 ++-- .github/ansible/scripts/init_safekeeper.sh | 10 ++--- .github/ansible/ssm_config | 3 ++ .github/ansible/staging.hosts.yaml | 22 ++++----- .github/ansible/staging.us-east-2.hosts.yaml | 32 +++++++++++++ .github/ansible/systemd/pageserver.service | 2 +- .github/ansible/systemd/safekeeper.service | 4 +- .github/workflows/build_and_test.yml | 47 ++++++++++++++++++-- 11 files changed, 116 insertions(+), 44 deletions(-) create mode 100644 .github/ansible/ssm_config create mode 100644 .github/ansible/staging.us-east-2.hosts.yaml diff --git a/.github/ansible/deploy.yaml b/.github/ansible/deploy.yaml index bfd3fd123d..4adc685684 100644 --- a/.github/ansible/deploy.yaml +++ b/.github/ansible/deploy.yaml @@ -1,7 +1,7 @@ - name: Upload Neon binaries hosts: storage gather_facts: False - remote_user: admin + remote_user: "{{ remote_user }}" tasks: @@ -36,7 +36,7 @@ - name: Deploy pageserver hosts: pageservers gather_facts: False - remote_user: admin + remote_user: "{{ remote_user }}" tasks: @@ -124,7 +124,7 @@ - name: Deploy safekeeper hosts: safekeepers gather_facts: False - remote_user: admin + remote_user: "{{ remote_user }}" tasks: diff --git a/.github/ansible/neon-stress.hosts.yaml b/.github/ansible/neon-stress.hosts.yaml index d4c77e7ada..8afc9a5be8 100644 --- a/.github/ansible/neon-stress.hosts.yaml +++ b/.github/ansible/neon-stress.hosts.yaml @@ -12,19 +12,20 @@ storage: bucket_name: "{{ bucket_name }}" bucket_region: "{{ bucket_region }}" prefix_in_bucket: "{{ inventory_hostname }}" - + hostname_suffix: ".local" + remote_user: admin children: pageservers: hosts: neon-stress-ps-1: - console_region_id: 1 + console_region_id: aws-eu-west-1 neon-stress-ps-2: - console_region_id: 1 + console_region_id: aws-eu-west-1 safekeepers: hosts: neon-stress-sk-1: - console_region_id: 1 + console_region_id: aws-eu-west-1 neon-stress-sk-2: - console_region_id: 1 + console_region_id: aws-eu-west-1 neon-stress-sk-3: - console_region_id: 1 + console_region_id: aws-eu-west-1 diff --git a/.github/ansible/production.hosts.yaml b/.github/ansible/production.hosts.yaml index c276ca3805..9f9b12d25d 100644 --- a/.github/ansible/production.hosts.yaml +++ b/.github/ansible/production.hosts.yaml @@ -12,20 +12,22 @@ storage: bucket_name: "{{ bucket_name }}" bucket_region: "{{ bucket_region }}" prefix_in_bucket: "{{ inventory_hostname }}" + hostname_suffix: ".local" + remote_user: admin children: pageservers: hosts: zenith-1-ps-2: - console_region_id: 1 + console_region_id: aws-us-west-2 zenith-1-ps-3: - console_region_id: 1 + console_region_id: aws-us-west-2 safekeepers: hosts: zenith-1-sk-1: - console_region_id: 1 + console_region_id: aws-us-west-2 zenith-1-sk-2: - console_region_id: 1 + console_region_id: aws-us-west-2 zenith-1-sk-3: - console_region_id: 1 + console_region_id: aws-us-west-2 diff --git a/.github/ansible/scripts/init_pageserver.sh b/.github/ansible/scripts/init_pageserver.sh index 1cbdd0db94..426925a837 100644 --- a/.github/ansible/scripts/init_pageserver.sh +++ b/.github/ansible/scripts/init_pageserver.sh @@ -12,18 +12,19 @@ cat <> $GITHUB_OUTPUT elif [[ "$GITHUB_REF_NAME" == "release" ]]; then - PRODUCTION='{"env_name": "production", "proxy_job": "neon-proxy", "proxy_config": "production.proxy", "kubeconfig_secret": "PRODUCTION_KUBECONFIG_DATA"}' + PRODUCTION='{"env_name": "production", "proxy_job": "neon-proxy", "proxy_config": "production.proxy", "kubeconfig_secret": "PRODUCTION_KUBECONFIG_DATA", "console_api_key_secret": "NEON_PRODUCTION_API_KEY"}' echo "include=[$PRODUCTION]" >> $GITHUB_OUTPUT else echo "GITHUB_REF_NAME (value '$GITHUB_REF_NAME') is not set to either 'main' or 'release'" @@ -735,7 +735,46 @@ jobs: ssh-add ssh-key rm -f ssh-key ssh-key-cert.pub ansible-galaxy collection install sivel.toiletwater - ansible-playbook deploy.yaml -i ${{ matrix.env_name }}.hosts.yaml + ansible-playbook deploy.yaml -i ${{ matrix.env_name }}.hosts.yaml -e CONSOLE_API_TOKEN=${{ secrets[matrix.console_api_key_secret] }} + rm -f neon_install.tar.gz .neon_current_version + + deploy-new: + runs-on: dev + container: 369495373322.dkr.ecr.eu-central-1.amazonaws.com/ansible:pinned + # We need both storage **and** compute images for deploy, because control plane picks the compute version based on the storage version. + # If it notices a fresh storage it may bump the compute version. And if compute image failed to build it may break things badly + needs: [ push-docker-hub, calculate-deploy-targets, tag, regress-tests ] + if: | + (github.ref_name == 'main') && + github.event_name != 'workflow_dispatch' + defaults: + run: + shell: bash + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_DEV }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_KEY_DEV }} + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + submodules: true + fetch-depth: 0 + + - name: Redeploy + run: | + export DOCKER_TAG=${{needs.tag.outputs.build-tag}} + cd "$(pwd)/.github/ansible" + + if [[ "$GITHUB_REF_NAME" == "main" ]]; then + ./get_binaries.sh + elif [[ "$GITHUB_REF_NAME" == "release" ]]; then + RELEASE=true ./get_binaries.sh + else + echo "GITHUB_REF_NAME (value '$GITHUB_REF_NAME') is not set to either 'main' or 'release'" + exit 1 + fi + + ansible-playbook deploy.yaml -i staging.us-east-2.hosts.yaml -e @ssm_config -e CONSOLE_API_TOKEN=${{secrets.NEON_STAGING_API_KEY}} rm -f neon_install.tar.gz .neon_current_version deploy-proxy: