Skip to content

Commit 7b7b7d3

Browse files
committed
Merge branch 'master' into helm
2 parents 4cffd0d + 8c20ea8 commit 7b7b7d3

File tree

3 files changed

+67
-11
lines changed

3 files changed

+67
-11
lines changed

cmd/download.go

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,31 +30,51 @@ func DownloadCommand() cli.Command {
3030
},
3131
cli.StringSliceFlag{
3232
Name: "image",
33-
Usage: "Download an imgae list.\n rkd download --image busybox --image alpine",
33+
Usage: "Download an image list.\n rkd download --image busybox --image alpine",
3434
},
3535
cli.StringFlag{
3636
Name: "rancher",
3737
Usage: "Download Rancher images, rke and helm chart.\n rkd download --rancher v2.5.0",
3838
},
39+
cli.StringFlag{
40+
Name: "dest",
41+
Usage: "Set the name of the destination folder containing all downloaded componets (images, rancher images, rancher chart, ...), optional, a generic name will be set: datapack-YYY_MM_JJThh_mm_ss\n rkd download --rancher v2.5.0 --dest destFolder",
42+
},
43+
cli.StringFlag{
44+
Name: "imgarchname",
45+
Usage: "Set the name of the generated archive containing additionals images provided by --image flag, optional, default archive name is images.tar\n rkd download --rancher v2.5.0 --image busybox --imgarchname busybox.tar",
46+
},
3947
}
4048

4149
return cli.Command{
4250
Name: "download",
4351
Aliases: []string{"d"},
44-
Usage: "Downlaod helm chart list, container images and Rancher release",
52+
Usage: "Download helm chart list, container images and Rancher release",
4553
Action: DownloadDataPack,
4654
Flags: DownloadFlags,
4755
}
4856
}
4957

50-
// DownloadRancherRelease downlaod Rancher chart and images
58+
// DownloadDataPack downlaod Rancher chart and images
5159
func DownloadDataPack(c *cli.Context) {
5260

53-
dest := helpers.GenFileName("datapack")
61+
var dest string
62+
63+
if c.String("dest") != "" {
64+
dest = c.String("dest")
65+
} else {
66+
dest = helpers.GenFileName("datapack")
67+
}
5468
helpers.CreateDestDir(dest)
5569

5670
if len(c.StringSlice("image")) > 0 {
57-
destImg := fmt.Sprintf("%s/images.tar", dest)
71+
var destImg string
72+
73+
if c.String("imgarchname") != "" {
74+
destImg = fmt.Sprintf("%s/%s", dest, c.String("imgarchname"))
75+
} else {
76+
destImg = fmt.Sprintf("%s/images.tar", dest)
77+
}
5878
containers.DownloadImage(c.StringSlice("image"), destImg)
5979
}
6080

dockerfile

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
FROM ubuntu:20.04 AS builder
2+
3+
ENV ENV="/root/.bashrc" \
4+
TZ=Europe \
5+
EDITOR=vi \
6+
LANG=en_US.UTF-8
7+
8+
WORKDIR /go/src/rkd
9+
10+
COPY . /go/src/rkd/
11+
12+
ADD https://golang.org/dl/go1.15.2.linux-amd64.tar.gz /tmp
13+
14+
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone && \
15+
apt-get update && \
16+
apt-get install -y sudo git build-essential make libdevmapper-dev libgpgme-dev libostree-dev curl libassuan-dev libbtrfs-dev && \
17+
tar -C /usr/local -xzf /tmp/go1.15.2.linux-amd64.tar.gz && \
18+
rm /tmp/go1.15.2.linux-amd64.tar.gz && \
19+
ln -s /usr/local/go/bin/* /usr/local/bin/ && \
20+
go get && \
21+
GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o /go/src/rkd/rkd-linux-amd64
22+
23+
FROM debian:stretch-slim
24+
WORKDIR /go/bin/
25+
COPY --from='builder' /go/src/rkd/rkd-linux-amd64 /go/bin/rkd-linux-amd64
26+
COPY --from='builder' /go/src/rkd/policy.json /go/bin/
27+
COPY --from='builder' /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
28+
run apt update && \
29+
apt install -y libgpgme-dev libdevmapper-dev && \
30+
rm -rf /var/lib/apt/lists/*
31+
ENTRYPOINT ["/go/bin/rkd-linux-amd64"]

readme.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,28 @@ Num. Name - TagName
2121
```
2222

2323
## Download latest package
24-
To downlaod the package in order install a Rancher on Air Gapped environment (helm chart + images):
24+
To download the package in order install a Rancher on Air Gapped environment (helm chart + images):
2525

2626
```bash
27-
# Downlaod latest chart & images of rancher
28-
./rkd downlaod
27+
# download latest chart & images of rancher
28+
./rkd download
2929
```
3030

3131
```bash
32-
# Downlaod only busybox and alpine images
33-
./rkd downlaod --image busybox --image alpine
32+
# download only busybox and alpine images
33+
./rkd download --image busybox --image alpine
3434
```
3535

3636
```bash
37-
# Downlaod rancher v2.5.0 and alpine image
37+
# download rancher v2.5.0 and alpine image
3838
./rkd d --rancher v2.4.8 --image alpine
3939
```
4040

41+
```bash
42+
# download only busybox and alpine images in the specified directory
43+
./rkd download --image busybox --image alpine --dest myDirectory
44+
```
45+
4146
## Auth
4247
rkd uses Docker credential helpers to pull images from a registry.
4348

0 commit comments

Comments
 (0)