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

Initial work on Orleans-Docker docs #3004

Merged
merged 5 commits into from
May 11, 2017
Merged

Initial work on Orleans-Docker docs #3004

merged 5 commits into from
May 11, 2017

Conversation

galvesribeiro
Copy link
Member

This PR add some guidance on how to deploy Orleans to Docker.

Initially, it explain how to create a project, add Docker support and debugger capabilities.

Swarm is described in this document. Kubernetes will be added later on.


Docker containers and networking model were designed to run mostly stateless and immutable containers. So, spin up a cluster running node.js or nginx applications, is pretty easy. However, if you try to use something more elaborated, like a real clustered or distributed application (like Orleans-based ones) you will eventually have troubles setting it up. It is possible, but not as simples as web-based applications.

Docker clustering consist of putting together multiple hosts to work as a single pull of resources managed using a *Container Orchestrator*. *Docker Inc.* provide **Swarm** as their option for Container Orchestration while *Google* has **Kubernetes** (aka **K8s**). There are other Orchestrators like **DC/OS**, **Mesos**, etc., but in this document we will talk about Swarm and K8s as they are more widely used.

Choose a reason for hiding this comment

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

"single pull" - i think you mean single pool*

Copy link
Member Author

Choose a reason for hiding this comment

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

Ops!


# Google Kubernetes (K8s)

Comming soon...

Choose a reason for hiding this comment

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

typo Coming*

Copy link
Member Author

Choose a reason for hiding this comment

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

Done. Thanks

services:
orleans-client:
image: orleans-client
depends_on:

Choose a reason for hiding this comment

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

not entirely sure, but do you think this is really needed as it doesnt seem to be supported within swarm mode; or perhaps only for docker-compose up?

The depends_on option is ignored when deploying a stack in swarm mode with a version 3 Compose file.
https://docs.docker.com/compose/compose-file/#dependson

Copy link
Member Author

Choose a reason for hiding this comment

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

Ha! That is new. Didn't checked that update. It used to work... Will check with the Docker folks what should be used now. Thanks for point out.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, just checked... It is only for stack. You still be able to use it with compose. Nevertheless, you are not required to use depends_on. It was just to illustrate the dependency so I think I'll stick with it there. I probably can create another section later (like the Kubernetes one) that show how to leverage stack.

To give an idea, most of the hosted Docker services like in Azure or AWS, still use the older versions of the engine, which mean, we still don't have stack available there.

But again, thanks for point that out.

Choose a reason for hiding this comment

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

welcome, and thanks for clarifying 👍


Docker clustering stack is called **Swarm** and you can find more by reading its [documentation here](https://docs.docker.com/engine/swarm/).

To run this article in a `Swarm` cluster, you don't have any extra work. When you run `docker-compose up -d` in a `Swarm` node, it will schedule containers based on the configured rules. The same applies to other Swarm-based services like [Docker Datacenter](https://www.docker.com/enterprise-edition), [Azure ACS](https://azure.microsoft.com/en-us/services/container-service/) (in Swarm mode), [AWS ECS Container Service](https://aws.amazon.com/ecs/) and so on. All you need to do is to deploy your `Swarm` cluster before deploy your **dockerized** Orleans application.

Choose a reason for hiding this comment

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

in order to deploy on swarms, it seems to be a better approach to use

docker stack deploy -c docker-compose.yml <name>

when using v3 compose files, perhaps just to mention it - what do you think?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, like I mentioned in your previously comment. It must have stack support on the engine. I'll add a comment there for it now. Thanks

Choose a reason for hiding this comment

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

sorry posted this before saw the reply

Copy link
Member Author

Choose a reason for hiding this comment

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

Np, thanks :)

@sergeybykov sergeybykov added this to the 1.5.0 milestone May 10, 2017
```

The string `orleans-silo` here, is essentially the **service name** used in `docker-compose`, which we will dig into more details later on (keep reading!). It will resolve to one of the containers' ips inside that same service (like a Load Balancer). In a docker-compose project, a service is a group of multiple (exactly equal) instances of a give container. For example, we will have a service for our `OrleansSilo` project. Within that service, we will be able to scale the service up and down horizontally and adding each of those containers to the Orleans cluster automatically respecting Orleans Membership Protocol. More on that later.

Copy link
Contributor

Choose a reason for hiding this comment

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

I was looking, but did not fin anything for "later".
I am puzzled how swarm clustering works along side Orleans's Membership.
If Orleans still creates a membership table in Azure, why GW is configured with IP and not pointed to the table?

Can you please explain?

Copy link
Member Author

Choose a reason for hiding this comment

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

@gabikliot because you are inside a Compose/Swarm project, the sane way to refer to another service, is by using the service name. Also, if the client is outside the same compose project of the silo, the IPs from the GW are not registered on Azure Table. We discussed before changes on the way membership record IPs on the tables, and everyone was against changes in MBR so the only safe way is to get the service IP, which works as a NLB and span across the cluster. It is a docker internal IP, not public, and works for the purpose of finding any of the GWs.

Copy link
Contributor

Choose a reason for hiding this comment

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

Let me see if I understand.
So if MBR registered the gw ip in the table, that ip is not routable from outside, so it is useless.
Instead, from outside, one has to go via load balancer end point ( which is what nlb stands for).
Correct?

So u just need to associate that end point with all gateway silos, make sure they are part of this load balanced group, and then it is a static end point for the clients to use. The Client will send to the end point, and the load balancer will route to one of the gateways. There is no way in this architecture to let client pick a gateway, be sticky to a particular gw for particular grains, etc...

Did I understand it correctly?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. The point is that you don't need to register the GW IP into the load balancer. The container's IP will be always behind the service IP, which is the load balancer.

So yes, you are correct.

MBR for this case, is only useful for the cluster, not the client.

I'm still investigating Kubernetes, which is way more complicated. Will see how its pod network works.

@gabikliot
Copy link
Contributor

Makes sense.

I still think one Could register internal gw ip in the table, as long as it is routable from outside. But there is no need to, as you said, since we can use the service end point.

@galvesribeiro
Copy link
Member Author

Yeah, I had a big debate with others from core team on whether we should register an internal IP + router IP in MBR or not. This very same case happens when you have firewalls/routers between OrleansClient and the cluster and this firewall/router only expose 1 single IP or a different IP address for each silo. Like you already know, we tried make a MBR provider for Docker but we fail because among other things, the way we register those IPs is different from what the majority of scenarios expect to be.

In the end, I decided stop fighting and with some updates on Docker I ended up with this solution which work perfectly fine. Even in case of gateway container failure, the service endpoint is notified and the next retry will in fact redirect to another container.

@gabikliot
Copy link
Contributor

I was not aware of this discussion.
If it was on GH, I would have had a chance to chime in.

we tried make a MBR provider for Docker but we fail

I do remember you tried. I remember that you tried to make it similar to Service Fabric, but what was not clear to me to then is if Swarm indeed provides the membership service (the list of active containers) in a way that we could feed in Orleans.

Conceptually, I don't see a problem with exposing the actual IP and not the service end point, IF they are indeed routable and secure. Orleans does its own load balancing between gateways, so it does not strickly need the load balanced end point.

I think its similar in spirit to the same high level discussion of why not use storage always and write stateless services and never do in memory state (and have to route to this state, etc)... Load balanced end point is great, but not a panacea. One should not force everyone always to use it. If we have our won solution that works better for us, why not.

@galvesribeiro
Copy link
Member Author

@gabikliot #2571

And yes, I agree that would be awesome if we have our own membership. Maybe we can have it Kubernetes, I don't know, still need to check it.

For now, this document and the sample will unblock a lot of people trying to use Orleans and Docker with Swarm. They are eagerly asking for it and since I was the one who got it to work and is actively working with Docker daily, I decided to write it and shed some light for people. We can always revisit it later if/when we have a membership solution for it.

@gabikliot
Copy link
Contributor

+1 on unblocking first.

@sergeybykov sergeybykov merged commit 2cd9f75 into dotnet:gh-pages May 11, 2017
@sergeybykov
Copy link
Contributor

Thank you very very much, @galvesribeiro! This is just the beginning.

@galvesribeiro
Copy link
Member Author

Yup! Will come up with more later. Just want to make sure people got unblocked and I stop to repeat same thing on Gitter 😄

@galvesribeiro galvesribeiro deleted the docker-docs branch May 11, 2017 20:45
var config = new ClientConfiguration();
config.DeploymentId = "Orleans-Docker";
config.PropagateActivityId = true;
var hostEntry = await Dns.GetHostEntryAsync("orleans-silo");
Copy link

Choose a reason for hiding this comment

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

When I use service name "orleans-silo", have a error.

Unhandled Exception: System.AggregateException: One or more errors occurred. (No such device or address)

It's my docker-compose file:

version: '3'

services:
  orleans-silo:
    image: hub.xxx.com/beck/orleans/silo-test:0.0.1
    volumes:
      - /usr/local/beck/docker/orleans/test/siloservice/config:/app/Config
~                                                                             

@RainingNight
Copy link

Any 2.x docker sample?

@github-actions github-actions bot locked and limited conversation to collaborators Dec 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants