Files
oc-k8s/internal/k3s.go

34 lines
787 B
Go
Raw Normal View History

2026-01-07 16:56:27 +01:00
package internal
import (
"fmt"
"oc-k8s/utils"
)
func Help_K3S() {
fmt.Println(`
K3S commands: oc-k8s <action> k3s
install - Install k3s
help - Show this help message
Usage:
oc-k8s install k3s
oc-k8s help values `)
}
func Install_K3S() error {
utils.Exec("sudo /usr/local/bin/k3s-uninstall.sh")
2026-01-08 21:15:34 +01:00
utils.Exec("sudo rm -rf /etc/rancher /var/lib/rancher")
2026-01-07 16:56:27 +01:00
if err := utils.Exec("curl -sfL https://get.k3s.io | sh -s - --write-kubeconfig-mode 644"); err != nil {
return err
}
2026-01-08 21:15:34 +01:00
utils.Exec("yes | sudo cp -rf /etc/rancher/k3s/k3s.yaml ~/.kube/config")
utils.Exec("chmod 700 /home/mr/.kube")
utils.Exec("sudo chmod 600 ~/.kube/config")
2026-01-07 16:56:27 +01:00
if err := utils.Exec("sudo systemctl status k3s"); err != nil {
return err
}
2026-01-08 21:15:34 +01:00
return utils.Exec("chmod 600 ~/.kube/config")
2026-01-07 16:56:27 +01:00
}