This guide describes how to bootstrap new Production Core OS Cluster as High Availability Service in a 15 minutes with using etcd2, Fleet, Flannel, Confd, Nginx Balancer and Docker.
3 августа 2017, RamblerFront& meetup #2, Москва
В коде начинающих программистов обычно много ошибок. Постепенно мы набираемся опыта, код становится надежнее, покрывается тестами, и нам кажется, что ошибки в нашем коде практически исключены.
Но фронтенд — это неконтролируемая среда и произойти может что угодно. Доклад о том, как начать использовать ошибки в свою пользу.
#!/usr/bin/env bash | |
# Фейковый npm | |
# Нужен для кэширования папки node_modules | |
# Кэш находится в папке ~/.cache/npm-inject/[sha1 хэш файла package.json]/node_modules | |
# | |
# В PATH надо добавить путь папки с фейковым npm, таким образом при выполнении команды `npm install` | |
# bash вызовет фейковый npm c параметром `install`. | |
# Фейк проверяет наличие папки [sha1 хэш файла package.json] в кэше. | |
# Если она в кэше, создаем на неё симлинк node_modules |
Custom recipe to get full Node.js Cloud Environment in DigitalOcean Dokku droplet running from scratch. Yes. Your own Heroku for $5 per month.
I use this gist to keep track of the important configuration steps required to have a functioning system after fresh install.
When you have executed that's all step by step you will get a new working and stable system which is ready to host & serve your Node.js application and databases.
#cloud-config | |
coreos: | |
etcd: | |
# generate a new token for each unique cluster from https://discovery.etcd.io/new | |
discovery: https://discovery.etcd.io/<token> | |
# multi-region deployments, multi-cloud deployments, and droplets without | |
# private networking need to use $public_ipv4 | |
addr: $private_ipv4:4001 | |
peer-addr: $private_ipv4:7001 |
{ | |
"ru": { | |
"Your original english text": "Твой оригинальный русский текст" | |
} | |
} |
- View the diagram of what's going on: https://drive.google.com/file/d/0B74l6vUHf9HrMzNrYUlyMm40RWs/view?usp=sharing
- coreos: server machine clustering via a shared cloud-config.yml
- etcd: key value store for service registration and discovery
- fleet: scheduling/failover of docker containers across coreos cluster
- flannel: Gives each docker container a unique ip that allows you to access the internal port (i.e. port 80 not 32679)
- confd: watch etcd for nodes arriving/leaving - template nginx configuration files / reload nginx on change
Before upgrading, make sure you are allowing insecure registry access, or your newer docker won't be able to talk to the Deis registry:
sudo bash -c 'mkdir -p /etc/systemd/system/docker.service.d/; cat <<EOF > /etc/systemd/system/docker.service.d/50-insecure-registry.conf
[Service]
Environment="DOCKER_OPTS=--insecure-registry 10.0.0.0/8 --insecure-registry 172.16.0.0/12 --insecure-registry 192.168.0.0/16"
EOF
'
function offset(count, offset, limit) { | |
const finalOffset = Math.max(Math.min(count, offset), 0); | |
const remainedCount = Math.min(count, count - finalOffset); | |
const finalCount = (typeof limit === 'number') ? Math.min(limit, remainedCount) : remainedCount; | |
return { offset: finalOffset, finalCount: finalCount }; | |
} | |
console.log(offset(10, 0)); // {"offset":0,"finalCount":10} | |
console.log(offset(10, 4)); // {"offset":4,"finalCount":6} | |
console.log(offset(10, 10)); // {"offset":10,"finalCount":0} |
import React from 'react' | |
import 'fontfaceobserver' | |
import IndexPage from './IndexPage' | |
import Loader from './Loader' | |
import { fetchUser } from '../apiclient' | |
import 'font-awesome-webpack' | |
import './Lato-font.css' | |
import './Roboto-font.css' |