-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add default_gcp_op #314
Add default_gcp_op #314
Changes from 5 commits
54b75c8
396607f
8c1756b
0b9a34c
033e4bf
5e2b368
5919bce
17ac105
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Copyright 2018 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from .kubeflow_tfjob_launcher_op import kubeflow_tfjob_launcher_op | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Copyright 2018 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from kfp import dsl | ||
from typing import Dict | ||
from kubernetes import client as k8s_client | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you please move the kubernetes import inside the function? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
|
||
|
||
def default_gcp_op(name: str, image: str, command: str = None, | ||
arguments: str = None, file_inputs: Dict[dsl.PipelineParam, str] = None, | ||
file_outputs: Dict[str, str] = None, is_exit_handler=False): | ||
"""An operator that mounts the default GCP service account to the container. | ||
|
||
The user-gcp-sa secret is created as part of the kubeflow deployment that | ||
stores the access token for kubeflow user service account. | ||
|
||
With this service account, the container has a range of GCP APIs to | ||
access to. This service account is automatically created as part of the | ||
kubeflow deployment. | ||
|
||
For the list of the GCP APIs this service account can access to, check | ||
https://github.com/kubeflow/kubeflow/blob/7b0db0d92d65c0746ac52b000cbc290dac7c62b1/deployment/gke/deployment_manager_configs/iam_bindings_template.yaml#L18 | ||
|
||
If you want to call the GCP APIs in a different project, grant the kf-user | ||
service account access permission. | ||
""" | ||
return dsl.ContainerOp(name, image, command, arguments, file_inputs, | ||
IronPan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
file_outputs, is_exit_handler). \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you please move the dot to the next line? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and thanks for the suggestion of parentheses. I think slash is not uncommon to see so maybe just use it for now? we can switch when we see it pain to read |
||
add_volume(k8s_client.V1Volume(name='gcp-credentials', | ||
secret=k8s_client.V1SecretVolumeSource( | ||
secret_name='user-gcp-sa'))). \ | ||
add_volume_mount(k8s_client.V1VolumeMount( | ||
mount_path='/secret/gcp-credentials', name='gcp-credentials')). \ | ||
add_env_variable(k8s_client.V1EnvVar( | ||
name='GOOGLE_APPLICATION_CREDENTIALS', | ||
value='/secret/gcp-credentials/user-gcp-sa.json')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrong import?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed. thx