Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to package and deploy Drone in kubernetes environment

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "how to package and deploy Drone in the kubernetes environment". In the daily operation, I believe many people have doubts about how to package and deploy Drone in the kubernetes environment. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the questions of "how to package and deploy Drone in the kubernetes environment". Next, please follow the editor to study!

1. Drone is an open source CI automatic build platform developed using Go. Native Docker is supported, and so is kubernetes. Drone is faster, simpler and lighter than argo and tekton. Drone cloud native concept + 1, do a lot of things do not have to consider + 1 Magi Gitlabip GitHub can see the build results + 1

Environment: kubernetes 1.18, helm3 reference official

Https://github.com/drone/charts

Https://docs.drone.io/server/provider/gitlab/

Create namespace and add warehouse

Kubectl create ns dronehelm repo add drone https://charts.drone.iohelm repo update

Create an OAuth application in gitlab. Redirect URI is the address of drone plus a / login, authorizing two api, read_user

Add a file drone-server-overrides.yaml. The traefik used here. A database link is required. Sqllite is used by default. In this case, postgres is used.

Image: tag: 1.10.1ingress: enabled: true annotations: traefik.ingress.kubernetes.io/router.tls: "true" traefik.ingress.kubernetes.io/router.entrypoints: websecure traefik.ingress.kubernetes.io/router.tls.certresolver: aliyun traefik.ingress.kubernetes.io/router.tls.domains.0.main: drone.your_domain.com hosts:-host: drone.your_domain.com paths:-"/" env : DRONE_SERVER_HOST: drone.your_domain.com:31000 DRONE_SERVER_PROTO: https # Update the existing and related gitlab account to admin permission If you need to restart pod, refer to https://docs.drone.io/server/user/admin/ DRONE_USER_CREATE: username:your_gitlab_username,admin:true # generate a DRONE_RPC_SECRET: c7a536a3af5e2809f3d0d34a71a13302 DRONE_GITLAB_CLIENT_ID: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx DRONE_GITLAB_CLIENT_SECRET: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx DRONE_GITLAB_SERVER: https://your_gitlab_url # oauth through openssl rand-hex 16 to verify the GitlabCertificate, if the verification fails Need to open # DRONE_GITLAB_SKIP_VERIFY: true DRONE_DATABASE_DRIVER: postgres DRONE_DATABASE_DATASOURCE: postgres://postgres:password@192.168.1.10:5433/drone?sslmode=disablepersistentVolume: enabled: false

Create drone server

Helm install-namespace drone\ server\ drone/drone\-f drone-server-overrides.yaml

Create a runner file drone-runner-kube-values.yaml

Image: tag: latestrbac: buildNamespaces:-droneenv: # kubernetes service name same as server DRONE_RPC_HOST: server-drone DRONE_RPC_SECRET: c7a536a3af5e2809f3d0d34a71a13302 DRONE_NAMESPACE_DEFAULT: drone

Run runner

Helm install-namespace drone\ drone-runner-kube\ drone/drone-runner-kube\-f drone-runner-kube-values.yaml

Check to see if pod is running

$kubectl get pods-n droneNAME READY STATUS RESTARTS AGEdrone-runner-kube-6554c9df64-2znff 1 3h26mserver-drone-647875c9f-t5bfx 1 Running 0 3h26mserver-drone-647875c9f-t5bfx 1 Running 0 3h31m

Resolve the domain name and access the exported Ingress. The first visit will jump to gitlab, requiring authorization

Create .drone.yml under the project. Drone docker plug-in reference

Kind: pipelinetype: kubernetesname: defaultsteps:- name: compile & build Image image: plugins/docker # Mount host docker volumes:-name: docker path: / var/run/docker.sock settings: repo: registry.your_registry.com:31000/your_project/test-ci registry: registry.your_registry.com:31000 mirror: https://hub-mirror.c.163.com username: username password: password # more Variable reference https://docs.drone.io/pipeline/environment/reference/ tags:-${DRONE_TAG=latest}-build-$ {DRONE_BUILD_NUMBER}-name: deploy to k8s image: jeessy/dron8s:0.4.0 settings: yaml:. / deployment-test.yaml image_addr: registry.your_registry.com:31000/your_project/$ {DRONE_REPO_NAME}: build-$ {DRONE_BUILD_NUMBER}

11.1 deployment-test.yaml

ApiVersion: v1kind: Namespacemetadata: name: {{.repo_namespace}}-apiVersion: apps/v1kind: Deploymentmetadata: name: {{.repo_name}} namespace: {{.repo_namespace}} spec: selector: matchLabels: app: {{. Repo_name}} replicas: 1 template: metadata: labels: app: {{.repo_name}} spec: imagePullSecrets:- Name: harbor-registry-secret containers:-name: {{repo_name}} image: {{.image_addr}} ports:-containerPort: 80---apiVersion: v1kind: Servicemetadata: name: {{.repo_name}}-svc namespace: {{.repo _ namespace}} spec: selector: app: {{.repo_name}} ports:-protocol: TCP port: 80 targetPort: 80 Murray # Private warehouse apiVersion: v1kind: Secretmetadata: name: harbor-registry-secret namespace: {{. Repo_namespace}} type: kubernetes.io/dockerconfigjsondata: .dockerconfigjson: xxxxx

Description: you can use pelotech/drone-helm3 or jeessy/dron8s to deploy to K8s. Both plug-ins have submitted code myself. Depending on the situation, the helm configuration is more complex. Personal promotion uses dron8s, which can be used in the cluster. There is no need to add kube_token https://github.com/bh90210/dron8s#in-cluster-use to drone.

Pelotech/drone-helm3 is a plug-in that connects helm and kubernetes. Through it, you can transfer the helm automatic department under the project to kubernetes. Refer to the official

Create a helm project using helm create test-ci and put it under the project. Modify the template under the templates folder according to the actual situation. Refer to the official tutorial

The picture shows the effect after operation.

At this point, the study on "how to package and deploy Drone in the kubernetes environment" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report