Nix in a Cluster Environment

● ●

Kevin Cox https://kevincox.ca

● ●

Been using Nix for ~2 years. Have been running a personal cluster for almost that long. Working as an SRE at Google. Opinions expressed are my own, no one else’s.

Overview ● ● ● ●

What is a cluster good for? Why are clusters hard? How Nix makes clusters easier. Introduction to my personal cluster as an example implementation.

What I Want out of a Cluster ● Abstract individual machines. ● Keep track of resource usage. ● Isolate difference tasks/services.

Challenges in a cluster environment. ● ● ● ●

Base system consistency. Getting data where it needs to be. Base system still needs to be updated. You don’t know your neighbours. ○ You could even be a neighbour with a different version of yourself!

How Nix Helps ● Isolation ○ Nix packages depend only on other store paths. ○ Store paths are named based on hashes so they don’t conflict with each other.

● Deployment ○ Easy dependencies. ○ No naming issues.

More Nix Advantages ● Packages can be installed by any user. ● Packages are file/directory trees. ● Built in distribution infrastructure.

Putting it Together 1. 2. 3. 4.

Developer commits new version. Packages are built in CI and tested. Artifacts are uploaded to “binary cache”. On success new version is sent to the cluster scheduler.

Developer commits new version. ● Works just as you are used to. ● You can also use nix-env to give your developers an environment just like production.

Packages are built in CI and Tested ● This build “locks in” exact package versions. ○ I generally follow a nixpkgs release. ○ Could also pin to a specific version.

● Tests are run on exact set of dependencies. ● Results are uploaded to package server. ● If tests fail the exact packages can be fetched for debugging.

Service Updated ● Contains exact version information. ● Optionally contain config and data. ○ Recommended, depends on your use case.

● Your tooling should handle rollouts and rollbacks.

Questions?

My Cluster Always a work in progress, many options selected for simplicity.

● ● ● ● ●

Mesos/Marathon Semaphore CI B2 Cloud Storage Github and Bitbucket etcd + Cloudflare DNS DNS

Semaphore CI ● Free and hosted. ● Allows custom commands. ● Easy to switch.

Semaphore CI # (Heavily) simplified. See https://github.com/kevincox/nix-ci/blob/master/nix-ci.sh curl -fsS https://nixos.org/nix/install | bash # Build/test nix-build --fallback --show-trace # Upload nix-env -i /nix/store/jm3pazmq42x9lqz9dsvwrj16f74bwj2g-b2-nix-cache \ /nix/store/p5rdp7zlgfqryqnk80jjwnbc7b2f0x8v-backblaze-b2-0.6.2 b2-nix-cache $(cat secrets/b2-bucket) secrets/nix-cache-key # Deploy nix-build -A marathon -o result-marathon wget "${args[@]}" \ --method PUT \ --header 'Content-Type: application/json' --body-file result-marathon "$(cat secrets/marathon)/v2/apps"

Mesos/Marathon ● Provide cluster scheduling. ● Marathon has basic deployment tools. ● Marathon provides a nice API ○ Used for monitoring/alerting on task health. ○ Used for updating DNS to point at healthy tasks.

● Mesos is incredibly flexible.

Mesos/Marathon marathon = klib.marathon.config [{ id = "/api.dontsayit.kevincox.ca"; dns = [{ name = "api.dontsayit.kevincox.ca" }]; mem = 50; ports = 1; user = "api-dontsayit"; env-pass = [ "PORT0" ]; env-files = [ "/etc/dontsayit" ]; env = { RUST_BACKTRACE = "1"; DSI_WORDS = "${./data/words.csv}"; }; exec = '' export DSI_BIND=0.0.0.0:$PORT0 exec "${out}/bin/dontsayit-api" ''; healthChecks = [{ … }]; }];

Mesos/Marathon # Stage 1 args = [ "/run/current-system/sw/bin/sh" "-c" '' set -eaux . /etc/kevincox-environment nix-store -r ${stage2f} --add-root klib-marathon-stage-2 --indirect exec env -i ${env-pass} ${stage2f} "$@" '' "--" ]

Mesos/Marathon # Stage 2 stage2 = '' #! ${pkgs.dash}/bin/dash set -eaux ${ concatMapStringsSep "\n" (f: ". '${f}'") r.env-files } ${ env } exec "$@" # Not executed, included to make a dependency. ${concatStrings user-cmd} '';

Questions?

Nix in a Cluster Environment

Developer commits new version. 2. Packages are built in ... developers an environment just like production. ... result-marathon. "$(cat secrets/marathon)/v2/apps" ...

NAN Sizes 2 Downloads 233 Views

Recommend Documents

Revisiting TCP Congestion Control in A Virtual Cluster ...
Cloud computing allows users to hire a cluster of VMs in an on-demand fashion. To improve the cost-effectiveness of their cloud platforms, cloud providers strive ...

Cluster Forests
May 23, 2013 - The general goal of clustering is to partition a set of data such that ...... Proceedings of the IEEE International Conference on Data Mining, pages.

Cluster Forests
May 23, 2013 - cloud to obtain “good local clusterings” and then aggregates via .... The growth of a clustering vector is governed by the following .... likelihood solution. ...... In ACM Symposium on the Theory of Computing, pages 619–626,.

Cluster Forests
May 23, 2013 - Irvine machine learning benchmark datasets. Finally we conclude in Section 6. 2 The Method. CF is an instance of the general class of cluster ...

Cluster Forests
May 23, 2013 - Department of Statistics and of EECS. University of ... Geometrically, CF randomly probes a high-dimensional data cloud to obtain .... followed by an analysis of the κ criterion and the mis-clustering rate of spectral clustering ...

A NOVEL INTER-CLUSTER DISTANCE ... - Semantic Scholar
ous meeting speech data show that this combined measure improves ..... speaker diarization systems,” IEEE Trans. Audio ... Speech and Audio Processing, vol.

Cluster audiovisual.pdf
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. Cluster ...

Agenda - Shelter Cluster
ADRA is working with voucher system, in cooperation with Canadian government. Voucher system is used with Metro (as only Metro responded among all the ...

meeting notes - Shelter Cluster
Feb 23, 2015 - The form is available as a web-based form and on Android as an application (ODK Collect). It allows easily record all assistance and then ...

WAP, Scalability and Availability in a J2EE environment
Dec 4, 2000 - Support for JMS on part of J2EE compliant application servers has now been raised ... respect to ascertaining the best deployment scenario. ..... A JMS Provider is the entity which implements JMS for a messaging product.

Web Browsing in a Wireless Environment
wireless Web access practical from both a usability and cost perspective. The successful deployment of Web. Express extends Web technology to a new usage ...

WAP, Scalability and Availability in a J2EE environment
Dec 4, 2000 - application within a domain, needs thorough investigation and testing ...... machine hosting the application server would cause all the services.

Statistical thinking in a technological environment
salaries in Israel, Internet sites to look for data on salaries, newspaper articles .... public bus company's campaign to use buses, because of their safety, is not ...