artifactory_new: will be used to refer to the newly deployed environment
artifactory_prod: will be used to refer to the current production environment
-
Create RDS snapshot of artifactory_prod
-
Check the CFN files and make sure the following values are set in config files and in CFN files
-
prod-db.json, paste snapshot ARN made in step 1 This snapshot is used to create the new database
"DBSnapshotIdentifier": "arn:aws:rds:eu-west- 1:012345678912:snapshot:awsbackup:XXXXXXXXXXXXXXXXXXXXXXXXX",
-
prod-ecs.json, we want to deploy a parallel environment with the same image as in artifactory_prod. And the port has to be 8081 and this will change when we upgrade to artifactory 7.37
"ContainerFrontendPort": "8081" "ImageUrl": "docker.bintray.io/jfrog/artifactory-pro:6.18.1"
-
artifactory-ecs.yaml, comment out the R53 records these will be created after all resources have been deployed Artifactory_prod will remain available during the upgrade
# ArtiDNSRecord: # Type: "AWS::Route53::RecordSet" # Properties: # AliasTarget: # HostedZoneId: !Sub "{{resolve:ssm:/${Application}/${Stage}/alb/hosted-zone-id/cf}}" # DNSName: !Sub "{{resolve:ssm:/${Application}/${Stage}/alb/dns/cf}}" # Comment: 'Artifactory FIRSTDOMAIN' # HostedZoneId: !Ref ArtiDNSHostedZoneId # Name: !Join [ '', [ !FindInMap ["DnsMapping", !Ref Stage, "value"], !Ref ArtiURL ] ] # Type: 'A' # ArtiDNSRecordSECONDDOMAIN: # Type: "AWS::Route53::RecordSet" # Properties: # AliasTarget: # HostedZoneId: !Sub "{{resolve:ssm:/${Application}/${Stage}/alb/hosted-zone-id/cf}}" # DNSName: !Sub "{{resolve:ssm:/${Application}/${Stage}/alb/dns/cf}}" # Comment: 'Artifactory SECONDDOMAIN' # HostedZoneId: !Ref ArtiDNSHostedZoneIdSECONDDOMAIN # Name: !Join [ '', [ !FindInMap ["DnsMapping", !Ref Stage, "value"], !Ref ArtiURLSECONDDOMAIN ] ] # Type: 'A'
-
Comment out in resource ECSTaskDefinition, this is needed when we upgrade to artifactory 7.37
# Environment: # - Name: 'ENABLE_MIGRATION' # Value: 'y'
-
- Sync filestore objects to S3 with AWS Datasync (ClickOps in console) This sync can take hours depending on how much data has to be transfered, this can run in the background. Continue with the other steps
- Create location
- In S3 Create a folder filestore
- S3 bucket that was created by the pipeline (Destination)
- Create a new task
- For source select the existing EFS that contains all the artifacts
- For destination select the S3 location we created in step A
- Create location
- Deploy the pipeline
- make deploy-pipeline ENVIRONMENT=prod
- Once deployed update the ECS service through console, set desired tasks to 0 (This will allow us to update the artifactory config files)
EFS Copy artifactory_prod config to artifactory_new
- Create a temporary EC2 instance and mount the artifactory_prod EFS and the artifactory_new EFS
- mkdir /mnt/prod
- sudo mount -t nfs4 -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvp ort fs-XXXXXXX.efs.eu-west-1.amazonaws.com:/ /mnt/prod
- mkdir /mnt/new
- sudo mount -t nfs4 -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvp ort fs-XXXXXXX.efs.eu-west-1.amazonaws.com:/ /mnt/new
- Create ZIP of artifactory_prod config files
- cd /mnt/prod
- zip -r myarchive.zip . -x data/filestore/***
- Unzip in artifactory_new EFS
- cd /mnt/prod
- unzip myarchive.zip -d /mnt/new/
- Change owner of files to artifactory user (-r recursively)
- chown -r 1030:1030 /mnt/new/
- cd /mnt/new
- Set database endpoint
- nano etc/db.properties Edit line 3: YOUR-ENDPOINT.eu-west-1.rds.amazonaws.com 2. type=postgresql
- driver=org.postgresql.Driver
- url=jdbc:postgresql://YOUR-ENDPOINT.eu-west-
- rds.amazonaws.com:5432/artifactory
- username=artifactory password=XXXXXXXXXXXXXXXXXXXXXX
- When you need to change the "urlBase".
Artifactory will redirect you to this url when you hit the domain apex (artifactory.DOMAIN1.cloud → dev.artifactory.DOMAIN1.cloud/artifactory)
Currently only for DEV environment!!!
- nano etc/artifactory.config.bootstrap.xml https://dev.artifactory.DOMAIN1.cloud/artifactory</url Base>
- Copy the file and rename it this way Artifactory will register it as a change
- cp etc/artifactory.config.bootstrap.xml etc/artifactory.config.import.xml
- Update license file Currently only for DEV environment!!! nano etc/artifactory.lic
- Once the Datasync is complete we can update the ECS service through console, set desired tasks to 1
- Update the artifactory_new ECS service through console, set desired tasks to 0
- Change parameter prod-ecs.json
- Change the image and the port
"ImageUrl": "docker.bintray.io/jfrog/artifactory-pro:7.37.13", "ContainerFrontendPort": "8082"
- artifactory-ecs.yaml Uncomment the following parameter, this parameter will trigger update in Artifactory
Environment: - Name: 'ENABLE_MIGRATION' Value: 'y'
- Push changes
- Temporarily update the target group health check settings.
We do this because the upgrade process takes a while until it returns a 200, if we don't do this the health check will fail and stop the container.
- Increase all values to max and afterwards revert to default settings
- Update the artifactory_new ECS service through console, set desired tasks to 1
- Update the artifactory_new ECS service through console, set desired tasks to 0
- Update binarystore.xml UPDATE BUCKET NAME
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <config version="2"> <chain template="s3-storage-v3-direct"/> <provider type="s3-storage-v3" id="s3-storage-v3"> <bucketName>BUCKET-NAME</bucketName> <path>filestore</path> <endpoint>s3.amazonaws.com</endpoint> <useInstanceCredentials>true</useInstanceCredentials> <maxConnections>300</maxConnections> <region>eu-west-1</region> </provider> </config>
- Update the artifactory_new ECS service through console, set desired tasks to 1
- Scanning all files on S3 will take a while depending on how many artifacts are available (Batches of 15000)
-
Hosted zone: DNSZONE1.cloud Change current DNS record to old.artifactory.DOMAIN.COM
-
Hosted zone: DNSZONE2.cloud Change current DNS record to old.artifactory.DOMAIN.COM
-
Change artifactory-ecs.yaml
Uncomment the R53 resources
ArtiDNSRecord: Type: "AWS::Route53::RecordSet" Properties: AliasTarget: HostedZoneId: !Sub "{{resolve:ssm:/${Application}/${Stage}/alb/hosted-zone-id/cf}}" DNSName: !Sub "{{resolve:ssm:/${Application}/${Stage}/alb/dns/cf}}" Comment: 'Artifactory FIRSTDOMAIN' HostedZoneId: !Ref ArtiDNSHostedZoneId Name: !Join [ '', [ !FindInMap ["DnsMapping", !Ref Stage, "value"], !Ref ArtiURL ] ] Type: 'A' ArtiDNSRecordSECONDDOMAIN: Type: "AWS::Route53::RecordSet" Properties: AliasTarget: HostedZoneId: !Sub "{{resolve:ssm:/${Application}/${Stage}/alb/hosted-zone-id/cf}}" DNSName: !Sub "{{resolve:ssm:/${Application}/${Stage}/alb/dns/cf}}" Comment: 'Artifactory SECONDDOMAIN' HostedZoneId: !Ref ArtiDNSHostedZoneIdSECONDDOMAIN Name: !Join [ '', [ !FindInMap ["DnsMapping", !Ref Stage, "value"], !Ref ArtiURLSECONDDOMAIN ] ] Type: 'A'
-
artifactory-ecs.yaml comment the following parameter
#Environment: #- Name: 'ENABLE_MIGRATION' # Value: 'y
-
Push changes
-
(DataSync last changes again)
-
Done