This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule LibCluster.LocalStrategy do | |
# this defines a strategy used in our local dev environment | |
# assuming a list of Nodes is defined in the runtime environment, | |
# we use that to connect our cluster | |
use Cluster.Strategy | |
alias Cluster.Strategy.State | |
def start_link([%State{} = state]) do | |
case System.get_env("NODES") do | |
node_binary_list when is_binary(node_binary_list) -> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Mix.Config | |
config :libcluster, | |
topologies: [ | |
example: [ | |
strategy: LibCluster.LocalStrategy | |
] | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Mix.Config | |
config :libcluster, | |
topologies: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Mix.Config | |
config :libcluster, | |
topologies: [ | |
k8s_example: [ | |
strategy: Elixir.Cluster.Strategy.Kubernetes.DNS, | |
config: [ | |
service: "excluster-service-headless", | |
application_name: "ex_cluster", | |
polling_interval: 3_000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ... | |
# No longer take in NODES from env | |
# case System.get_env("NODES") do | |
# nodes when is_binary(nodes) -> | |
# nodes | |
# |> String.split(",") | |
# |> Enum.map(&String.to_atom/1) | |
# |> Enum.each(&Node.connect/1) | |
# _ -> | |
# nil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: excluster-service-headless | |
spec: | |
ports: | |
- port: 8000 | |
selector: | |
app: ex-cluster | |
clusterIP: None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: extensions/v1beta1 | |
kind: Deployment | |
metadata: | |
name: ex-cluster | |
spec: | |
replicas: 2 | |
template: | |
metadata: | |
labels: | |
app: ex-cluster |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM elixir:1.7 | |
# Install Hex+Rebar | |
RUN mix local.hex --force && \ | |
mix local.rebar --force | |
WORKDIR /opt/app | |
ENV MIX_ENV=prod |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ... | |
## Name of the node | |
-name ex_cluster@${MY_POD_IP} | |
## Cookie for distributed erlang | |
-setcookie ${NODE_COOKIE} | |
# ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ... | |
defp deps do | |
[ | |
{ :horde, "~> 0.3.0" }, | |
# add distillery and libcluster | |
{ :distillery, "~> 2.0" }, | |
{ :libcluster, "~> 3.0" } | |
] | |
end | |
# ... |
NewerOlder