Thanks to visit codestin.com
Credit goes to github.com

Skip to content

add examples of deployment object #345

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 6 commits into from
Oct 18, 2017

Conversation

DjangoPeng
Copy link
Contributor

@DjangoPeng DjangoPeng commented Sep 24, 2017

Add 4 examples of deployment object, including:

  1. Create deployment object with client-python API
  2. Create deployment
  3. Update deployment
  4. Cascading delete deployment

@mbohlool Please check the PR. Refer this issue

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Sep 24, 2017
@DjangoPeng
Copy link
Contributor Author

Ping @mbohlool .I have updated the code style for PEP8. Now, it's ready to be reviewed.

# Update container image
deployment.container.image = "nginx:1.9.1"
# Update the deployment
api_response = api_instance.replace_namespaced_deployment(
Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest you use patch_namespaced_deployment here as it is the recommended way to update an API object. Replace can have unintentional consequences.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good suggestion.

@DjangoPeng
Copy link
Contributor Author

@mbohlool Updated. Plz review.

@mbohlool
Copy link
Contributor

mbohlool commented Sep 28, 2017

Have you actually tried this code? specially the patch that you just changed? I just want to make sure it is working for you before merging it into master. I will see if I can give it a try tomorrow.

@mbohlool
Copy link
Contributor

@DjangoPeng I tried these examples and they gave me syntax errors. That could be because of the new client generation. Can you please take a look at them and make sure that they can be run?

@DjangoPeng
Copy link
Contributor Author

@mbohlool I have fixed the error and tested all examples by myself. Please review and check.

@mbohlool
Copy link
Contributor

@DjangoPeng The branch is out of date. The new client has some differences (like you need to provide required fields on model creation, etc.). Please rebase to master and run the examples again. An example failure I get:

ValueError: Invalid value for `template`, must not be `None`

@DjangoPeng
Copy link
Contributor Author

@mbohlool Ok, I'll test it today .

@DjangoPeng
Copy link
Contributor Author

DjangoPeng commented Oct 13, 2017

I run all examples on Kubernetes 1.7 with client-python 3.0, and I attached the stdout as below. It looks like all is well. Should I try it on Kubernetes 1.8, or what?

$ python deployment_examples.py
Deployment created. status='{'available_replicas': None,
 'collision_count': None,
 'conditions': None,
 'observed_generation': None,
 'ready_replicas': None,
 'replicas': None,
 'unavailable_replicas': None,
 'updated_replicas': None}'
Deployment updated. status='{'available_replicas': None,
 'collision_count': None,
 'conditions': [{'last_transition_time': datetime.datetime(2017, 10, 13, 1, 30, 1, tzinfo=tzutc()),
                 'last_update_time': datetime.datetime(2017, 10, 13, 1, 30, 1, tzinfo=tzutc()),
                 'message': 'Deployment does not have minimum availability.',
                 'reason': 'MinimumReplicasUnavailable',
                 'status': 'False',
                 'type': 'Available'}],
 'observed_generation': 1,
 'ready_replicas': None,
 'replicas': None,
 'unavailable_replicas': 3,
 'updated_replicas': None}'
Deployment deleted. status='{u'observedGeneration': 1, u'unavailableReplicas': 3, u'conditions': [{u'status': u'False', u'lastUpdateTime': u'2017-10-13T01:30:01Z', u'lastTransitionTime': u'2017-10-13T01:30:01Z', u'reason': u'MinimumReplicasUnavailable', u'message': u'Deployment does not have minimum availability.', u'type': u'Available'}]}'

@mbohlool
Copy link
Contributor

Use master. You can goto root folder of repo and call python -m examples.deploment_examples. just make sure you rebase to the latest code.

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Oct 13, 2017
@DjangoPeng
Copy link
Contributor Author

@mbohlool Now, it works on latest master branch. I delete the rollback example because there is a error that I'm debugging and identifying. When I solve it, I'll make a new PR to append the rollback example.

@DjangoPeng
Copy link
Contributor Author

@mbohlool Please review the PR. I think it's ready to be merged.

@mbohlool
Copy link
Contributor

mbohlool commented Oct 18, 2017

@DjangoPeng Thanks. Great work.

@mbohlool mbohlool merged commit 8665a76 into kubernetes-client:master Oct 18, 2017
@DjangoPeng
Copy link
Contributor Author

DjangoPeng commented Oct 19, 2017

I have updated the description of the PR. Welcome to append the rollback example of Deployment.

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/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants