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

Add notebook on how to create a Service #250

Merged
merged 1 commit into from Jul 7, 2017

Conversation

djkonro
Copy link
Contributor

@djkonro djkonro commented Jun 9, 2017

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
"source": [
"spec = client.V1ServiceSpec()\n",
"spec.selector = {'app': 'MyApp'}\n",
"spec.ports = [client.V1ServicePort(protocol='TCP', port=80, target_port=9376)]\n",
Copy link
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
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
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.

Copy link
Contributor

@sebgoa sebgoa left a comment

Choose a reason for hiding this comment

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

Small changes on descriptions.

"=============\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
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.

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

@sebgoa
Copy link
Contributor

sebgoa commented Jul 7, 2017

/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.

None yet

4 participants