Skip to content

Add notebook on how to create a Service#250

Merged
mbohlool merged 1 commit into
kubernetes-client:masterfrom
djkonro:create_service
Jul 7, 2017
Merged

Add notebook on how to create a Service#250
mbohlool merged 1 commit into
kubernetes-client:masterfrom
djkonro:create_service

Conversation

@djkonro

@djkonro djkonro commented Jun 9, 2017

Copy link
Copy Markdown
Contributor

No description provided.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jun 9, 2017
Comment thread examples/notebooks/create_service.ipynb Outdated
"source": [
"spec = client.V1ServiceSpec()\n",
"spec.selector = {'app': 'MyApp'}\n",
"spec.ports = [client.V1ServicePort(protocol='TCP', port=80, target_port=9376)]\n",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@mbohlool Please, why does the documentation (https://github.com/kubernetes-incubator/client-python/blob/master/kubernetes/docs/V1ServicePort.md) say target_port is of type str, but when I do target_port='9376' I get the errors below.

kubernetes.client.rest.ApiException: (422)
Reason: Unprocessable Entity
HTTP response headers: HTTPHeaderDict({'Date': 'Thu, 08 Jun 2017 22:42:31 GMT', 'Content-Length': '468', 'Content-Type': 'application/json'})
HTTP response body: {"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"Service \"my-service\" is invalid: spec.ports[0].targetPort: Invalid value: \"9376\": must contain at least one letter or number (a-z, 0-9)","reason":"Invalid","details":{"name":"my-service","kind":"Service","causes":[{"reason":"FieldValueInvalid","message":"Invalid value: \"9376\": must contain at least one letter or number (a-z, 0-9)","field":"spec.ports[0].targetPort"}]},"code":422}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ignore docs and pass a number instead of string. Let me know if it worked and I will explain why.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks, passing a number works fine.

@mbohlool
mbohlool requested a review from sebgoa June 21, 2017 06:26

@sebgoa sebgoa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Small changes on descriptions.

Comment thread examples/notebooks/create_service.ipynb Outdated
"=============\n",
"\n",
"In this notebook, we show you how to create a [Service](https://kubernetes.io/docs/concepts/services-networking/service/). \n",
"A Service in Kubernetes is a REST object, similar to a Pod. It is an abstraction which defines a logical set of Pods and a policy by which to access them - sometimes called a micro-service."

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A service is a key Kubernetes API resource. It defines a networking abstraction to route traffic to a particular set of Pods using a label selection.

Comment thread examples/notebooks/create_service.ipynb Outdated
},
"source": [
"### Provide Service .spec description\n",
"Set Service object named **my-service** to target TCP port **9376** on any Pod with the **app=MyApp** label."

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

..the label selection allows Kubernetes to determine which Pod should receive traffic when the service is used.

@djkonro
djkonro force-pushed the create_service branch 2 times, most recently from 116a3d3 to 39d7cb3 Compare July 6, 2017 01:55
@sebgoa

sebgoa commented Jul 7, 2017

Copy link
Copy Markdown
Contributor

/lgtm

@mbohlool

@mbohlool
mbohlool merged commit 2fac3c7 into kubernetes-client:master Jul 7, 2017
yliaog pushed a commit to yliaog/client-python that referenced this pull request Jan 8, 2022
…/741

Refresh exec-based API credentials when they expire
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants