-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Added additional examples #898
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
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: ratanboddu The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/assign @roycaihw |
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.
Thanks for contributing! I think the examples will be super helpful. I went through half of them and left some comments.
Since these examples are standalone, could you split this PR into smaller pieces (maybe 2~3 PRs, each containing a couple of exampels), which will be easier to review and keep track of?
@@ -0,0 +1,45 @@ | |||
# Copyright 2016 The Kubernetes Authors. |
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.
2019 (also in the other files)
name="kube-client-test" | ||
) | ||
) | ||
) |
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.
the indentation looks weird. I'm surprised that pycodestyle doesn't catch this
) | ||
|
||
# Listing pods in the namespace that we created | ||
list_namespaces = v1.list_namespaced_pod("kube-client") |
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.
the namespace being queried is different from the namespace you just created before kube-client-test
i.status.pod_ip, | ||
i.metadata.namespace, | ||
i.metadata.name) | ||
) |
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.
for a new namespace there will be no pod in it. I don't think printing pod information will show meaningful information. Maybe just GET the namespace above instead?
# Fetching and loading Kubernetes Information | ||
config.load_kube_config() | ||
# For incluster details | ||
# config.incluster_kube_config() |
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.
load_incluster_config
(also in the other files)
extension = client.ExtensionsV1beta1Api() | ||
|
||
body = client.ExtensionsV1beta1Ingress( | ||
api_version="v1beta1", |
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.
missing api group in api_version
field
) | ||
|
||
extension.create_namespaced_ingress( | ||
namespace="kube-client", |
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.
this requires the kube-client
namespace to be created first. I'd suggest using the default
namespace for a standalone example (also in the other files)
# For incluster details | ||
# config.incluster_kube_config() | ||
|
||
extension = client.BatchV1Api() |
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.
name the api object corresponding to the api being used, e.g. batch_v1
# Container | ||
container = client.V1Container( | ||
name="jobtest", | ||
image="nginx:1.7.9", |
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.
running nginx doesn't sound like a good use case for job to me
extension.create_namespaced_job( | ||
namespace="kube-client", | ||
body=job | ||
) |
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.
will the example print some information showing the job succeeded?
I'd suggest creating the job template in the official doc and print the pod logs. I have a snippet written for the first step already #872 (comment)
As suggested I've raised a PR for creating an Ingress #933 and will create more PR's for the remaining examples in the coming days |
@ratanboddu can you close this PR since you are splitting it out into other PRs? |
@roycaihw I still could not figure out the secret like docker secret. How do you pass the docker secret to authenticate the job to download from docker hub? |
Added the following examples :
-Ramped
-Recreate