Giter Club home page Giter Club logo

cicd's Introduction

💻工程实践---后端作业(2021年12月)

📦题目:使用 Jenkins 构建服务的镜像,并将其发布到 Kubernetes 集群,要求整个 CICD 过程连贯,能够一键触发或提交代码之后自动触发执行。

📋要求:

1️⃣ 选择一个自己熟悉的后端服务项目, 也可以使用 https://github.com/shaowenchen/gin-hello-world
2️⃣ 选择 Pipeline 类型的流水线,使用 Jenkinsfile 文件定义流水线。
3️⃣ 应用在 Kubernetes 集群的相关对象,使用 Yaml 文件显式定义。
4️⃣ 根据要求的处理流程,画出各个组件之间的数据流关系,给出每个关键步骤执行成功时的日志或截图。
5️⃣ 配置和代码放在同一个地方(推荐 Git 仓库)进行版本管理。

✏️完成情况:

使用 Yaml 文件显式定义k8s集群。
构建服务镜像。Dockerfile。
部署服务到k8s集群。
使用Jenkins file 文件定义流水线。
画出各个组件之间的数据流关系。
每个关键步骤执行成功时的日志或截图。
定时触发执行。(使用 ⏰ Poll SCM)

🔧使用工具:

  • k3d- k3d is a lightweight wrapper to run k3s in docker.
  • kubectl - to interact with the Kubernetes cluster.
  • docker - to be able to use k3d at all
    • Note: k3d v5.x.x requires at least Docker v20.10.4 to work properly

🚀收获:

Docker Jenkins Kubernetes git GitHub k3d

Visual Studio Code

🔖 Dockerfile文件的编写。
🔖 Docker镜像的打包、使用、部署。
🔖 Jenkins的Pipeline使用、Poll SCM轮询。
🔖 使用k3d进行k8s的集群模拟。
🔖 使用kubectl命令进行部署、暴露服务。
🔖 使用Yaml文件显示定义k3d集群和deployment。
🔖 了解CICD过程中的概念。

📊可优化:

  1. 因为Docker没有部署私有仓库,所以使用kubectl命令部署时,需要将制作的Docker镜像手动导入到k3d的Node中,即pipeline中的:
sh "k3d image import -c go go-gin-img"
  1. Jenkins没有部署到有公网ip的服务器中,或者使用内网穿透工具,所以webhook暂时无法使用,只能使用 poll SCM 定时轮询查看github有没有更新代码。
  2. 😂...还有很多可以优化,流程写得太死。

📚参考:

  1. 如何在本地快速启动一个 K8S 集群 - https://zhuanlan.zhihu.com/p/357907926
  2. Kubernetes入门实践--部署运行Go项目 - https://zhuanlan.zhihu.com/p/152394424
  3. jenkins + pipeline构建自动化部署 - https://www.cnblogs.com/shenh/p/8963688.html
  4. Kubernetes Docs - https://kubernetes.io/zh/docs/home/
  5. K3D Docs - https://k3d.io/v5.2.2/usage/configfile/

cicd's People

Contributors

carlthenight avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.