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

Fix and Update Existing Examples #884

Closed
13 tasks done
scottilee opened this issue Jul 17, 2019 · 10 comments · Fixed by #938
Closed
13 tasks done

Fix and Update Existing Examples #884

scottilee opened this issue Jul 17, 2019 · 10 comments · Fixed by #938
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.

Comments

@scottilee
Copy link
Contributor

scottilee commented Jul 17, 2019

The *.py files in the examples/ directory need updates for various reasons. Some of them could also use better file names and more commenting within the files (alternatively, there could be a README.md that provides more information about setup and each file). Below are the files that I have tested and found issues for.

  • create_deployment.py: seems redundant with deployment_examples.py and create_deployment_from_yaml.py, I think it should be merged with one of those
  • create_deployment_from_yaml.py: fix the associated nginx-deployment.yaml which creates pods that go to a state of crashloopbackoff
  • create_thirdparty_resource.md: in progress of being replaced with a custom resource definition example with add example of using custom resources #848
  • deployment_examples.py: add documentation
  • example1.py: add documentation and use more descriptive filename
  • example2.py: add documentation and use more descriptive filename
  • example3.py: add documentation and use more descriptive filename
  • example4.py: add documentation and use more descriptive filename, also the print("Active host is %s" % configuration.host) line throws the error AttributeError: module 'kubernetes.client.configuration' has no attribute 'host' -- in progress with https://github.com/kubernetes-client/python/pull/846/files
  • exec.py: add documentation explaining what this does
  • in_cluster_config.py: create YAML for in-cluster pod
  • manage_node_labels.py: add documentation that it is for minikube only
  • nginx-deployment.yaml: using this with create_deployment_from_yaml.py creates nginx pods that immediately go to a state of crashloopbackoff fixed by Deprecate extensions/v1beta1 deployment #888
  • remote_cluster.py: the list_pod_for_all_namespaces method returns a 401 unauthorized error, probably needs RBAC?

Examples without issues:

@roycaihw
Copy link
Member

This is awesome! Thanks for looking into the examples and putting together this summary.

Some additional thoughts:

@micw523
Copy link
Contributor

micw523 commented Jul 19, 2019

The create_deployment and create_deployment_from_yaml does the same thing except that the deployment is performed using different ways.

I wonder what's happening with the yaml deployment though. The source function for calling the yaml method should be the same.

@micw523
Copy link
Contributor

micw523 commented Jul 19, 2019

/help

@k8s-ci-robot
Copy link
Contributor

@micw523:
This request has been marked as needing help from a contributor.

Please ensure the request meets the requirements listed here.

If this request no longer meets these requirements, the label can be removed
by commenting with the /remove-help command.

In response to this:

/help

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. label Jul 19, 2019
@roycaihw
Copy link
Member

create_deployment_from_yaml.py: fix the associated nginx-deployment.yaml which creates pods that go to a state of crashloopbackoff

The yaml file models from https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#creating-a-deployment. It's probably something wrong with the container image 1.7.9. Please update the yaml file to be the same as https://k8s.io/examples/controllers/nginx-deployment.yaml

Deployment has been removed from extensions/v1beta1 in 1.15, we should update the examples create_deployment.py and create_deployment_from_yaml.py to use apps/v1 instead

@micw523
Copy link
Contributor

micw523 commented Jul 22, 2019

Sounds good. Looks like the e2e tests would need this update too. Let me quickly fix this today.

@scottilee
Copy link
Contributor Author

I will start organizing and fixing these examples in the week after next (busy next week unfortunately) and hopefully most of the pull requests trying to update examples will be merged by then as well.

@zmunro
Copy link

zmunro commented Sep 5, 2019

There is also an issue with the custom_objects.py example, but I am not sure if the issue is with the example or the api itself. I have not been able to call this api without getting an error. Below is the error output when I try to run the custom_objects.py module, and the error is similar when I try to call the API from elsewhere:

Traceback (most recent call last):
  File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/Users/zach/Documents/dzd2/examples/custom_object.py", line 93, in <module>
    main()
  File "/Users/zach/Documents/dzd2/examples/custom_object.py", line 65, in main
    body=my_resource,
  File "/usr/local/lib/python3.7/site-packages/kubernetes/client/apis/custom_objects_api.py", line 178, in create_namespaced_custom_object
    (data) = self.create_namespaced_custom_object_with_http_info(group, version, namespace, plural, body, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/kubernetes/client/apis/custom_objects_api.py", line 277, in create_namespaced_custom_object_with_http_info
    collection_formats=collection_formats)
  File "/usr/local/lib/python3.7/site-packages/kubernetes/client/api_client.py", line 334, in call_api
    _return_http_data_only, collection_formats, _preload_content, _request_timeout)
  File "/usr/local/lib/python3.7/site-packages/kubernetes/client/api_client.py", line 168, in __call_api
    _request_timeout=_request_timeout)
  File "/usr/local/lib/python3.7/site-packages/kubernetes/client/api_client.py", line 377, in request
    body=body)
  File "/usr/local/lib/python3.7/site-packages/kubernetes/client/rest.py", line 266, in POST
    body=body)
  File "/usr/local/lib/python3.7/site-packages/kubernetes/client/rest.py", line 222, in request
    raise ApiException(http_resp=r)
kubernetes.client.rest.ApiException: (404)
Reason: Not Found
HTTP response headers: HTTPHeaderDict({'Audit-Id': 'e1e34583-bc4d-45e2-96ec-9072d3624586', 'Content-Type': 'text/plain; charset=utf-8', 'X-Content-Type-Options': 'nosniff', 'Date': 'Thu, 05 Sep 2019 18:18:33 GMT', 'Content-Length': '19'})
HTTP response body: 404 page not found```

@roycaihw
Copy link
Member

@zmunro The 404 error sounds like the apiserver doesn't understand the requested API resource. Have you registered the CRD to apiserver?

# The following yaml manifest has to be applied first:
#
# apiVersion: apiextensions.k8s.io/v1beta1
# kind: CustomResourceDefinition
# metadata:
# name: crontabs.stable.example.com
# spec:
# group: stable.example.com
# versions:
# - name: v1
# served: true
# storage: true
# scope: Namespaced
# names:
# plural: crontabs
# singular: crontab
# kind: CronTab
# shortNames:
# - ct

It's probably better to have the example run the CRD creation for you

@micw523
Copy link
Contributor

micw523 commented Sep 11, 2019

@roycaihw the comment is addressed in #948, the issue that the author of the comment raised.

k8s-ci-robot added a commit that referenced this issue Sep 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants