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

feat(components): Added Kubernetes CRUD operations #5239

Conversation

Ark-kun
Copy link
Contributor

@Ark-kun Ark-kun commented Mar 4, 2021

No description provided.

Comment on lines +18 to +34
object_path=$0
output_name_path=$1
output_kind_path=$2
output_object_path=$3
mkdir -p "$(dirname "$output_name_path")"
mkdir -p "$(dirname "$output_kind_path")"
mkdir -p "$(dirname "$output_object_path")"

kubectl apply -f "$object_path" --output=json > "$output_object_path"

< "$output_object_path" jq '.metadata.name' --raw-output > "$output_name_path"
< "$output_object_path" jq '.kind' --raw-output > "$output_kind_path"

- {inputPath: Object}
- {outputPath: Name}
- {outputPath: Kind}
- {outputPath: Object}
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is the difference between create and apply objects?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The difference is pretty small. Create always tries to create a new object and fails when it already exists.
Apply patches or replaces an object if it exists. Create supports auto-generating object names (generateName), but apply does not.
I'm adding both for the sake of completeness. There is a long-term plan to replace or retrofit kfp.dsl.ResourceOp with these components.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thank you Alexey! Do we plan to support generateName for Create, and fails if already exists in current PR? Or as you mentioned, it is for future plan?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

generateName is supported as part of the Kubernetes object passed to the Object input.
If you pass structure that has:

...
metadata:
    generateName: "some-prefix-"
...

to the "Create Kubernetes object" component, which calls kubectl create then the object name would be generated by Kubernetes and returned from the component.

If you pass that to the "Apply Kubernetes object" component, then kubectl will fail and the component will fail as it should.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I see, thank you Alexey!

@zijianjoy
Copy link
Collaborator

/lgtm
/approve

@google-oss-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Ark-kun, zijianjoy

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants