Skip to content

Commit

Permalink
improve setup and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuriy Bezsonov committed Oct 26, 2023
1 parent 8cf59d0 commit a37a99d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,14 @@ resource "aws_iam_user_policy_attachment" "ci_access" {
policy_arn = aws_iam_policy.ci_access.arn
}

resource "random_string" "ecr_ui_suffix" {
length = 6
upper = false
special = false
}

resource "aws_ecr_repository" "ecr_ui" {
name = "retail-store-sample-ui"
name = "retail-store-sample-ui-${random_string.ecr_ui_suffix.result}"
image_tag_mutability = "MUTABLE"
force_delete = true

Expand Down Expand Up @@ -341,7 +347,7 @@ resource "aws_codebuild_project" "codebuild_amd64" {

environment_variable {
name = "ECR_URI"
value = "${data.aws_caller_identity.current.account_id}.dkr.ecr.${data.aws_region.current.name}.amazonaws.com/retail-store-sample-ui"
value = aws_ecr_repository.ecr_ui.repository_url
}

environment_variable {
Expand Down Expand Up @@ -379,7 +385,7 @@ resource "aws_codebuild_project" "codebuild_arm64" {

environment_variable {
name = "ECR_URI"
value = "${data.aws_caller_identity.current.account_id}.dkr.ecr.${data.aws_region.current.name}.amazonaws.com/retail-store-sample-ui"
value = aws_ecr_repository.ecr_ui.repository_url
}

environment_variable {
Expand Down Expand Up @@ -417,7 +423,7 @@ resource "aws_codebuild_project" "codebuild_manifest" {

environment_variable {
name = "ECR_URI"
value = "${data.aws_caller_identity.current.account_id}.dkr.ecr.${data.aws_region.current.name}.amazonaws.com/retail-store-sample-ui"
value = aws_ecr_repository.ecr_ui.repository_url
}
}

Expand Down
Binary file modified website/docs/automation/gitops/flux/assets/ecr.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 8 additions & 4 deletions website/docs/automation/gitops/flux/ci.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ You can navigate to `CodePipeline` in AWS Console and explore `eks-workshop-reta

As a result of a CodePipeline run with CodeBuild you will have a new image in ECR

```bash
$ echo IMAGE_URI_UI=$IMAGE_URI_UI
```

The suffix `z7llv2` in the name `retail-store-sample-ui-z7llv2` is random and will be different in your case.

![ci-start](assets/ecr.png)

While we are waiting for pipeline to create new images (5-10 minutes), let's [automate image updates to Git](https://fluxcd.io/flux/guides/image-update/) using Flux Image Automation Controller.
Expand Down Expand Up @@ -162,7 +168,7 @@ ui alb * k8s-ui-ui-1268651632.us-west-2.elb.amazonaws.com 80

We wait 2-5 minutes until Application Load Balancer will be provisioned and check the UI page using url of the ingress.

```bash test=false
```bash timeout=300
$ export UI_URL=$(kubectl get ingress -n ui ui -o jsonpath="{.status.loadBalancer.ingress[*].hostname}{'\n'}")
$ wait-for-lb $UI_URL
```
Expand Down Expand Up @@ -193,10 +199,8 @@ $ git -C ~/environment/retail-store-sample-codecommit push

Wait until CodePipeline will build the new image and Flux will deploy it.

```bash test=false
```bash timeout=900
$ kubectl -n ui describe deployment ui | grep Image
$ # aws codepipeline start-pipeline-execution --name eks-workshop-retail-store-sample
$ # sleep 10
$ while [[ "$(aws codepipeline get-pipeline-state --name eks-workshop-retail-store-sample --query 'stageStates[1].actionStates[0].latestExecution.status' --output text)" != "InProgress" ]]; do echo "Waiting for pipeline to start ..."; sleep 10; done && echo "Pipeline started."
$ while [[ "$(aws codepipeline get-pipeline-state --name eks-workshop-retail-store-sample --query 'stageStates[1].actionStates[2].latestExecution.status' --output text)" != "Succeeded" ]]; do echo "Waiting for pipeline to reach 'Succeeded' state ..."; sleep 10; done && echo "Pipeline has reached the 'Succeeded' state."

Expand Down

0 comments on commit a37a99d

Please sign in to comment.