aboutsummaryrefslogtreecommitdiff
path: root/gn/packages/kubernetes.scm
blob: e762895b987eff7d41dc673af2f54af59d3f6e6a (about) (plain)
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
(define-module (gn packages kubernetes)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (guix packages)
  #:use-module (guix git-download)
  #:use-module (guix download)
  #:use-module (guix utils)
  #:use-module (guix build-system go)
  #:use-module (guix build-system trivial)
  #:use-module (gnu packages base)
  #:use-module (gnu packages compression)
  #:use-module (gnu packages linux)
  #:use-module (gnu packages rsync))

(define-public kubernetes
  (package
    (name "kubernetes")
    (version "1.16.4")
    (source (origin
              (method git-fetch)
              (uri (git-reference
                     (url "https://github.com/kubernetes/kubernetes.git")
                     (commit (string-append "v" version))))
              (file-name (git-file-name name version))
              (sha256
               (base32
                "0snk4jr5is8rwx0px2kwx802dg770mrgp11irnwy2z50p327jrcs"))))
    (build-system go-build-system)
    (arguments
     `(#:import-path "k8s.io/kubernetes"
       #:install-source? #f
       #:tests? #f ; Skip tests for now.
       #:phases
       (modify-phases %standard-phases
         (add-after 'unpack 'make-files-writable
           (lambda _
             (for-each make-file-writable (find-files "."))
             #t))
         (add-before 'build 'prepare-build
           (lambda* (#:key inputs #:allow-other-keys)
             (with-directory-excursion "src/k8s.io/kubernetes"
               (substitute* '("build/root/Makefile"
                              "build/root/Makefile.generated_files"
                              "build/pause/Makefile")
                 (("/bin/bash") (which "bash")))
               (substitute* "pkg/util/mount/mount.go"
                 (("defaultMountCommand.*")
                  (string-append "defaultMountCommand = \""
                                 (assoc-ref inputs "util-linux")
                                 "/bin/mount\"\n"))))
             #t))
         (add-before 'build 'fix-version-numbers
           (lambda _
             (with-directory-excursion "src/k8s.io/kubernetes"
               (substitute* '("cmd/kubeadm/app/version/base.go"
                              "staging/src/k8s.io/client-go/pkg/version/base.go"
                              "staging/src/k8s.io/kubectl/pkg/version/base.go"
                              "staging/src/k8s.io/component-base/version/base.go"
                              "staging/src/k8s.io/component-base/metrics/version_parser_test.go"
                              "pkg/version/base.go"
                              "vendor/k8s.io/client-go/pkg/version/base.go"
                              "vendor/k8s.io/kubectl/pkg/version/base.go"
                              "vendor/k8s.io/component-base/metrics/version_parser_test.go")
                 (("v0.0.0-master\\+\\$Format:\\%h\\$") (string-append "v" ,version))
                 (("v0.0.0-master") (string-append "v" ,version))
                 (("gitMajor string = \"\"")
                  (string-append "gitMajor string = \"" ,(version-major version) "\""))
                 (("gitMinor string = \"\"")
                  (string-append "gitMinor string = \""
                                 ,(string-drop (version-major+minor version) 2) "\""))))
             #t))
         (replace 'build
           (lambda _
             (with-directory-excursion "src/k8s.io/kubernetes"
               ;; Cannot find go-bindata otherwise.
               (setenv "PATH" (string-append (getcwd) "/_output/bin:"
                                             (getenv "PATH")))
               (invoke "make"))))
         (replace 'install
           (lambda* (#:key outputs #:allow-other-keys)
             (let ((out (assoc-ref outputs "out")))
               (with-directory-excursion "src/k8s.io/kubernetes"
                 ;; This saves more than 350MiB.
                 (delete-file "_output/local/go/bin/e2e.test")
                 (delete-file "_output/local/go/bin/e2e_node.test")
                 (for-each
                   (lambda (file)
                     (install-file file (string-append out "/bin")))
                   (find-files "_output/local/go/bin" ".*"))
                 ;(mkdir-p (string-append out "/share/bash-completion/completions"))
                 ;(call-with-output-file (string-append out "/share/bash-completion/completions/kubectl")
                 ;  (lambda (port)
                 ;    (format port (invoke "_output/local/go/bin/kubectl" "completion" "bash"))))
                 ;(mkdir-p (string-append out "/share/zsh/site-function"))
                 ;(call-with-output-file (string-append out "/share/zsh/site-functions/_kubectl")
                 ;  (lambda (port)
                 ;    (format port (invoke "_output/local/go/bin/kubectl" "completion" "zsh"))))
                 (install-file "LICENSE"
                               (string-append out "/share/doc/"
                                              ,name "-" ,version)))
               #t)))
         (add-after 'install 'install-man-pages
           (lambda* (#:key outputs #:allow-other-keys)
             (let ((out (assoc-ref outputs "out")))
               (mkdir-p (string-append out "/share/man/man1"))
               (with-directory-excursion "src/k8s.io/kubernetes"
                 (for-each
                   (lambda (file)
                     (invoke "_output/local/go/bin/genman"
                             (string-append out "/share/man/man1") file))
                   '("kube-apiserver" "kube-controller-manager" "kube-proxy"
                     "kube-scheduler" "kubelet" "kubectl")))
               #t))))))
    (native-inputs
     `(("which" ,which)))
    (inputs
     `(("rsync" ,rsync)
       ("util-linux" ,util-linux)))
    (propagated-inputs
     `(("crictl" ,crictl))) ; Must be the same major+minor version as kubernetes.
    (home-page "https://kubernetes.io/")
    (synopsis "Production-Grade Container Scheduling and Management")
    (description "Kubernetes is an open source system for managing containerized
applications across multiple hosts.  It provides basic mechanisms for
deployment, maintenance, and scaling of applications.")
    (license license:asl2.0)))

(define-public kubernetes-1.15
  (package
    (inherit kubernetes)
    (name "kubernetes")
    (version "1.15.7")
    (source (origin
              (method git-fetch)
              (uri (git-reference
                     (url "https://github.com/kubernetes/kubernetes.git")
                     (commit (string-append "v" version))))
              (file-name (git-file-name name version))
              (sha256
               (base32
                "0xk5cx0ihvnfb3y6s0xhkfyb7a62dy2bkxsarq4wdis5nkc2jdim"))))
    (arguments
     (substitute-keyword-arguments (package-arguments kubernetes)
       ((#:phases phases)
        `(modify-phases ,phases
           (delete 'fix-version-numbers)))))
    (propagated-inputs
     `(("crictl" ,crictl-1.15)))))

(define-public kubernetes-1.14
  (package
    (inherit kubernetes-1.15)
    (name "kubernetes")
    (version "1.14.10")
    (source (origin
              (method git-fetch)
              (uri (git-reference
                     (url "https://github.com/kubernetes/kubernetes.git")
                     (commit (string-append "v" version))))
              (file-name (git-file-name name version))
              (sha256
               (base32
                "09p3w64f7spcj2mg1gw32g2mwjpii4zmpd2ychazdq7zrc85lxdq"))))
    (propagated-inputs
     `(("crictl" ,crictl-1.14)))))

(define-public kubernetes-1.13
  (package
    (inherit kubernetes-1.15)
    (name "kubernetes")
    (version "1.13.12")
    (source (origin
              (method git-fetch)
              (uri (git-reference
                     (url "https://github.com/kubernetes/kubernetes.git")
                     (commit (string-append "v" version))))
              (file-name (git-file-name name version))
              (sha256
               (base32
                "1drbd0qdj7pala78hda1aag2vq791sbk5a13c060a15d77ppnzwr"))))
    (propagated-inputs
     `(("crictl" ,crictl-1.13)))))

(define-public minikube
  (package
    (name "minikube")
    (version "1.5.2")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://github.com/kubernetes/minikube/"
                                  "releases/download/v"
                                  version "/" name "-linux-amd64"))
              (sha256
               (base32
                "1sgpb5k3i6g1slz9f6lvp4br5llgm2wcklpn2804hpp8dnlsjwhr"))))
    (build-system trivial-build-system)
    (arguments
     `(#:modules ((guix build utils))
       #:builder
       (begin
         (use-modules (guix build utils))
         (let* ((out     (assoc-ref %outputs "out"))
                (bin     (string-append out "/bin"))
                (target  (string-append bin "/minikube"))
                (source  (assoc-ref %build-inputs "source")))
           (mkdir-p bin)
           (copy-file source target)
           (chmod target #o555))
         #t)))
    (home-page "https://minikube.sigs.k8s.io/")
    (synopsis "Run Kubernetes locally")
    (description "Minikube implements a local Kubernetes cluster.  Minikube's
primary goals are to be the best tool for local Kubernetes application
development and to support all Kubernetes features that fit.")
    (supported-systems '("x86_64-linux"))
    (license license:asl2.0)))

(define-public crictl
  (package
    (name "crictl")
    (version "1.16.1")
    (source (origin
              (method git-fetch)
              (uri (git-reference
                     (url "https://github.com/kubernetes-sigs/cri-tools.git")
                     (commit (string-append "v" version))))
              (file-name (git-file-name name version))
              (sha256
               (base32
                "0qsbqml7jlhf73hlpqrh10bidz4v219bi2m5xg7914dzi0mzm733"))))
    (build-system go-build-system)
    (arguments
     `(;#:import-path "github.com/kubernetes-sigs/cri-tools"
       #:install-source? #f
       #:tests? #f ; tests require 'framwork' from kubernetes
       #:phases
       (modify-phases %standard-phases
         (add-after 'unpack 'change-directory
           (lambda _
             (chdir "src") #t))
         (add-before 'build 'prepare-source
           (lambda* (#:key outputs #:allow-other-keys)
             (let ((out (assoc-ref outputs "out")))
               (substitute* "Makefile"
                 (("/usr/local") out)
                 (("^VERSION .*") (string-append "VERSION := " ,version "\n")))
               #t)))
         (replace 'build
           (lambda _
             (invoke "make")))
         ;(replace 'check
         ;  (lambda _
         ;    (invoke "make" "test-e2e")))
         (replace 'install
           (lambda* (#:key outputs #:allow-other-keys)
             (let ((out (assoc-ref outputs "out")))
               (setenv "BINDIR" (string-append out "/bin"))
               (invoke "make" "install")))))))
    (home-page "https://github.com/kubernetes-sigs/cri-tools")
    (synopsis "CLI and validation tools for Kubelet Container Runtime Interface")
    (description "Cri-tools aims to provide a series of debugging and validation
tools for Kubelet CRI.")
    (license license:asl2.0)))

(define-public crictl-1.15
  (package
    (inherit crictl)
    (name "crictl")
    (version "1.15.0")
    (source (origin
              (method git-fetch)
              (uri (git-reference
                     (url "https://github.com/kubernetes-sigs/cri-tools.git")
                     (commit (string-append "v" version))))
              (file-name (git-file-name name version))
              (sha256
               (base32
                "03fhddncwqrdyxz43m3bak9dlrsqzibqqja3p94nic4ydk2hry62"))))
    (arguments
     (substitute-keyword-arguments (package-arguments crictl)
       ((#:phases phases)
        `(modify-phases ,phases
           (replace 'build
             (lambda _
               (invoke "make" "windows"))) ; This is the correct invocation
           (add-after 'prepare-source 'update-version
             (lambda _
               (substitute* "Makefile"
                 (("^VERSION .*") (string-append "VERSION := " ,version "\n")))
               #t))
           (replace 'prepare-source
             (lambda* (#:key outputs #:allow-other-keys)
               (let ((out (assoc-ref outputs "out")))
                 (substitute* "Makefile"
                   (("/usr/local") out)
                   ;; So we can use 'make windows'.
                   ((".exe") "")
                   (("GOOS=windows") "CGO_ENABLED=0")
                   (("_output") "../bin"))
                 #t)))))))))

(define-public crictl-1.14
  (package
    (inherit crictl-1.15)
    (name "crictl")
    (version "1.14.0")
    (source (origin
              (method git-fetch)
              (uri (git-reference
                     (url "https://github.com/kubernetes-sigs/cri-tools.git")
                     (commit (string-append "v" version))))
              (file-name (git-file-name name version))
              (sha256
               (base32
                "0yzb2vpypf2psrmbaqfh1fw6nba5mzdqr99lkga1204xygs863by"))))
    (arguments
     (substitute-keyword-arguments (package-arguments crictl-1.15)
       ((#:phases phases)
        `(modify-phases ,phases
           (replace 'update-version
             (lambda _
               (substitute* "Makefile"
                 (("^VERSION .*") (string-append "VERSION := " ,version "\n")))
               #t))))))))

(define-public crictl-1.13
  (package
    (inherit crictl-1.15)
    (name "crictl")
    (version "1.13.0")
    (source (origin
              (method git-fetch)
              (uri (git-reference
                     (url "https://github.com/kubernetes-sigs/cri-tools.git")
                     (commit (string-append "v" version))))
              (file-name (git-file-name name version))
              (sha256
               (base32
                "0xq3fvarx1x2bjyg3cj2jh3vz4lghb5mw2hhqb8ylflr8phd22cx"))))
    (arguments
     (substitute-keyword-arguments (package-arguments crictl-1.15)
       ((#:phases phases)
        `(modify-phases ,phases
           (replace 'update-version
             (lambda _
               (substitute* "Makefile"
                 (("^VERSION .*") (string-append "VERSION := " ,version "\n")))
               #t))))))))