-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathskydns.yaml
140 lines (132 loc) · 5.48 KB
/
skydns.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#cloud-config
coreos:
etcd:
addr: $private_ipv4:4001
peer-addr: $private_ipv4:7001
# runing a multi-node cluster with discovery mode:
# generate a new token for each unique cluster from https://discovery.etcd.io/new
# WARNING: replace each time you 'vagrant destroy'
#discovery: https://discovery.etcd.io/<token>
fleet:
public-ip: $private_ipv4
units:
- name: etcd.service
command: start
- name: fleet.service
command: start
- name: docker.service
command: start
content: |
.include /usr/lib/systemd/system/docker.service
[Service]
# Use our own dns, instead of the host's.
EnvironmentFile=/var/lib/skydns/env
ExecStart=
ExecStart=/usr/bin/docker daemon -r=false -H fd:// --dns=$private_ipv4 --dns-search=${DOMAIN}
- name: docker-tcp.socket
command: start
enable: true
content: |
[Unit]
Description=Docker Socket for the API
[Socket]
ListenStream=2375
Service=docker.service
BindIPv6Only=both
[Install]
WantedBy=sockets.target
- name: skydns-install.service
command: start
content: |
[Unit]
Description=SkyDNS Installer
[Service]
Type=oneshot
RemainAfterExit=true
EnvironmentFile=/var/lib/skydns/env
ExecStart=-/bin/mkdir -p ${SKYDNS_HOME}/bin
ExecStart=/usr/bin/bash -c "[ -x ${SKYDNS_CMD} ] || curl -L -o ${SKYDNS_CMD} ${SKYDNS_CMD_REPO} && chmod 755 ${SKYDNS_CMD}"
- name: skydns.service
command: start
content: |
[Unit]
Description=skydns
Requires=skydns-install.service
Requires=etcd.service
After=skydns-install.service
After=etcd.service
[Service]
Type=simple
Restart=always
RestartSec=5
EnvironmentFile=/etc/environment
EnvironmentFile=/var/lib/skydns/env
PermissionsStartOnly=true
# For DNS to work properly SkyDNS needs to tell peers its nameservers. i.e. ns=<private_ip>
ExecStartPre=/usr/bin/sh -c "etcdctl get ${DNS_NAMESERVER_PATH} > /dev/null || etcdctl set ${DNS_NAMESERVER_PATH} {host:${COREOS_PRIVATE_IPV4}}"
ExecStartPre=/usr/bin/etcdctl set ${DOMAIN_PATH}/%H '{"host":"${COREOS_PRIVATE_IPV4}"}'
# Set skydns configuration in etcd
ExecStartPre=/usr/bin/etcdctl set /skydns/config ${SKYDNS_CONFIG}
ExecStart=/usr/bin/bash -c ${SKYDNS_CMD}
ExecStopPost=-/usr/bin/etcdctl rm /skydns/config
ExecStopPost=-/usr/bin/etcdctl rm ${DNS_NAMESERVER_PATH} --with-value '{host:${COREOS_PRIVATE_IPV4}}'
ExecStopPost=-/usr/bin/etcdctl rm ${DOMAIN_PATH}/%H
[Install]
WantedBy=multi-user.target
write_files:
- path: /var/lib/skydns/env
permissions: 0644
owner: root
content: |
DOMAIN=docker.local
DOMAIN_PATH=/skydns/local/docker
DNS_NAMESERVER_PATH=/skydns/local/docker/dns/ns
SKYDNS_CONFIG='{"domain":"docker.local", "dns_addr":"0.0.0.0:53", "ttl":3600, "nameservers": ["8.8.8.8:53","8.8.4.4:53"]}'
SKYDNS_CMD_REPO=https://github.com/xuwang/skydns-docker/releases/download/skydns-7025dba3834f/skydns
SKYDNS_HOME=/var/lib/skydns
SKYDNS_CMD=/var/lib/skydns/bin/skydns
- path: /etc/resolv.conf
permissions: 0644
owner: root
content: |
domain docker.local
nameserver 127.0.0.1
nameserver 8.8.8.8
- path: /etc/profile.d/alias.sh
content: |
alias lal="ls -al"
alias ll="ls -l"
alias dk="docker "
alias dkc="dk ps"
alias dkm="dk images"
alias dki="dk inspect"
alias dkb="dk build"
alias cleandkc="dkc -a --no-trunc| grep Exit | awk '{print \$1}' | xargs -L 1 -r docker rm"
alias cleandkm="dkm -a --no-trunc | grep none | awk '{print \$3}' | xargs -L 1 -r docker rmi"
alias cleandk="cleandkc && cleandkm"
alias killdk="dk rm -f $(docker ps -qa)"
alias sd="sudo systemctl"
alias sdl="sd list-units"
alias sds="sd status"
alias sdcat="sd cat"
alias cci="sudo coreos-cloudinit --from-file"
alias j="journalctl"
alias jfu="journalctl -f -u"
alias e="etcdctl"
alias els="e ls --recursive"
alias eget="e get"
alias eset="e set"
alias f="fleetctl -strict-host-key-checking=false"
alias fcat="f cat"
alias fss="f status"
alias fst="f start"
alias fdy="f destroy"
alias flm="f list-machines"
alias flu="f list-units"
alias fsh="f ssh"
function dkip() { docker inspect --format "{{ .NetworkSettings.IPAddress }}" $1 ; }
function dkid() { docker inspect --format "{{ .ID }}" $1 ; }
function dkim() { docker inspect --format "{{ .Image }}" $1 ; }
function dkst() { docker inspect --format "{{ .State.Running }}" $1 ; }
function sdrit() { sudo docker run -i -t $1 bash ; }
function nsa { sudo nsenter -p -u -m -i -n -t $(docker inspect -f "{{ .State.Pid }}" $1) ; }