docker-compose.yaml
4.62 KB
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
version: '3.4'
x-extra-hosts: &_x_extra_hosts
extra_hosts:
- "${APP_REGISTRY_NAME}:${APP_REGISTRY_ADDRESS}"
x-etcd-environment: &_x-etcd-environment
ALLOW_NONE_AUTHENTICATION: "yes"
ETCD_LISTEN_PEER_URLS: http://0.0.0.0:2380
ETCD_LISTEN_CLIENT_URLS: http://0.0.0.0:2379
ETCD_INITIAL_CLUSTER_TOKEN: etcd-cluster
ETCD_INITIAL_CLUSTER: etcd1=http://etcd1:2380,etcd2=http://etcd2:2380,etcd3=http://etcd3:2380
ETCD_INITIAL_CLUSTER_STATE: new
ETCD_DATA_DIR: /bitnami/etcd/data/db
ETCD_WAL_DIR: /bitnami/etcd/data/wal
x-etcd-base: &_x-etcd-base
image: docker.io/bitnami/etcd:3
entrypoint: ["/etcd-entrypoint.sh", "/opt/bitnami/scripts/etcd/entrypoint.sh"]
command: ["/opt/bitnami/scripts/etcd/run.sh"]
user: root
restart: always
x-root-cert-volume: &_x-root-cert-volume
type: bind
source: ${CONTEXT_DIR}/certs/root.crt
target: /etc/ssl/certs/root.crt
read_only: true
bind:
create_host_path: false
x-kubelet-volume: &_x-kubelet-volume
type: volume
target: /var/lib/kubelet
# volume:
# propagation: shared
x-registries-yaml-volume: &_x-registries-yaml-volume
type: bind
source: ${APISERVER_DIR}/etc/registries.yaml
target: /etc/rancher/k3s/registries.yaml
read_only: true
bind:
create_host_path: false
x-k3s-master-env: &_x-k3s-master-env
K3S_KUBECONFIG_OUTPUT: /output/kubeconfig.yaml
K3S_KUBECONFIG_MODE: "666"
K3S_NODE_NAME: master
x-k3s-master-base: &_x-k3s-master-base
<<: *_x_extra_hosts
image: "docker.io/rancher/k3s:${K3S_VERSION:-latest}"
networks:
default:
aliases:
- k3s-master
tmpfs:
- /run
- /var/run
ulimits:
nproc: 65535
nofile:
soft: 65535
hard: 65535
privileged: true
restart: always
ports:
- 6443
environment:
<<: *_x-k3s-master-env
volumes:
- server:/var/lib/rancher/k3s/server
- output:/output
- ${APP_ROOT_DIR?Please set APP_ROOT_DIR}:${APP_ROOT_MOUNT?Please set APP_ROOT_MOUNT(where to mount $PWD)}
# - *_x-registries-yaml-volume
- *_x-root-cert-volume
- *_x-kubelet-volume
x-coredns-base: &_x-coredns-base
image: docker.io/coredns/coredns
command: ['-conf', '/etc/coredns/Corefile']
restart: always
volumes:
- server:/var/lib/rancher/k3s/server
- output:/output
- ${APISERVER_DIR}/etc/coredns:/etc/coredns:ro
networks:
default:
nginx:
name: nginx
external: true
services:
etcd1:
<<: *_x-etcd-base
environment:
<<: *_x-etcd-environment
ETCD_NAME: etcd1
ETCD_INITIAL_ADVERTISE_PEER_URLS: http://etcd1:2380
ETCD_ADVERTISE_CLIENT_URLS: http://etcd1:2379
volumes:
- ${APISERVER_DIR}/scripts/etcd-entrypoint.sh:/etcd-entrypoint.sh:ro
- etcd1-data:/bitnami/etcd/data
etcd2:
<<: *_x-etcd-base
environment:
<<: *_x-etcd-environment
ETCD_NAME: etcd2
ETCD_INITIAL_ADVERTISE_PEER_URLS: http://etcd2:2380
ETCD_ADVERTISE_CLIENT_URLS: http://etcd2:2379
volumes:
- ${APISERVER_DIR}/scripts/etcd-entrypoint.sh:/etcd-entrypoint.sh:ro
- etcd2-data:/bitnami/etcd/data
etcd3:
<<: *_x-etcd-base
environment:
<<: *_x-etcd-environment
ETCD_NAME: etcd3
ETCD_INITIAL_ADVERTISE_PEER_URLS: http://etcd3:2380
ETCD_ADVERTISE_CLIENT_URLS: http://etcd3:2379
volumes:
- ${APISERVER_DIR}/scripts/etcd-entrypoint.sh:/etcd-entrypoint.sh:ro
- etcd3-data:/bitnami/etcd/data
k3s-master-1:
<<: *_x-k3s-master-base
command: [
"server",
"--disable=traefik,coredns,local-storage",
"--node-taint", "node-role.kubernetes.io/master=true:NoSchedule",
"--datastore-endpoint=http://etcd1:2379",
"--cluster-init",
]
environment:
<<: *_x-k3s-master-env
K3S_NODE_NAME: master-1
k3s-master-2:
<<: *_x-k3s-master-base
command: [
"server",
"--disable=traefik,coredns,local-storage",
"--node-taint", "node-role.kubernetes.io/master=true:NoSchedule",
"--datastore-endpoint=http://etcd2:2379",
"--server=http://k3s-master-1:6443",
]
environment:
<<: *_x-k3s-master-env
K3S_NODE_NAME: master-2
k3s-master-3:
<<: *_x-k3s-master-base
command: [
"server",
"--disable=traefik,coredns,local-storage",
"--node-taint", "node-role.kubernetes.io/master=true:NoSchedule",
"--datastore-endpoint=http://etcd3:2379",
"--server=http://k3s-master-1:6443",
]
environment:
<<: *_x-k3s-master-env
K3S_NODE_NAME: master-3
k3s-coredns-1:
<<: *_x-coredns-base
k3s-coredns-2:
<<: *_x-coredns-base
k3s-coredns-3:
<<: *_x-coredns-base
volumes:
etcd1-data:
etcd2-data:
etcd3-data:
server: {}
output: {}
local-path-provisioner: