forked from canonical/microk8s
-
Notifications
You must be signed in to change notification settings - Fork 0
/
snapcraft.yaml
424 lines (393 loc) · 12 KB
/
snapcraft.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
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
name: microk8s
version-script: |
. build-scripts/set-env-variables.sh > /dev/null
echo $KUBE_VERSION
version: "latest"
summary: Kubernetes for workstations and appliances
description: |-
MicroK8s is a small, fast, secure, single node Kubernetes that installs on
just about any Linux box. Use it for offline development, prototyping,
testing, or use it on a VM as a small, cheap, reliable k8s for CI/CD. It's
also a great k8s for appliances - develop your IoT apps for k8s and deploy
them to MicroK8s on your boxes.
grade: stable
confinement: classic
base: core
apps:
microk8s:
command: microk8s.wrapper
daemon-etcd:
command: run-etcd-with-args
daemon: simple
daemon-flanneld:
command: run-flanneld-with-args
daemon: simple
daemon-containerd:
command: run-containerd-with-args
daemon: simple
daemon-apiserver:
command: run-with-config-args kube-apiserver
daemon: simple
daemon-apiserver-kicker:
command: apiservice-kicker
daemon: simple
daemon-cluster-agent:
command: run-cluster-agent-with-args
daemon: simple
daemon-controller-manager:
command: run-with-config-args kube-controller-manager
daemon: simple
daemon-scheduler:
command: run-with-config-args kube-scheduler
daemon: simple
daemon-kubelet:
command: run-with-config-args kubelet
daemon: simple
daemon-proxy:
command: run-with-config-args kube-proxy
daemon: simple
kubectl:
command: microk8s-kubectl.wrapper
completer: kubectl.bash
add-node:
command: microk8s-add-node.wrapper
join:
command: microk8s-join.wrapper
remove-node:
command: microk8s-remove-node.wrapper
leave:
command: microk8s-leave.wrapper
ctr:
command: microk8s-ctr.wrapper
inspect:
command: sudo SNAP_DATA=${SNAP_DATA} ${SNAP}/inspect.sh
enable:
command: microk8s-enable.wrapper
disable:
command: microk8s-disable.wrapper
start:
command: microk8s-start.wrapper
stop:
command: microk8s-stop.wrapper
status:
command: microk8s-status.wrapper
config:
command: microk8s-config.wrapper
reset:
command: microk8s-reset.wrapper
istioctl:
command: microk8s-istioctl.wrapper
linkerd:
command: microk8s-linkerd.wrapper
helm:
command: microk8s-helm.wrapper
helm3:
command: microk8s-helm3.wrapper
cilium:
command: microk8s-cilium.wrapper
juju:
command: microk8s-juju.wrapper
parts:
libnftnl:
plugin: autotools
source: https://www.netfilter.org/projects/libnftnl/files/libnftnl-1.0.9.tar.bz2
build-packages:
- libjansson-dev
- libmnl-dev
iptables:
after:
- libnftnl
source: https://www.netfilter.org/projects/iptables/files/iptables-1.6.1.tar.bz2
plugin: autotools
build-packages:
- bison
- flex
- libmnl-dev
- libnfnetlink-dev
- libnetfilter-conntrack3
- libnetfilter-conntrack-dev
configflags:
- "--disable-shared"
- "--enable-static"
prime: [ -bin/iptables-xml ]
containerd:
build-snaps: [go]
after: [iptables]
source: https://github.com/containerd/containerd
source-type: git
plugin: go
go-importpath: github.com/containerd/containerd
build-packages:
- btrfs-tools
- libseccomp-dev
override-build: |
set -eu
. $SNAPCRAFT_PROJECT_DIR/build-scripts/set-env-variables.sh
go version
export GOPATH=$(realpath ../go)
mkdir -p $SNAPCRAFT_PART_INSTALL/bin
# Build containerd
go get github.com/containerd/containerd
(
cd $GOPATH/src/github.com/containerd/containerd
git checkout ${CONTAINERD_COMMIT}
# building the btrfs driver can be disabled via the
# build tag no_btrfs, removing this dependency
make
)
cp $GOPATH/src/github.com/containerd/containerd/bin/* $SNAPCRAFT_PART_INSTALL/bin/
rm $SNAPCRAFT_PART_INSTALL/bin/containerd-stress
# Build runc
go get github.com/opencontainers/runc
(
cd $GOPATH/src/github.com/opencontainers/runc
git checkout ${RUNC_COMMIT}
make BUILDTAGS='seccomp apparmor'
)
cp $GOPATH/src/github.com/opencontainers/runc/runc $SNAPCRAFT_PART_INSTALL/bin/
# Assemble the snap
# snapcraftctl build
organize:
containerd/install/bin/*: bin/
stage-packages:
- libnss-myhostname
- libnss-resolve
- libnss-mymachines
- conntrack
- curl
- aufs-tools
- gawk
- sed
- socat
- grep
- jq
- libssl1.0.0
- coreutils
- hostname
- diffutils
- squashfs-tools
- tar
stage:
- -sbin/xtables-multi
- -sbin/iptables*
- -lib/xtables
cluster-agent:
plugin: python
python-version: python3
source: .
python-packages:
- flask
- PyYAML
stage-packages:
- python3-openssl
- openssl
- python3-requests
- gunicorn3
microk8s:
after: [containerd]
plugin: dump
build-attributes: [no-patchelf]
build-packages:
- make
- mercurial
- git
- rsync
- openssl
- file
- dpkg
stage-packages:
- libatm1
- net-tools
- util-linux
- zfsutils-linux
- iproute2
source: .
prime:
- -README*
- -installer*
- -tests*
- -docs*
- -build*
override-build: |
set -eux
. build-scripts/set-env-variables.sh
REMOVE_KUBE_SNAP_BINS=false
echo "Reached here"
if [ ! -e "${KUBE_SNAP_BINS}" ]; then
if [ -z "${KUBE_SNAP_BINS}" ]; then
REMOVE_KUBE_SNAP_BINS=true
. build-scripts/set-env-binaries-location.sh
fi
echo "Downloading binaries"
. build-scripts/fetch-other-binaries.sh
if [ -z "${KUBERNETES_COMMIT}" ]; then
echo "Downloading k8s binaries from upstream"
. build-scripts/fetch-k8s-binaries.sh
else
echo "Building k8s binaries"
. build-scripts/build-k8s-binaries.sh
fi
else
echo "Binaries provided in $KUBE_SNAP_BINS"
fi
echo "Setting default daemon configs"
cp -r $KUBE_SNAP_ROOT/microk8s-resources/default-args .
echo "Building certs"
cp -r $KUBE_SNAP_ROOT/microk8s-resources/certs .
cp -r $KUBE_SNAP_ROOT/microk8s-resources/certs-beta .
echo "Preparing cni"
mkdir -p opt/cni/bin/
cp $KUBE_SNAP_BINS/cni/* opt/cni/bin/
echo "Preparing flanneld"
mkdir -p opt/cni/bin/
cp $KUBE_SNAP_BINS/flanneld/flanneld opt/cni/bin/
echo "Preparing containerd"
cp $KUBE_SNAP_ROOT/microk8s-resources/containerd-profile .
echo "Preparing etcd"
cp $KUBE_SNAP_BINS/etcd/etcd .
cp $KUBE_SNAP_BINS/etcd/etcdctl .
echo "Preparing kube-apiserver"
cp $KUBE_SNAP_BINS/$KUBE_ARCH/kube-apiserver .
# Old versions will be pointing to these .csv files from inside their kube-apiserver config
# Keep them around for a couple of releases.
touch known_token.csv
cp $KUBE_SNAP_ROOT/microk8s-resources/basic_auth.csv .
echo "Preparing kube-controller-manager"
cp $KUBE_SNAP_BINS/$KUBE_ARCH/kube-controller-manager .
echo "Preparing kube-scheduler"
cp $KUBE_SNAP_BINS/$KUBE_ARCH/kube-scheduler .
echo "Preparing kubelet"
mkdir -p configs
cp $KUBE_SNAP_BINS/$KUBE_ARCH/kubelet .
echo "Preparing kube-proxy"
cp $KUBE_SNAP_BINS/$KUBE_ARCH/kube-proxy .
echo "Preparing kubelet"
cp $KUBE_SNAP_BINS/$KUBE_ARCH/kubectl .
echo "Preparing user config"
cp $KUBE_SNAP_ROOT/microk8s-resources/client.config.template .
echo "Creating commands and wrappers"
cp $KUBE_SNAP_ROOT/microk8s-resources/wrappers/* .
cp -r $KUBE_SNAP_ROOT/microk8s-resources/actions .
if [ "${ARCH}" = "arm64" ]
then
# Some actions are not available on arm64
# Nvidia support
rm "actions/enable.gpu.sh"
rm "actions/disable.gpu.sh"
rm "actions/gpu.yaml"
# Istio support
rm "actions/enable.istio.sh"
rm "actions/disable.istio.sh"
# Knative support
rm "actions/enable.knative.sh"
rm "actions/disable.knative.sh"
# Prometheus support
rm "actions/enable.prometheus.sh"
rm "actions/disable.prometheus.sh"
rm -rf "actions/prometheus"
# Fluentd support
rm "actions/enable.fluentd.sh"
rm "actions/disable.fluentd.sh"
rm -rf "actions/fluentd"
# Jeager support
rm "actions/enable.jaeger.sh"
rm "actions/disable.jaeger.sh"
rm -rf "actions/jaeger"
# Linkerd support
rm "actions/enable.linkerd.sh"
rm "actions/disable.linkerd.sh"
# Juju support
rm "actions/enable.juju.sh"
rm "actions/disable.juju.sh"
# Kubeflow support
rm "actions/enable.kubeflow.sh"
rm "actions/disable.kubeflow.sh"
else
# Knative support
echo "Preparing knative"
cp -r $KUBE_SNAP_BINS/knative-yaml ./actions/knative
fi
echo "Creating inspect hook"
cp $KUBE_SNAP_ROOT/scripts/inspect.sh .
# Add bash completion for microk8s kubectl.
./kubectl completion bash | sed "s/complete -o default -F __start_kubectl kubectl/complete -o default -F __start_kubectl microk8s kubectl/g" | sed "s/complete -o default -o nospace -F __start_kubectl kubectl/complete -o default -o nospace -F __start_kubectl kubectl/g" > kubectl.bash
./kubectl completion bash | sed "s/complete -o default -F __start_kubectl kubectl/complete -o default -F __start_kubectl microk8s.kubectl/g" | sed "s/complete -o default -o nospace -F __start_kubectl kubectl/complete -o default -o nospace -F __start_kubectl kubectl/g" > kubectl.bash
if $REMOVE_KUBE_SNAP_BINS; then
rm -rf "$KUBE_SNAP_BINS"
fi
snapcraftctl build
# Unfortunately we cannot add package repositories to our snaps
# https://forum.snapcraft.io/t/proposal-additional-package-sources/2199
# We handpick the debs we need.
# To update these debs add the repository
# Follow the instructions in https://github.com/NVIDIA/nvidia-docker and
# install the https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list repo.
# Use apt-cache show <package> to make sure
# a) the dockerd we ship in this snap is supported by nvidia-container-runtime
# b) the version dependencies of each package is met.
nvidia-runtime:
plugin: dump
source: https://nvidia.github.io/nvidia-container-runtime/ubuntu16.04/amd64/nvidia-container-runtime_2.0.0+docker18.06.1-1_amd64.deb
source-type: deb
override-build: |
set -eu
ARCH=$(dpkg --print-architecture)
if ! [ "${ARCH}" = "arm64" ]
then
snapcraftctl build
else
echo "Skipped"
fi
nvidia-runtime-hook:
plugin: dump
source: https://nvidia.github.io/nvidia-container-runtime/ubuntu16.04/amd64/nvidia-container-runtime-hook_1.4.0-1_amd64.deb
source-type: deb
override-build: |
set -eu
ARCH=$(dpkg --print-architecture)
if ! [ "${ARCH}" = "arm64" ]
then
snapcraftctl build
else
echo "Skipped"
fi
libnvidia:
plugin: dump
source: https://nvidia.github.io/libnvidia-container/ubuntu16.04/amd64/libnvidia-container1_1.0.0-1_amd64.deb
source-type: deb
override-build: |
set -eu
ARCH=$(dpkg --print-architecture)
if ! [ "${ARCH}" = "arm64" ]
then
snapcraftctl build
else
echo "Skipped"
fi
libnvidia-tools:
plugin: dump
source: https://nvidia.github.io/libnvidia-container/ubuntu16.04/amd64/libnvidia-container-tools_1.0.0-1_amd64.deb
source-type: deb
override-build: |
set -eu
ARCH=$(dpkg --print-architecture)
if ! [ "${ARCH}" = "arm64" ]
then
snapcraftctl build
else
echo "Skipped"
fi
juju:
plugin: dump
source: https://launchpad.net/juju/2.7/2.7.3/+download/juju-2.7.3-k8s.tar.xz
source-type: tar
organize:
juju: bin/juju
prime:
- bin/juju
slots:
microk8s-info:
interface: content
content: microk8s
source:
read: [$SNAP/.microk8s-info/microk8s]