我的需求是:
先不拉取代码,直接git 提交后,直接触发 k8s 的 yml 文件
是我哪里 对 drone 的理解错了吗????
.drone.yml
kind: pipeline
type: kubernetes
name: my-k8s
clone:
disable: true
steps:
- name: deploy
image: bitnami/kubectl:latest
volumes:
- name: nginx-path
path: /go/src/files
commands:
- rm -rf /root/.kube && cp -r .kube /root/.kube
- cd /go/src/files
- kubectl delete -f nginx.yml || true
- kubectl apply -f nginx.yml
volumes:
- name: nginx-path
host:
path: /go/src/files
我的宿主机 /go/src/files 事先已经 放了 .kube/config 文件 和 nginx.yml 文件
nginx.yml 文件
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deploymenet
namespace: test
spec:
replicas: 3
selector:
matchLabels:
app: nginx #匹配 pod 标签 为 app: nginx 的 pod
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
name: nginx-sever
namespace: test
spec:
selector: #选择器
app: nginx
type: NodePort
ports:
- port: 5000
targetPort: 80
nodePort: 33000
[root@art files]# docker logs -f -n 30 drone-server
{"admin":true,"level":"info","login":"test12345","machine":false,"msg":"bootstrap: account created","time":"2023-11-04T17:10:56Z","token":"fyPUDkEdpgsILpbmnGSX2y1VaCrW3ThT"}
{"acme":false,"host":"192.168.2.115:9080","level":"info","msg":"starting the http server","port":":80","proto":"http","time":"2023-11-04T17:10:56Z","url":"http://192.168.2.115:9080"}
{"interval":"30m0s","level":"info","msg":"starting the cron scheduler","time":"2023-11-04T17:10:56Z"}
{"interval":"24h0m0s","level":"info","msg":"starting the zombie build reaper","time":"2023-11-04T17:10:56Z"}
[root@art files]# docker logs -f -n 30 drone-runner
time="2023-11-04T17:10:58Z" level=info msg="starting the server" addr=":3000"
time="2023-11-04T17:10:58Z" level=info msg="successfully pinged the remote server"
time="2023-11-04T17:10:58Z" level=info msg="polling the remote server" arch=amd64 capacity=2 endpoint="http://192.168.2.115:9080" kind=pipeline os=linux type=docker