k3s详细安装+rancher2.7界面展示
k3s详细安装+rancher2.7界面展示
实验环境
注:这里是arm版本,使用的M1安装的ubuntu虚拟机,其他版本需要找对应的版本
选择k3s版本并安装
使用版本号:v1.23.14+k3s1
# 因为使用1.25不支持helm chart
root@hao:~# helm install rancher rancher-latest/rancher \
> --namespace cattle-system \
> --set hostname=172.16.190.100.sslip.io \
> --set replicas=1 \
> --set bootstrapPassword=jshebuebyxg45h3
Error: INSTALLATION FAILED: chart requires kubeVersion: < 1.25.0-0 which is incompatible with Kubernetes v1.25.4+k3s1
一行命令即可安装,等待大约一分钟左右
curl -sfL https://get.k3s.io | INSTALL_K3S_VERSION=v1.23.14+k3s1 sh -
出现下边的提示,表示k3s安装已经八九不离十了
root@hao:~# curl -sfL https://get.k3s.io | INSTALL_K3S_VERSION=v1.23.14+k3s1 sh -
[INFO] Using v1.23.14+k3s1 as release
[INFO] Downloading hash https://github.com/k3s-io/k3s/releases/download/v1.23.14+k3s1/sha256sum-arm64.txt
[INFO] Downloading binary https://github.com/k3s-io/k3s/releases/download/v1.23.14+k3s1/k3s-arm64
[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] Skipping /usr/local/bin/ctr symlink to k3s, command exists in PATH at /usr/bin/ctr
[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] systemd: Starting k3s
拷贝配置文件到当前机器:
scp root@172.16.190.100:/etc/rancher/k3s/k3s.yaml ~/.kube/config
本机可以直接cp
cp /etc/rancher/k3s/k3s.yaml ~/.kube/config
下载helm
wget https://get.helm.sh/helm-v3.10.2-linux-arm64.tar.gz
解压并复制到指定路径
tar -zxvf helm-v3.10.2-linux-arm64.tar.gz
cp linux-arm64/helm /usr/bin/
查看helm版本
root@hao:~# helm version
version.BuildInfo{Version:"v3.10.2", GitCommit:"50f003e5ee8704ec937a756c646870227d7c8b58", GitTreeState:"clean", GoVersion:"go1.18.8"}
更新helm相关配置
helm repo add rancher-latest https://releases.rancher.com/server-charts/latest
kubectl create namespace cattle-system
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.7.1/cert-manager.crds.yaml
helm repo add jetstack https://charts.jetstack.io
helm repo update
helm install cert-manager jetstack/cert-manager \
--namespace cert-manager \
--create-namespace \
--version v1.7.1
# Windows Powershell
helm install cert-manager jetstack/cert-manager `
--namespace cert-manager `
--create-namespace `
--version v1.7.1
出现以下界面表示helm更新成功
root@hao:~# helm repo add rancher-latest https://releases.rancher.com/server-charts/latest
"rancher-latest" already exists with the same configuration, skipping
root@hao:~# kubectl create namespace cattle-system
namespace/cattle-system created
root@hao:~# kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.7.1/cert-manager.crds.yaml
customresourcedefinition.apiextensions.k8s.io/certificaterequests.cert-manager.io created
customresourcedefinition.apiextensions.k8s.io/certificates.cert-manager.io created
customresourcedefinition.apiextensions.k8s.io/challenges.acme.cert-manager.io created
customresourcedefinition.apiextensions.k8s.io/clusterissuers.cert-manager.io created
customresourcedefinition.apiextensions.k8s.io/issuers.cert-manager.io created
customresourcedefinition.apiextensions.k8s.io/orders.acme.cert-manager.io created
root@hao:~# helm repo add jetstack https://charts.jetstack.io
"jetstack" already exists with the same configuration, skipping
root@hao:~# helm repo update
Hang tight while we grab the latest from your chart repositories...
...Successfully got an update from the "jetstack" chart repository
...Successfully got an update from the "rancher-latest" chart repository
Update Complete. ⎈Happy Helming!⎈
使用helm安装rancher2.7
helm install rancher rancher-latest/rancher \
--namespace cattle-system \
--set hostname=172.16.190.100.sslip.io \
--set replicas=1 \
--set bootstrapPassword=jshebuebyxg45h3
出现下面提示就表示安装成功了
NAME: rancher
LAST DEPLOYED: Sat Dec 3 09:12:02 2022
NAMESPACE: cattle-system
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
Rancher Server has been installed.
NOTE: Rancher may take several minutes to fully initialize. Please standby while Certificates are being issued, Containers are started and the Ingress rule comes up.
Check out our docs at https://rancher.com/docs/
If you provided your own bootstrap password during installation, browse to https://172.16.190.100.sslip.io to get started.
If this is the first time you installed Rancher, get started by running this command and clicking the URL it generates:
```
echo https://172.16.190.100.sslip.io/dashboard/?setup=$(kubectl get secret --namespace cattle-system bootstrap-secret -o go-template='{{.data.bootstrapPassword|base64decode}}')
```
To get just the bootstrap password on its own, run:
```
kubectl get secret --namespace cattle-system bootstrap-secret -o go-template='{{.data.bootstrapPassword|base64decode}}{{ "\n" }}'
```
Happy Containering!
root@hao:~# echo https://172.16.190.100.sslip.io/dashboard/?setup=$(kubectl get secret --namespace cattle-system bootstrap-secret -o go-template='{{.data.bootstrapPassword|base64decode}}')
https://172.16.190.100.sslip.io/dashboard/?setup=jshebuebyxg45h3
root@hao:~# kubectl get secret --namespace cattle-system bootstrap-secret -o go-template='{{.data.bootstrapPassword|base64decode}}{{ "\n" }}'
jshebuebyxg45h3
最后一步,因为是在内网,需要添加hosts才能正常访问
cat /etc/hosts
172.16.190.100 172.16.190.100.sslip.io
熟悉的界面出现了!ok大功告成!