Skip to content

Instantly share code, notes, and snippets.

@jschwinger233
Last active December 9, 2019 09:38
Show Gist options
  • Select an option

  • Save jschwinger233/80c81036f1609335cead0a10f1332a01 to your computer and use it in GitHub Desktop.

Select an option

Save jschwinger233/80c81036f1609335cead0a10f1332a01 to your computer and use it in GitHub Desktop.
# init
systemctl stop iptables
apt update -y
# etcd
curl -OL https://github.com/etcd-io/etcd/releases/download/v3.3.10/etcd-v3.3.10-linux-amd64.tar.gz
tar xf etcd-v3.3.10-linux-amd64.tar.gz
cp -f /root/etcd-v3.3.10-linux-amd64/{etcd,etcdctl} /usr/bin/
if [ -z $master ]
then
nohup etcd --listen-client-urls http://0.0.0.0:2379 --advertise-client-urls http://0.0.0.0:2379 &> etcd.log &
else
nohup etcd gateway start --endpoints=$master:2379 --listen-addr 127.0.0.1:2379 &> etcd-gateway.log &
fi
# docker
apt install docker.io -y
cat > /etc/docker/daemon.json <<!
{
"hosts": ["unix:///var/run/docker.sock", "tcp://0.0.0.0:2376"],
"log-level":"debug",
"cluster-store":"etcd://127.0.0.1:2379"
}
!
sed -i 's/-H\s\+fd:\/\///g' /lib/systemd/system/docker.service
systemctl daemon-reload
systemctl restart docker
# calico
curl -L https://github.com/projectcalico/calicoctl/releases/download/v3.4.0/calicoctl -o /usr/bin/calicoctl
chmod a+x /usr/bin/calicoctl
mkdir -p /etc/calico
cat > /etc/calico/calicoctl.cfg <<!
apiVersion: projectcalico.org/v3
kind: CalicoAPIConfig
metadata:
spec:
datastoreType: "etcdv3"
etcdEndpoints: "http://127.0.0.1:2379"
!
calicoctl node run --node-image="calico/node:release-v3.4" --disable-docker-networking
cat <<! | calicoctl create -f -
- apiVersion: projectcalico.org/v3
kind: IPPool
metadata:
name: test
spec:
natOutgoing: true
cidr: 10.213.0.0/16
ipipMode: Always
!
cat <<! | calicoctl create -f -
apiVersion: projectcalico.org/v3
kind: Profile
metadata:
name: test
spec:
egress:
- action: Allow
destination: {}
source: {}
ingress:
- action: Allow
destination: {}
source: {}
!
echo 'net.netfilter.nf_conntrack_max=1000000' >>/etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_max=1000000' >>/etc/sysctl.conf
sysctl -p
# libnetwork
docker run -d --restart always --name minions --network host -v /var/run/docker/plugins/:/var/run/docker/plugins --privileged --env ETCD_ENDPOINTS=http://127.0.0.1:2379 projecteru2/minions /usr/bin/eru-minions
docker network create --ipam-driver calico-ipam --driver calico --subnet 10.213.0.0/16 test
[ ! -z $master ] && exit 0
# eru core
mkdir -p /etc/eru
cat <<! > /etc/eru/core.yaml
log_level: DEBUG
bind: ":5001"
image_cache: 2
global_timeout: 300s
lock_timeout: 30s
etcd:
machines:
- "http://127.0.0.1:2379"
prefix: "/eru-core"
lock_prefix: "core/_lock"
docker:
log:
type: "json-file"
config:
"max-size": "10m"
network_mode: "bridge"
cert_path: ""
hub: "hub.docker.com"
namespace: "projecteru2"
build_pod: "eru"
local_dns: true
scheduler:
maxshare: -1
sharebase: 100
!
docker run -d --name eru_core --net host --restart always -v /etc/eru:/etc/eru projecteru2/core /usr/bin/eru-core
# eru cli
add-apt-repository ppa:longsleep/golang-backports
apt-get update
apt-get install golang-go
GO111MODULE=on go get github.com/projecteru2/cli
export PATH=/root/go/bin/:$PATH
echo 'export PATH=/root/go/bin/:$PATH' >> ~/.bashrc
# pod and node
cli pod add k8s
cli node add --nodename $(hostname) --endpoint tcp://$(ip a show dev eth0 | grep -Po '\d+(\.\d+){3}'):2376 k8s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment