aboutsummaryrefslogtreecommitdiff
path: root/gn/packages/kubernetes.scm
blob: 04c1048710cd9b3b55ce28b9879c681091e5566b (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
(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 build-system go)
  #:use-module (guix build-system trivial)
  #:use-module (gnu packages base)
  #:use-module (gnu packages compression)
  #:use-module (gnu packages rsync)
  )

(define-public kubernetes
  (package
    (name "kubernetes")
    (version "1.16.2")
    (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
                "1al6jvljscqg6j39rpm03sb33ns10pqz1j298bm3vispphbqx0j7"))))
    (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 _
             (with-directory-excursion "src/k8s.io/kubernetes"
               (substitute* '("build/root/Makefile"
                              "build/root/Makefile.generated_files"
                              "build/pause/Makefile")
                 (("/bin/bash") (which "bash"))))
             #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)))
    (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 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 url-fetch)
              (uri (string-append "https://github.com/kubernetes-sigs/cri-tools/releases/download/v" version "/crictl-v" version "-linux-amd64.tar.gz"))
              (sha256
               (base32
                "1l9s7g9ahpd1y5b5adanj25466bw2fxq6cspymcgxk0gf4hx9zhr"))))
    (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 "/crictl"))
                (tar     (assoc-ref %build-inputs "tar"))
                (gzip    (assoc-ref %build-inputs "gzip"))
                (source  (assoc-ref %build-inputs "source")))
           (setenv "PATH" (string-append gzip "/bin"))
           (invoke (string-append tar "/bin/tar") "xvf" source)
           (install-file "crictl" target))
         #t)))
    (native-inputs
     `(("gzip" ,gzip)
       ("tar" ,tar)))
    (home-page "")
    (synopsis "CLI and validation tools for Kubelet Container Runtime Interface")
    (description "")
    (supported-systems '("x86_64-linux"))
    (license license:asl2.0)))