查看ip地址
shellip addr
shellssh [email protected]
shellsu root echo "pub key" >> ~/.ssh/authorized_keys
update依赖
shell//更新软件包列表 apt update //安装实际的软件包更新 apt upgrade
shellapt install curl -y
安装k3s
shellcurl -sfL https://get.k3s.io | K3S_KUBECONFIG_MODE="644" K3S_NODE_NAME="k8s-master-01" sh -s - [INFO] Finding release for channel stable [INFO] Using v1.28.7+k3s1 as release [INFO] Downloading hash https://github.com/k3s-io/k3s/releases/download/v1.28.7+k3s1/sha256sum-amd64.txt [INFO] Downloading binary https://github.com/k3s-io/k3s/releases/download/v1.28.7+k3s1/k3s [INFO] Verifying binary download [INFO] Installing k3s to /usr/local/bin/k3s [INFO] Skipping installation of SELinux RPM [INFO] Creating /usr/local/bin/kubectl symlink to k3s [INFO] Creating /usr/local/bin/crictl symlink to k3s [INFO] Creating /usr/local/bin/ctr symlink to k3s [INFO] Creating killall script /usr/local/bin/k3s-killall.sh [INFO] Creating uninstall script /usr/local/bin/k3s-uninstall.sh [INFO] env: Creating environment file /etc/systemd/system/k3s.service.env [INFO] systemd: Creating service file /etc/systemd/system/k3s.service [INFO] systemd: Enabling k3s unit Created symlink /etc/systemd/system/multi-user.target.wants/k3s.service → /etc/systemd/system/k3s.service. [INFO] Host iptables-save/iptables-restore tools not found [INFO] Host ip6tables-save/ip6tables-restore tools not found [INFO] systemd: Starting k3s
安装helm
https://helm.sh/docs/intro/install/
shellcurl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
安装dashbord
先让traefik可以代理https流量
/var/lib/rancher/k3s/server/manifests/traefik-config.yaml
yamlapiVersion: helm.cattle.io/v1 kind: HelmChartConfig metadata: name: traefik namespace: kube-system spec: valuesContent: |- globalArguments: - "--serversTransport.insecureSkipVerify=true" ports: psql: port: 5432 expose: true exposedPort: 5432 protocol: TCP
https://github.com/kubernetes/dashboard
bashexport KUBECONFIG=/etc/rancher/k3s/k3s.yaml
Add kubernetes-dashboard repository
shellhelm repo add kubernetes-dashboard https://kubernetes.github.io/dashboard/
Deploy a Helm Release named "kubernetes-dashboard" using the kubernetes-dashboard chart
shellhelm upgrade --install kubernetes-dashboard kubernetes-dashboard/kubernetes-dashboard --create-namespace --namespace kubernetes-dashboard
- 创建账户参考官网,博主可直接内网使用Kubernetes 资源清单
bashkubectl apply -f https://git.ooxo.cc/sonic/k8s/raw/branch/main/kubernetes-dashboard.yaml
获取token
shellkubectl get secret admin-user -n kubernetes-dashboard -o jsonpath={".data.token"} | base64 -d
安装storage
- https://docs.k3s.io/zh/storage#%E8%AE%BE%E7%BD%AE-longhorn
- https://github.com/longhorn/longhorn
- https://longhorn.io/docs/1.6.0/deploy/install/install-with-kubectl/
shellapt install open-iscsi -y
shellkubectl apply -f https://raw.githubusercontent.com/longhorn/longhorn/v1.6.0/deploy/longhorn.yaml
观察启动成功
shellhttps://longhorn.io/docs/1.6.0/deploy/install/install-with-kubectl/
配置 UI访问 https://git.ooxo.cc/sonic/yaml/raw/branch/main/longhorn.yaml