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

airbyte-workers: add support for kubernetes pod annotations #10753

Merged
merged 19 commits into from
Apr 5, 2022

Conversation

tbcdns
Copy link
Contributor

@tbcdns tbcdns commented Mar 1, 2022

What

This PR adds the possibility to define pod annotations to the pods created by the workers.
Pod annotations can be required in different situations, such as configuring which IP pool to use when using some network plugins.

The original PR was here: #9874 we decided to split it into 3 different PRs.

How

Pod node selectors are already available (using the JOB_KUBE_NODE_SELECTORS environment variable), pod annotations can be configured in the same way, using the JOB_KUBE_ANNOTATIONS environment variable)

🚨 User Impact 🚨

No user impact

@github-actions github-actions bot added area/documentation Improvements or additions to documentation area/platform issues related to the platform area/worker Related to worker kubernetes labels Mar 1, 2022
Copy link
Member

@marcosmarxm marcosmarxm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! Made some feedback

* @param input string
* @return map containing kv pairs
*/
public Optional<Map<String, String>> splitKVPairsFromEnvString(String input) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tbcdns can you add tests to this function?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, I added a unit test for this function in d95394e

6. `JOB_KUBE_BUSYBOX_IMAGE` - Define the Job pod busybox image.
7. `JOB_KUBE_CURL_IMAGE` - Define the Job pod curl image pull.
8. `JOB_KUBE_NAMESPACE` - Define the Kubernetes namespace Job pods are created in.
3. `JOB_KUBE_ANNOTATIONS` - Define one or more Job pod annotations. Each kv-pair is separated by a `,`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add an example of kv-pair? For me it's not clear the user should add key1=value1 instead of key1:value1.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, done

@@ -288,6 +288,26 @@
*/
Optional<Map<String, String>> getDiscoverJobKubeNodeSelectors();

/**
* Define one or more Job pod annotations. Each kv-pair is separated by a `,`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you include in the comment that this annotation is used as a fallback in case other annotations aren't set, as well as, used as the sync job pod annotation.

7. `JOB_KUBE_CURL_IMAGE` - Define the Job pod curl image pull.
8. `JOB_KUBE_NAMESPACE` - Define the Kubernetes namespace Job pods are created in.
2. `JOB_KUBE_NODE_SELECTORS` - Define one or more Job pod node selectors. Each k=v pair is separated by a `,`. For example: `key1=value1,key2=value2`
3. `JOB_KUBE_ANNOTATIONS` - Define one or more Job pod annotations. Each k=v pair is separated by a `,`. For example: `key1=value1,key2=value2`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we update the comment here to match my earlier comment on reflecting that this the default annotation fallback and the annotation configuration for sync jobs.

8. `JOB_KUBE_NAMESPACE` - Define the Kubernetes namespace Job pods are created in.
2. `JOB_KUBE_NODE_SELECTORS` - Define one or more Job pod node selectors. Each k=v pair is separated by a `,`. For example: `key1=value1,key2=value2`
3. `JOB_KUBE_ANNOTATIONS` - Define one or more Job pod annotations. Each k=v pair is separated by a `,`. For example: `key1=value1,key2=value2`
4. `JOB_KUBE_MAIN_CONTAINER_IMAGE_PULL_POLICY` - Define the Job pod connector image pull policy.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we also add the other job specific annotation env vars? it was an oversight on our part to leave out the job specific node selectors.

@@ -483,6 +484,7 @@ public KubePodProcess(final boolean isOrchestrator,
.withNewMetadata()
.withName(podName)
.withLabels(labels)
.withAnnotations(annotations.orElse(null))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happens if this is an empty map or null? if the effect is the same, it'll be slightly cleaner to drop the optional and have splitKVPairsFromEnvString. Sorry, I know you are following an already existing pattern - however I think it complicates things. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @davinchia, the optional has been added in this PR: #10200 , but I also don't really see its benefit.
splitKVPairsFromEnvString (previously getNodeSelectorsFromEnvString) is now used for both the annotations and the node selectors.
So, you would suggest that splitKVPairsFromEnvString returns a simple Map<String, String> instead of Optional<Map<String, String>> and adapt its usage for the annotations and node selectors, correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was actually discussed in this comment: #10200 (comment)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeap! returning a map would simplify the entire code execution chain.

@davinchia
Copy link
Contributor

@tbcdns thank you!

Pretty close. I left some comments.

Did you get a chance to do a sanity test on the node annotations?

@tbcdns
Copy link
Contributor Author

tbcdns commented Mar 28, 2022

@davinchia , @marcosmarxm I fixed your comments, could you please review it?
Thx!

@davinchia
Copy link
Contributor

davinchia commented Apr 4, 2022

/gke-kube-test

🕑 https://github.com/airbytehq/airbyte/actions/runs/2089043444
https://github.com/airbytehq/airbyte/actions/runs/2089043444

@davinchia
Copy link
Contributor

I ended up testing this locally and confirmed it works. I think there is a format issue. I don't have push to the fork so I will fix this after.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/documentation Improvements or additions to documentation area/platform issues related to the platform area/worker Related to worker community kubernetes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants