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

Startup dependency control #23

Open
wangeguo opened this issue Jul 8, 2023 · 0 comments
Open

Startup dependency control #23

wangeguo opened this issue Jul 8, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@wangeguo
Copy link
Member

wangeguo commented Jul 8, 2023

When multiple microservices or components are deployed together, it is desirable to control the startup order and dependencies based on their dependencies. One approach is to generate an initContainer for the specified workload, which waits for all pods with matching labels to reach the "Ready" state and all jobs with matching labels to reach the "Succeeded" state.

To achieve this:

  1. Init Containers: Create one or more initContainers for the designated workload. Init Containers are auxiliary containers that run before the main container starts. They can be used to perform pre-start tasks or wait for other services to become ready.

    In your main Pod configuration, define one or more initContainers, each responsible for executing specific tasks, such as waiting for specific services to be ready. You can assign one or more labels to the initContainers to match other pods or jobs.

    Within the initContainer, you can use the Kubernetes API or appropriate methods to loop and check the status of pods or jobs with matching labels. Once all the matching pods are in the "Ready" state, you can allow the initContainer to complete its task and enable the main container to start.

  2. Jobs and completion criteria: If you want to control the startup order and dependencies by waiting for successful job completion, you can create a Job object and use its completion criteria.

    Create a Job object and assign one or more labels to match other pods or jobs. Then, in the initContainer of the main container, use the Kubernetes API or appropriate methods to loop and check the status of jobs with matching labels until all the jobs reach the "Succeeded" state.

    Within the initContainer, you can use the Kubernetes API or other methods to loop and check the status of jobs with matching labels. Once all the matching jobs are in the "Succeeded" state, you can allow the initContainer to complete its task and enable the main container to start.

By combining Init Containers and Jobs with completion criteria, you can control the startup order and dependencies between multiple microservices or components. Please note that the specific implementation details may vary depending on the orchestration tool (such as Kubernetes), the orchestration files (such as Deployment or StatefulSet), and the programming language and libraries you choose.

@wangeguo wangeguo added the enhancement New feature or request label Jul 8, 2023
@wangeguo wangeguo moved this to Todo in Amphitheatre Jul 8, 2023
@wangeguo wangeguo moved this from 📋 Todo to 🏗 In progress in Amphitheatre Jan 19, 2024
@wangeguo wangeguo moved this from 🏗 In progress to 📋 Todo in Amphitheatre Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: 📋 Todo
Development

No branches or pull requests

1 participant