-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
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.
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}
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this 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." |
There was a problem hiding this comment.
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." |
There was a problem hiding this comment.
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.
116a3d3
to
39d7cb3
Compare
/lgtm |
…/741 Refresh exec-based API credentials when they expire
No description provided.