Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Document] CI/CD will be change using Kubernetes #116

Closed
ghkdqhrbals opened this issue Oct 3, 2023 · 0 comments
Closed

[Document] CI/CD will be change using Kubernetes #116

ghkdqhrbals opened this issue Oct 3, 2023 · 0 comments
Assignees
Labels
status: question Further information is requested theme: documentation Improvements or additions to documentation

Comments

@ghkdqhrbals
Copy link
Owner

ghkdqhrbals commented Oct 3, 2023

Original CI/CD flows

with AWS-ECR+EC2, docker-compose, git actions, etc.

1

2

  1. The deployment workflow gets the latest tag version
  2. Remove v prefix and separate into major, minor and patch
  3. Update the version matching your PR title and push it to github

So if v5.0.1 is the latest tag and the PR title contains **[patch]**, the operation returns an env with v5.0.2 and pushes it to github. If v5.0.2 already exists, the operation will append the commit hash to the end of the new tag, so it may be equal to v5.0.2-abf2154

  1. Run ./gradlew build --build-cache --parallel -Pversion=${new version} which build the .jar files and appending ${new version} at the end of .jar file name. Also creating Dockerfile building with .jar files

If v5.0.2 is new version tag, gradle read the new version and building **_v5.0.2.jar. After building .jar, gradle scripts create Dockerfile that copy matching .jar file (e.g. COPY /build/libs/shop-user-service-v5.0.2.jar /null/app.jar)

  1. Building all Dockerfile with composing, push all created images to ECR

ECR is quite expansive if you want to create multiple repositories. So I create only one repository, push all images tagged with ${service_name}_${new_version} to identifying them.

  1. Access to EC2 and pulling all images from ECR

When pulling all images, we should get all image name, filtering postfix name. For example, ECR has A-service_v5.0.2, A-service_v5.0.1, B-service_v5.0.2, C-service_v5.0.2. Separate each names with _ delimiter, find index[1] is exactly same as v5.0.2 , using for loop create new tags

  1. Run docker-compose-prod.yaml in background

Since I run 12 docker containers in t2.micro instance, it could be overloaded. I'm considering upgrade EC2 or horizontal scaling or EKS for running multiple servers.

Originally posted by @ghkdqhrbals in #78 (comment)

To explain simple, process will be like this.

  • Push new tag -> Build projects -> Build images -> Push to ECR -> Pull images from ECR in EC2 -> Run containers

Changed CI/CD plan

Same process

Push new tag -> Build projects -> Build images -> Push to ECR.

So ECR will has various tags like A-service_v5.0.1, B-service_v5.0.1, A-service_v5.0.2 etc.

Different process

Applying multiple service.yaml, deploy.yaml, persistance volume, etc. files to EC2 kubernetes master node.

But here comes with the question.

Since we are using kubernetes, we need to specify the exact name and tag of image that we pull from ECR. How can we write the image name and tag inside every deploy.yaml files? Kubernetes API doesn't support regular expression. What we want is that for example, find images with v5.0.1 postfix, pull that images, change to latest tag, write down like image: B-service:latest. The process becomes harder because of image versioning. Since we are using ECR, they automatically versioning our images with imageDigest so there's no need for custom versioning. But not human-readable. It's just hash values. For human-friendly, I set tag with custom versioning.

Anyway how can we write each of deploy.yaml files? Well... Let's find out!

@ghkdqhrbals ghkdqhrbals added the theme: documentation Improvements or additions to documentation label Oct 3, 2023
@ghkdqhrbals ghkdqhrbals self-assigned this Oct 3, 2023
@ghkdqhrbals ghkdqhrbals pinned this issue Oct 3, 2023
@ghkdqhrbals ghkdqhrbals added the status: question Further information is requested label Oct 3, 2023
@ghkdqhrbals ghkdqhrbals moved this from Remind to In Progress in Project scheduler for chat projects 👍 Oct 3, 2023
@ghkdqhrbals ghkdqhrbals moved this from In Progress to Remind in Project scheduler for chat projects 👍 Oct 3, 2023
@ghkdqhrbals ghkdqhrbals unpinned this issue Oct 30, 2023
@ghkdqhrbals ghkdqhrbals pinned this issue Jan 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: question Further information is requested theme: documentation Improvements or additions to documentation
Projects
Development

No branches or pull requests

1 participant