forked from holman/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbb.edn
153 lines (133 loc) · 4.91 KB
/
bb.edn
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
{:tasks
{:requires ([babashka.fs :as fs]
[clojure.edn :as edn]
[clojure.string :as str])
install-cert-manager
{:task
(let [version "1.14.4"
url (format "https://github.com/cert-manager/cert-manager/releases/download/v%s/cert-manager.yaml"
version)]
(shell (format "kubectl apply -f %s" url)))}
list-secret-keys
{:description "List gpg secret keys"
:task (shell "gpg --list-secret-keys --keyid-format=long")}
make-chart-repo
{:description "Install repo into cluster"
:task
(do
(println "make chart repo")
(let [name ""
url ""
data {:apiVersion "catalog.cattle.io/v1"
:kind "ClusterRepo"
:metadata {:name name}
:spec {:url url}}]
data))}
read-windows-key
{:description "Read windows key from firmware"
:task
(shell "sudo grep -Eao '(-?[A-Z0-9]{5}){5}' /sys/firmware/acpi/tables/MSDM")}
switch-home
{:decription "Update home-manager from flake"
:task (shell "home-manager switch --flake /home/duck/dotfiles#duck --impure")}
switch-os
{:decription "Update nixos from flake"
:task (shell "sudo nixos-rebuild switch --flake /home/duck/dotfiles#nixos")}
k3d-create-registry
{:task
(shell "k3d registry create myregistry.localtest.me --port 12345")}
k3d-create
{:description "Create a k3d cluster"
:task
(let [dry-run? false
use-ingress false
create-registry? false
use-registry? true
api-port 6550
registry-name "registry"
registry-host "k3d-myregistry.localtest.me:12345"
server-count 1
cmd (clojure.string/join
" "
["k3d cluster create"
"--api-port" api-port
"-p \"80:80@loadbalancer\""
"-p \"443:443@loadbalancer\""
(when-not use-ingress "--k3s-arg \"--disable=traefik@server:0\"")
"--servers" server-count
(when create-registry?
(str "--registry-create " registry-name))
(when use-registry?
(str "--registry-use " registry-host))
"--kubeconfig-update-default"])]
(if dry-run?
(println cmd)
(shell cmd)))}
k3d-delete
{:description "Delete k3d cluster"
:task (shell "k3d cluster delete k3s-default")}
k3d-start
{:task (shell "k3d cluster start")}
k3d-stop
{:task (shell "k3d cluster stop")}
install-argocd
{:task
(do
(println "Installing argocd")
(let [dry-run? false
url "https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml"
commands ["kubectl create namespace argocd"
(str "kubectl apply -n argocd -f " url)]]
(doseq [command commands]
(if dry-run?
(println command)
(shell command)))))}
install-charts
{:task
(let [dry-run? false]
(doseq [{:keys [name url]} (edn/read-string (slurp "./helm_charts.edn"))]
(let [command (str "helm repo add " name " " url)]
(if dry-run?
(println (str "[DRY-RUN] " command))
(shell command)))))}
install-consul
{:task
(let [replicas 1
ingress-host "consul.localhost"]
(shell
(clojure.string/join
" "
["consul-k8s install "
(str "--set server.replicas=" replicas)
"--set ui.ingress.enabled=true "
(format "--set \"ui.ingress.hosts[0].host=%s\"" ingress-host)
"--set \"ui.ingress.hosts[0].paths[0]=/\""
"--set connectInject.enabled=true"
"--set connectInject.default=true"
"--set controller.enabled=true"])))}
install-rancher
{:task
(let [namespace "cattle-system"
hostname "rancher.dev.kronkltd.net"
email "[email protected]"
replica-count 1
cmd (clojure.string/join
" "
["helm install rancher rancher-latest/rancher "
(format "--namespace %s" namespace)
(format "--set hostname=%s" hostname)
(format "--set replicas=%s" replica-count)
(format "--set ingress.tls.source=%s" "letsEncrypt")
(format "--set letsEncrypt.email=%s" email)])]
(println cmd)
(shell cmd))}
install-traefik
{:task (shell "helm install traefik traefik/traefik")}
show-ports
{:task (shell "netstat -ltnp")}
update-nix
{:task (shell "nix-channel --update")}
watch-namespaces
{:task (shell "watch kubectl get namespaces")}
watch-pods
{:task (shell "watch kubectl get pods --all-namespaces")}}}