Compare commits

...

19 Commits
0.1.3 ... main

Author SHA1 Message Date
ea7ca60477 [+] 更新 k3s 源
All checks were successful
Build Docker Image / Explore-Gitea-Actions (push) Successful in 1m55s
2025-04-11 13:47:39 +08:00
9af73a40ca [+] 修改 login 账户
All checks were successful
Build Docker Image / Explore-Gitea-Actions (push) Successful in 10s
2025-04-11 13:32:44 +08:00
22848f01e7 [+] 更新构建源
Some checks failed
Build Docker Image / Explore-Gitea-Actions (push) Failing after 11s
2025-04-11 13:32:04 +08:00
a031b90da9 [+] 更新 Git 镜像源
Some checks failed
Build Docker Image / Explore-Gitea-Actions (push) Failing after 12m13s
2025-04-10 16:12:07 +08:00
2cdf1bf16d [+] 更新镜像源
All checks were successful
Build Docker Image / Explore-Gitea-Actions (push) Successful in 13s
2025-04-10 10:13:36 +08:00
3c6ce06ce6 fix vim
All checks were successful
Build Docker Image / Explore-Gitea-Actions (push) Successful in 20s
2025-04-09 09:48:08 +08:00
bffce05b53 [+] 更改 watch 顺序
Some checks failed
Build Docker Image / Explore-Gitea-Actions (push) Failing after 10m51s
2025-04-08 15:54:21 +08:00
97d3881bee [+] 更新 构建参数
Some checks are pending
Build Docker Image / Explore-Gitea-Actions (push) Waiting to run
2025-04-08 15:50:33 +08:00
6f59ff50e3 [+] 更新 token
All checks were successful
Build Docker Image / Explore-Gitea-Actions (push) Successful in 17s
2025-04-08 15:30:38 +08:00
ea93cbd1b9 [+] INSTALL_K3S_MIRROR=cn
Some checks failed
Build Docker Image / Explore-Gitea-Actions (push) Has been cancelled
2025-04-08 15:28:17 +08:00
3db6138e91 [+] 更新 bash
All checks were successful
Build Docker Image / Explore-Gitea-Actions (push) Successful in 13s
2025-04-08 15:27:00 +08:00
1e3d6cfcaa [+] 更新 bash
All checks were successful
Build Docker Image / Explore-Gitea-Actions (push) Successful in 13s
2025-04-08 15:24:51 +08:00
919511263f [+] 初始化 apt
All checks were successful
Build Docker Image / Explore-Gitea-Actions (push) Successful in 13s
2025-04-08 15:19:09 +08:00
b7e78c1b43 [+] 支持 etcd
All checks were successful
Build Docker Image / Explore-Gitea-Actions (push) Successful in 9s
2025-04-08 15:17:30 +08:00
c246adc39e [+] 支持 etcd
All checks were successful
Build Docker Image / Explore-Gitea-Actions (push) Successful in 18s
2025-04-08 15:16:14 +08:00
9876eeb491 [+] 更新 k3s 脚本
All checks were successful
Build Docker Image / Explore-Gitea-Actions (push) Successful in 15s
2025-04-08 14:35:25 +08:00
f3e2fe88d5 [+] node-external-ip 声明节点VIP
All checks were successful
Build Docker Image / Explore-Gitea-Actions (push) Successful in 14s
2025-04-08 11:21:37 +08:00
a593dea13c [+] add k3s
All checks were successful
Build Docker Image / Explore-Gitea-Actions (push) Successful in 17s
2025-04-08 11:18:31 +08:00
6535e48260 [+] add k3s
All checks were successful
Build Docker Image / Explore-Gitea-Actions (push) Successful in 20s
2025-04-08 10:57:46 +08:00
5 changed files with 121 additions and 10 deletions

View File

@ -14,9 +14,9 @@ jobs:
- name: Log in to Docker Hub
uses: https://git.martin98.com/actions/login-action.git@v3
with:
registry: ${{ vars.DOCKER_HUB }}
username: ${{ vars.DOCKER_USERNAME }}
password: ${{ vars.DOCKER_PASSWORD }}
registry: ${{ vars.GIT_IMAGE_URL }}
username: ${{ vars.GIT_IMAGE_USERNAME }}
password: ${{ vars.GIT_IMAGE_PASSWORD }}
- name: Build and push
uses: https://git.martin98.com/actions/build-push-action.git@v4
@ -25,5 +25,5 @@ jobs:
platforms: linux/amd64
push: true
tags: |
docker.martin98.com/martin_farm/init:latest
docker.martin98.com/martin_farm/init:${{ github.sha }}
git.martin98.com/martinfarm/init:latest
git.martin98.com/martinfarm/init:${{ github.sha }}

View File

@ -1,3 +1,9 @@
## k3s
> https://docs.k3s.io/zh/quick-start
```bash
curl -sfL https://rancher-mirror.rancher.cn/k3s/k3s-install.sh | INSTALL_K3S_MIRROR=cn sh -
```
## k8s 快速部署
```bash
# 网段配置

View File

@ -45,8 +45,6 @@ else
fi
# fix vim 粘贴
if pidof vim >/dev/null 2>&1; then
if ! grep -q "set pastetoggle=" ~/.vimrc; then
echo "set pastetoggle=" >> ~/.vimrc
fi
if ! grep -q "set pastetoggle=" ~/.vimrc; then
echo "set pastetoggle=" >> ~/.vimrc
fi

View File

@ -5,7 +5,7 @@ if command -v git > /dev/null 2>&1; then
echo "git 已安装,正在配置镜像源..."
# 曾经设置过的强制取消
git config --global --unset url."https://git-proxy.hk.martin98.com/".insteadOf
git config --global url."https://git-proxy.hk.martin98.com/https://github.com/".insteadOf "https://github.com/"
git config --global url."https://git.mirrors.martin98.com/https://github.com/".insteadOf "https://github.com/"
echo "镜像源配置完成。"
else
echo "git 不存在,跳过..."

107
init-k3s.sh Normal file
View File

@ -0,0 +1,107 @@
#!/bin/bash
curl -sSL https://git.martin98.com/MartinFarm/init/raw/branch/main/init-apt.sh | bash
current_ip=$(hostname -I | awk '{print $1}')
# 镜像加速
mkdir /etc/rancher/k3s -p
cat <<EOF > /etc/rancher/k3s/registries.yaml
mirrors:
docker.io:
endpoint:
- https://docker.martin98.com
registry-1.docker.io:
endpoint:
- https://docker.martin98.com
registry.k8s.io:
endpoint:
- https://docker.martin98.com
k8s.gcr.io:
endpoint:
- https://docker.martin98.com
gcr.io:
endpoint:
- https://docker.martin98.com
ghcr.io:
endpoint:
- https://docker.martin98.com
quay.io:
endpoint:
- https://docker.martin98.com
EOF
# systemctl restart k3s
# 安装 keepalived
apt install -y keepalived
# 检查是否为 Master-01
if [ "$current_ip" == "$master" ]; then
state=MASTER
priority=100
else
state=BACKUP
priority=100
fi
# 初始化 VIP
mkdir /etc/keepalived
cat <<EOF | sudo tee /etc/keepalived/keepalived.conf
vrrp_instance VI_1 {
state $state
interface eth0
virtual_router_id 51
priority $priority
advert_int 1
virtual_ipaddress {
$vip
}
}
EOF
sudo systemctl restart keepalived
systemctl status keepalived &
# 检查是否为 Master-01
if [ "$current_ip" == "$master" ]; then
# 开始部署
curl -sfL https://rancher-mirror.rancher.cn/k3s/k3s-install.sh | INSTALL_K3S_MIRROR=cn sh -s - server \
--cluster-init \
--cluster-cidr $pod_subnet \
--service-cidr $service_subnet \
--node-external-ip=$vip_ip \
TOKEN=$(cat /var/lib/rancher/k3s/server/node-token)
cat <<EOF
------------------------------------------------------------------------------------
初始化 master VIP[$state] $current_ip 成功
export pod_subnet=$pod_subnet
export service_subnet=$service_subnet
export vip_ip=$vip_ip
export vip=$vip_ip/16
export master=$master
export TOKEN=$TOKEN
curl -sSL https://git.martin98.com/MartinFarm/init/raw/branch/main/init-k3s.sh | bash
------------------------------------------------------------------------------------
EOF
else
curl -sfL https://rancher-mirror.rancher.cn/k3s/k3s-install.sh | INSTALL_K3S_MIRROR=cn sh -s - server \
--cluster-cidr $pod_subnet \
--service-cidr $service_subnet \
--node-external-ip=$vip_ip \
--token $TOKEN \
--server https://$master:6443
watch kubectl get nodes
fi