This commit is contained in:
孙小云 2025-09-10 20:10:20 +08:00
parent 8e67c01540
commit 0d7a853a9d
3 changed files with 39 additions and 1 deletions

View File

@ -26,3 +26,35 @@ roleRef:
kind: Role
name: drone
---
# Grant the pipeline SA cross-namespace permissions to manage Deployments and Services
# and to read/create Namespaces when needed.
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: drone-deployer
rules:
- apiGroups: [""]
resources: ["namespaces"]
verbs: ["get","list","watch","create"]
- apiGroups: ["apps"]
resources: ["deployments"]
verbs: ["get","list","watch","create","update","patch"]
- apiGroups: [""]
resources: ["services"]
verbs: ["get","list","watch","create","update","patch"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: drone-deployer-binding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: drone-deployer
subjects:
- kind: ServiceAccount
name: drone-pipeline
namespace: default

View File

@ -6,6 +6,9 @@ echo "创建Drone数据目录..."
sudo mkdir -p /opt/drone/data
sudo chown -R 1000:1000 /opt/drone
kubectl create ns dev;
kubectl create ns test;
kubectl create ns prod
# 应用所有yaml文件
kubectl apply -f drone-pipeline-serviceaccount.yaml
kubectl apply -f drone-runner-rbac.yaml

View File

@ -5,6 +5,8 @@ curl -sfL https://rancher-mirror.rancher.cn/k3s/k3s-install.sh | INSTALL_K3S_MIR
sudo chmod 644 /etc/rancher/k3s/k3s.yaml
sudo chown th:th /etc/rancher/k3s/k3s.yaml
4:导入镜像
# 1. 先用 Docker 导入镜像
docker load -i k3s-airgap-images-amd64.tar.gz
@ -15,3 +17,4 @@ docker images
sudo systemctl restart k3s
# 验证结果
kubectl get pods -A