-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.ps1
153 lines (120 loc) · 3.58 KB
/
install.ps1
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
#!/usr/bin/pwsh
param (
[string] $domain = 'fuszenecker.eu',
[string] $cloudnsUrl4,
[string] $cloudnsUrl6
)
function Write-Step {
param (
[string] $text
)
Write-Host -ForegroundColor Green $text
}
function Install-Packages {
Write-Step "Installing packages..."
sudo apt install curl wget open-iscsi
}
function Install-K3s {
Write-Step "Installing K3s..."
curl -sfL https://get.k3s.io | sh -
Write-Step "Enabling K3s services..."
sudo systemctl enable k3s
Write-Step "Enabling K3s services..."
sudo systemctl start k3s
Write-Step "Copying Kubernetes config..."
mkdir -p ~/.kube
sudo cp /etc/rancher/k3s/k3s.yaml ~/.kube/config
sudo setfacl -m u:$(id -un):rw /etc/rancher/k3s/k3s.yaml
sudo chown $(id -un) ~/.kube/config
}
function Setup-ClouDNS {
Write-Step "Installing Certificate Manager..."
sudo setfacl -m u:$(id -un):rwx /etc/systemd/system
$contentService = @"
[Unit]
Description=Update IP in ClouDNS
Wants=ClouDNS.timer
[Service]
Type=oneshot
ExecStart=/usr/bin/wget -q $cloudnsUrl4
ExecStart=/usr/bin/wget -q $cloudnsUrl6
[Install]
WantedBy=multi-user.target
"@
Set-Content "/etc/systemd/system/ClouDNS.service" $contentService
$contentTimer = @"
[Unit]
Description=Update IP address in ClouDNS
Requires=ClouDNS.service
[Timer]
OnBootSec=15min
OnUnitActiveSec=4h
Unit=ClouDNS.service
[Install]
WantedBy=timers.target
"@
Set-Content "/etc/systemd/system/ClouDNS.timer" $contentTimer
sudo systemctl daemon-reload
sudo systemctl enable ClouDNS.service
sudo systemctl start ClouDNS.service
sudo systemctl enable ClouDNS.timer
sudo systemctl start ClouDNS.timer
}
function Install-Helm {
Write-Step "Installing Helm..."
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
}
function Install-CertificateManager {
Write-Step "Installing Certificate Manager..."
kubectl apply --wait -f https://github.com/cert-manager/cert-manager/releases/latest/download/cert-manager.yaml
$content = @"
apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
name: letsencrypt-prod
spec:
acme:
email: [email protected]
privateKeySecretRef:
name: letsencrypt-prod-key
server: https://acme-v02.api.letsencrypt.org/directory
solvers:
- http01:
ingress:
class: traefik
"@
Write-Output $content | kubectl apply --wait -f -
}
function Install-RancherUI {
helm repo add rancher-stable https://releases.rancher.com/server-charts/stable
helm repo update
kubectl create namespace cattle-system
helm install --wait rancher rancher-stable/rancher `
--namespace cattle-system `
--set hostname=rancher.$domain `
--set bootstrapPassword=admin `
--set ingress.tls.source=letsEncrypt `
--set [email protected] `
--set letsEncrypt.ingress.class=traefik
# Write-Host "DOMAIN: " $domain
# helm install --wait rancher rancher `
# --namespace cattle-system `
# --set hostname=rancher.$domain `
# --set bootstrapPassword=admin `
# --set ingress.tls.source=letsEncrypt `
# --set [email protected] `
# --set letsEncrypt.ingress.class=traefik
}
function Wait-Keypress {
Write-Host -NoNewLine 'Press any key to continue...';
$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown');
Write-Host " OK."
}
Install-Packages
Install-K3s
Setup-ClouDNS
Install-Helm
Wait-Keypress
Install-CertificateManager
Wait-Keypress
Install-RancherUI