Skip to content

Added additional examples#898

Closed
ratanboddu wants to merge 10 commits into
kubernetes-client:masterfrom
ratanboddu:examples
Closed

Added additional examples#898
ratanboddu wants to merge 10 commits into
kubernetes-client:masterfrom
ratanboddu:examples

Conversation

@ratanboddu

Copy link
Copy Markdown
Contributor

Added the following examples :

  • Jobs
  • Hooks
  • Namespaces
  • Services
  • Ingress
  • Deployment Strategies
    -Ramped
    -Recreate

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jul 26, 2019
@k8s-ci-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: ratanboddu
To complete the pull request process, please assign roycaihw
You can assign the PR to them by writing /assign @roycaihw in a comment when ready.

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

Details 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

@k8s-ci-robot k8s-ci-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Jul 26, 2019
@ratanboddu

Copy link
Copy Markdown
Contributor Author

/assign @roycaihw

@roycaihw roycaihw left a comment

Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Member

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"
)
)
)

Copy link
Copy Markdown
Member

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")

Copy link
Copy Markdown
Member

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)
)

Copy link
Copy Markdown
Member

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()

Copy link
Copy Markdown
Member

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",

Copy link
Copy Markdown
Member

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",

Copy link
Copy Markdown
Member

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)

Comment thread examples/create_job.py
# For incluster details
# config.incluster_kube_config()

extension = client.BatchV1Api()

Copy link
Copy Markdown
Member

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

Comment thread examples/create_job.py
# Container
container = client.V1Container(
name="jobtest",
image="nginx:1.7.9",

Copy link
Copy Markdown
Member

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

Comment thread examples/create_job.py
extension.create_namespaced_job(
namespace="kube-client",
body=job
)

Copy link
Copy Markdown
Member

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)

@ratanboddu

Copy link
Copy Markdown
Contributor Author

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?

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

@scottilee

Copy link
Copy Markdown
Contributor

@ratanboddu can you close this PR since you are splitting it out into other PRs?

@ratanboddu ratanboddu closed this Aug 21, 2019
@lucheeseng827

Copy link
Copy Markdown

@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?

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

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants