Add notebook on how to create a Service#250
Add notebook on how to create a Service#250mbohlool merged 1 commit intokubernetes-client:masterfrom
Conversation
| "source": [ | ||
| "spec = client.V1ServiceSpec()\n", | ||
| "spec.selector = {'app': 'MyApp'}\n", | ||
| "spec.ports = [client.V1ServicePort(protocol='TCP', port=80, target_port=9376)]\n", |
There was a problem hiding this comment.
@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}
There was a problem hiding this comment.
Ignore docs and pass a number instead of string. Let me know if it worked and I will explain why.
There was a problem hiding this comment.
Thanks, passing a number works fine.
sebgoa
left a comment
There was a problem hiding this comment.
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." |
There was a problem hiding this comment.
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." |
There was a problem hiding this comment.
..the label selection allows Kubernetes to determine which Pod should receive traffic when the service is used.
116a3d3 to
39d7cb3
Compare
|
/lgtm |
…/741 Refresh exec-based API credentials when they expire
No description provided.