-
Notifications
You must be signed in to change notification settings - Fork 63
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
Python sample does not work as documented #82
Comments
Yes, you need to change at least Should we document it? |
Thank you. You solved my problem but that wasn't my question :-) I was referring to this documentation which contradicts the https://metaparticle.io/tutorials/python/ from metaparticle import containerize
...
@containerize(
'docker.io/your-docker-user-goes-here',
options={
'ports': [8080],
'name': 'my-image',
'publish': True
})
def main():
Handler = MyHandler
httpd = SocketServer.TCPServer(("", port), Handler)
httpd.serve_forever() So the documentation needs to be corrected to reflect the correct module name etc. |
OK... Making progress... Mashed-up the sample from the metaparticle.io Python page with this sample: from metaparticle_pkg import Containerize
from six.moves import SimpleHTTPServer, socketserver
import socket
repo = 'docker.io/[[MY-DOCKER]]'
name = 'mp-python'
OK = 200
port = 8080
class MyHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
def do_GET(self):
self.send_response(OK)
self.send_header("Content-type", "text/plain")
self.end_headers()
self.wfile.write("Hello Metaparticle [{}] @ {}\n".format(
self.path,
socket.gethostname()).encode('UTF-8')
)
print("request for {}".format(self.path))
def do_HEAD(self):
self.send_response(OK)
self.send_header("Content-type", "text/plain")
self.end_headers()
@Containerize(
package={
'name': name,
'repository': repo,
'publish': True,
},
runtime={
'ports': [
port
],
}
)
def main():
Handler = MyHandler
httpd = socketserver.TCPServer(("", port), Handler)
httpd.serve_forever()
if __name__ == '__main__':
print("Starting...")
main() Runs under Docker locally: curl http://localhost:8080/test
Hello Henry [/test] @ 8b31882c087c I reviewed the code to work out -- I think !? -- the config for Kubernetes: 'replicas': 4,
'executor': 'metaparticle', and this yields Starting...
==> Detected container mp-python-c5b8b68d7-6kfvr:mp-python-0
==> Detected container mp-python-c5b8b68d7-t7ldn:mp-python-0
==> Detected container mp-python-c5b8b68d7-tqz82:mp-python-0
==> Detected container mp-python-c5b8b68d7-xvpph:mp-python-0 and: kubectl get pods
NAME READY STATUS RESTARTS AGE
mp-python-c5b8b68d7-gxj65 1/1 Running 0 11s
mp-python-c5b8b68d7-p5lbd 1/1 Running 0 11s
mp-python-c5b8b68d7-stvqh 1/1 Running 0 11s
mp-python-c5b8b68d7-wkwpz 1/1 Running 0 11s
kubectl get services
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.63.240.1 <none> 443/TCP 1h
mp-python ClusterIP 10.63.240.159 <none> 8080/TCP 16s The service is a ClusterIP and would be better (can I configure?) as a LoadBalancer, so: kubectl run curl --image=radial/busyboxplus:curl -i --tty --rm
If you don't see a command prompt, try pressing enter.
[ root@curl-6896d87888-hqr6b:/ ]$ curl mp-python:8080/test
Hello Henry [/test] @ mp-python-c5b8b68d7-wkwpz |
you need to set (at least that should work in Python, if it doesn't file another bug...) |
oops, didn't mean to close this... |
I was wrong, I think it was meant to be But as I mentioned in the bug, I should probably switch that to |
Apologies for my delay in replying. That did not work. kubectl get services
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.43.240.1 <none> 443/TCP 49m
mp-python ClusterIP 10.43.255.186 <none> 8080/TCP 2m I did not upgrade my code. |
This is mostly my personal curiosity and no customer is being harmed by this not working as intended. Very much value your help @brendanburns and I'm inspired by metaparticle but, unless others are pestering, please don't prioritize this. I'm headed out on vacation tomorrow and will be non-responsive for a week. I did not update metaparticle nor refresh the repo. I added the property as you suggested. The code is as-above and: @Containerize(
package={
'name': name,
'repository': repo,
'publish': True,
},
runtime={
'ports': [
port
],
'replicas': 4,
'executor': 'metaparticle',
'publicAddress': True,
}
)
What else can I provide that would help you repo? Does |
Ok, I fixed this in #98 The syntax is now: runtime={'ports': [8080], 'executor': 'metaparticle', 'replicas': 3, 'public': True} And you need to update to |
I followed the instructions (honest):
I tried the Python sample as-is:
This returns:
I then tried:
This returns:
I briefly explored the package but it's not immediately obvious to me what needs to be done :-(
The text was updated successfully, but these errors were encountered: