k3s 速通
配置 ssh login
- Windows
sh
type $env:USERPROFILE\.ssh\id_rsa.pub | ssh ubuntu@43.154.121.203 "cat >>.ssh/authorized_keys"
- MacOS / Linux
sh
ssh-copy-id -i ~/.ssh/id_rsa.pub ubuntu@43.154.121.203
login test
sh
ssh ubuntu@43.154.121.203
install docker
shell
sudo apt install docker.io
docker 镜像加速
https://gist.github.com/y0ngb1n/7e8f16af3242c7815e7ca2f0833d3ea6
install docker-compose
- MacOS / Linux
shell
sudo curl -L "https://github.com/docker/compose/releases/download/v2.32.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
install k3s
shell
curl -sfL https://rancher-mirror.rancher.cn/k3s/k3s-install.sh | INSTALL_K3S_MIRROR=cn sh -
install helm
shell
curl -fsSL -o get_helm.sh https://files.m.daocloud.io/raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
chmod 700 get_helm.sh
./get_helm.sh
fix: Helm CMD Error: INSTALLATION FAILED: Kubernetes cluster unreachable: Get "http://localhost:8080/version": dial tcp 127.0.0.1:8080: connect: connection refused
临时解决
shell
export KUBECONFIG=/etc/rancher/k3s/k3s.yaml
编辑/etc/profile
vim /etc/profile
shell
export KUBECONFIG=/etc/rancher/k3s/k3s.yaml
source /etc/profile
添加 Helm 仓库并更新
- 添加 Rancher Helm 仓库:
shell
helm repo add rancher-latest https://releases.rancher.com/server-charts/latest
helm repo update
- create namespace
shell
kubectl create namespace cattle-system
kubectl describe pod rancher-55769c4668-5ldt2 -n cattle-system
- install cert-manager 安装 cert-manager,Rancher 需要它来处理证书:
shell
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.13.1/cert-manager.yaml
等待 cert-manager 部署完成
shell
kubectl get pods --namespace cert-manager
所有 Pod 都应处于 Running 状态。
- install rancher
shell
helm install rancher rancher-latest/rancher \
--namespace cattle-system \
--set hostname=rancher.pursue.pub
- uninstall rancher
shell
helm uninstall rancher -n cattle-system
shell
cat << 'EOF' > /etc/profile.d/k8s.sh
export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH"
export KUBECONFIG=/etc/rancher/k3s/k3s.yaml
source <(kubectl completion bash)
alias k=kubectl
complete -o default -F __start_kubectl k
EOF
source /etc/profile.d/k8s.sh