Skip to content

Improve kube deploy process. #13397

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

Merged
merged 4 commits into from
Jun 2, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 41 additions & 37 deletions kube/resources/bootloader.yaml
Original file line number Diff line number Diff line change
@@ -1,40 +1,44 @@
apiVersion: v1
kind: Pod
apiVersion: batch/v1
kind: Job
Copy link
Contributor

Choose a reason for hiding this comment

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

Kube jobs only have best effort parallelism guarantees, which is why I don't really like using them for crucial workflows. Took a look and confirmed this is probably the best way of doing this with Kustomize. Can we add a comment here that we generally want to use Pod (our Helm charts use Pod) for the best exactly-once execution guarantees and cannot do so because Kustomize does not support generateName? Want to prevent confusion in the future.

If Kustomize did support generateName, we should be able to instruct users to run kubectl create on initial create and replace on subsequent runs.

This happens relatively infrequently so risk is low. In the long term, I think we'll consolidate the Kube deploys into Helm so I think this is fine for now.

metadata:
name: airbyte-bootloader
spec:
restartPolicy: Never
containers:
- name: airbyte-bootloader-container
image: airbyte/bootloader
env:
- name: AIRBYTE_VERSION
valueFrom:
configMapKeyRef:
name: airbyte-env
key: AIRBYTE_VERSION
- name: DATABASE_HOST
valueFrom:
configMapKeyRef:
name: airbyte-env
key: DATABASE_HOST
- name: DATABASE_PORT
valueFrom:
configMapKeyRef:
name: airbyte-env
key: DATABASE_PORT
- name: DATABASE_PASSWORD
valueFrom:
secretKeyRef:
name: airbyte-secrets
key: DATABASE_PASSWORD
- name: DATABASE_URL
valueFrom:
configMapKeyRef:
name: airbyte-env
key: DATABASE_URL
- name: DATABASE_USER
valueFrom:
secretKeyRef:
name: airbyte-secrets
key: DATABASE_USER
# This ttl is necessary to prevent errors when upgrading airbyte
ttlSecondsAfterFinished: 5
Copy link
Contributor Author

Choose a reason for hiding this comment

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

As mentioned in the PR description, this is necessary to avoid an error being about the airbyte-bootloader job being immutable. This isn't an ideal solution, because this means that the bootloader pod is deleted after it completes, making its logs inaccessible through kube.

This was the only solution I could come up with that allowed us to still use kubectl apply without issue though, so it may be a worthwhile tradeoff.

Definitely open to feedback here if there are any other options I haven't considered.

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 add a comment explaining why we do this, please?

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 thing, done!

template:
spec:
restartPolicy: Never
containers:
- name: airbyte-bootloader-container
image: airbyte/bootloader
env:
- name: AIRBYTE_VERSION
valueFrom:
configMapKeyRef:
name: airbyte-env
key: AIRBYTE_VERSION
- name: DATABASE_HOST
valueFrom:
configMapKeyRef:
name: airbyte-env
key: DATABASE_HOST
- name: DATABASE_PORT
valueFrom:
configMapKeyRef:
name: airbyte-env
key: DATABASE_PORT
- name: DATABASE_PASSWORD
valueFrom:
secretKeyRef:
name: airbyte-secrets
key: DATABASE_PASSWORD
- name: DATABASE_URL
valueFrom:
configMapKeyRef:
name: airbyte-env
key: DATABASE_URL
- name: DATABASE_USER
valueFrom:
secretKeyRef:
name: airbyte-secrets
key: DATABASE_USER
3 changes: 3 additions & 0 deletions kube/resources/db.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ metadata:
name: airbyte-db
spec:
replicas: 1
# Recreate strategy is necessary to avoid multiple simultaneous db pods running and corrupting the db state
strategy:
type: Recreate
selector:
matchLabels:
airbyte: db
Expand Down