wget -O - https://repo.saltstack.com/apt/ubuntu/16.04/amd64/2016.3/SALTSTACK-GPG-KEY.pub | sudo apt-key add -
wget -O - http://apt-mk.mirantis.com/public.gpg | sudo apt-key add -
add-apt-repository http://repo.saltstack.com/apt/ubuntu/16.04/amd64/2016.3
add-apt-repository "deb [arch=amd64] http://apt-mk.mirantis.com/xenial nightly salt"
apt update
apt install -y salt-master salt-minion reclass make
apt install -y salt-formula-linux salt-formula-reclass salt-formula-salt salt-formula-openssh salt-formula-ntp salt-formula-git salt-formula-docker salt-formula-etcd salt-formula-kubernetes

rm /etc/salt/minion_id
rm -f /etc/salt/pki/minion/minion_master.pub
echo "id: kube01.edge" > /etc/salt/minion
echo "master: localhost" >> /etc/salt/minion

[ ! -d /etc/salt/master.d ] && mkdir -p /etc/salt/master.d
cat <<-EOF > /etc/salt/master.d/master.conf
file_roots:
  base:
  - /usr/share/salt-formulas/env
pillar_opts: False
open_mode: True
reclass: &reclass
  storage_type: yaml_fs
  inventory_base_uri: /srv/salt/reclass
ext_pillar:
  - reclass: *reclass
master_tops:
  reclass: *reclass
EOF

[ ! -d /etc/reclass ] && mkdir /etc/reclass
cat <<-EOF > /etc/reclass/reclass-config.yml
storage_type: yaml_fs
pretty_print: True
output: yaml
inventory_base_uri: /srv/salt/reclass
EOF

service salt-master restart
service salt-minion restart

git clone https://github.com/andreyshestakov/k8s-compact /srv/salt/reclass
cd /srv/salt/reclass
git clone https://gerrit.mcp.mirantis.net/p/salt-models/reclass-system.git classes/system
mkdir classes/service
ln -s /usr/share/salt-formulas/reclass/service/* classes/service/

salt '*' saltutil.refresh_pillar
salt '*' saltutil.sync_all
salt '*' state.apply salt
salt '*' state.apply linux,ntp,openssh,git
salt -C 'I@docker:host' state.sls docker.host
salt -C 'I@etcd:server' state.sls etcd.server.service
salt -C 'I@etcd:server' cmd.run '. /var/lib/etcd/configenv && etcdctl cluster-health'
salt -C 'I@kubernetes:master' state.sls kubernetes.master.kube-addons
salt -C 'I@kubernetes:pool' state.sls kubernetes.pool
salt -C 'I@kubernetes:master and *01*' state.sls etcd.server.setup
salt -C 'I@kubernetes:master' state.sls kubernetes exclude=kubernetes.master.setup
salt -C 'I@kubernetes:master and *01*' state.sls kubernetes.master.setup
salt -C 'I@kubernetes:pool' service.restart 'kubelet'

docker run --net=host -e API_SERVER=http://localhost:8080 -it docker-dev-virtual.docker.mirantis.net/mirantis/kubernetes/k8s-conformance:v1.7.8-3_1509383733861