讓 Jenkins 老爺爺掌舵帶領開發者航向美好新世界

5a84ea9a0afaca03be45b87dde58e51c?s=47 Kyle Bai
September 26, 2020

讓 Jenkins 老爺爺掌舵帶領開發者航向美好新世界

5a84ea9a0afaca03be45b87dde58e51c?s=128

Kyle Bai

September 26, 2020
Tweet

Transcript

  1. @k2r2bai 讓 Jenkins 老爺爺掌舵 帶領開發者航向美好新世界 Kubernetes Summit 2020

  2. @k2r2bai About Me ⽩凱仁(Kyle Bai) • SRE at AMIS/MaiCoin. •

    AWS Container Hero. • Co-organizer of Cloud Native Taiwan User Group. • Interested in emerging technologies. • Top 3 Kubernetes contributor in Taiwan. https://k8s.devstats.cncf.io GitHub: kairen(k2r2.bai@gmail.com) Blog: https://k2r2bai.com
  3. @k2r2bai Kubernetes • Container orchestration. • Self-healing. • Horizontal scaling.

    • Service discovery and Load balancing. • Automated rollouts and rollbacks. • Secrets and conJguration management. • Storage orchestration. • ....
  4. @k2r2bai Jenkins • An open-source tool with great community suppoL.

    • 1000+ plugins. • Easy to install. • It is built with Java and hence, it is poLable to all the major plaUorms. • Anything you can customize. • Declarative Pipeline(Groovy script). • The Jrst project to graduate in the CD Foundation. • ...
  5. @k2r2bai Our services... Developer & Operator CEO/CTO/CxO

  6. @k2r2bai Developers Git Repository Commit/PR

  7. @k2r2bai Developers Git Repository Jenkins Commit/PR Trigger build

  8. @k2r2bai Developers Git Repository Jenkins Commit/PR Checkout Code and Load

    JenkinsGles Trigger build
  9. @k2r2bai Developers Git Repository Jenkins Commit/PR Checkout Code and Load

    JenkinsGles Run tests (unit, e2e, ...) Trigger build Run pipeline Runtime Agents Kubernetes Plugin For unit test, building, deploy
  10. @k2r2bai Jenkins plugin to run dynamic agents in a Kubernetes/Docker

    environment. The agent is essentially a pod. Can conJgure volumes, resources limit, namespaces … and more. h\ps://github.com/jenkinsci/kubernetes-plugin Runtime Agents Kubernetes Plugin
  11. @k2r2bai Runtime Agents Kubernetes Plugin

  12. @k2r2bai Jenkins Agent Pod jenkins-agent Docker dind Other Tools Runtime

    Pod Metadata and Spec Runtime Agents Kubernetes Plugin
  13. @k2r2bai Runtime Agents Kubernetes Plugin Jenkins Base Image v1.13.0 v1.14.2

    ... v2.3.0 v2.5.2 ...
  14. @k2r2bai Runtime Agents Kubernetes Plugin Jenkins Base Image v1.13.0 v1.14.2

    ... v2.3.0 v2.5.2 ... Use for deployment
  15. @k2r2bai

  16. @k2r2bai Runtime Agents Kubernetes Plugin How to save MONEY over

    time?
  17. @k2r2bai Runtime Agents Kubernetes Plugin Auto Scaling Groups Managed By

    Cluster Autoscaler Watch and List pod 1. Pods are in a pending state Max: 6 Desired: 3 Min: 0 MaxSize: 6 MinSize: 0
  18. @k2r2bai Runtime Agents Kubernetes Plugin Auto Scaling Groups Managed By

    Cluster Autoscaler Watch and List pod 1. Pods are in a pending state 2. Cluster Autoscaler requests node Max: 6 Desired: 4 Min: 0 MaxSize: 6 MinSize: 0
  19. @k2r2bai Runtime Agents Kubernetes Plugin Auto Scaling Groups Managed By

    Cluster Autoscaler Watch and List pod 1. Pods are in a pending state Max: 6 Desired: 4 Min: 0 2. Cluster Autoscaler requests node 3. New node in provisioned MaxSize: 6 MinSize: 0
  20. @k2r2bai Developers Git Repository Jenkins Commit/PR Checkout Code and Load

    JenkinsGles Run tests (unit, e2e, ...) Trigger build Run pipeline Runtime Agents Kubernetes Plugin Instance Agents EC2 Plugin For unit test, building, deploy For e2e, integration, ... , etc
  21. @k2r2bai Instance Agents Amazon EC2 plugin Allow Jenkins to staL

    agents on EC2 on demand, and kill them as they get unused. Can use EC2 Spot Instances for their Jenkins CI pipelines(Cost optimization). Instances are terminated when the idle timeout period expires. h\ps://github.com/jenkinsci/ec2-plugin
  22. @k2r2bai Instance Agents Amazon EC2 plugin

  23. @k2r2bai COPY AND PASTE!!

  24. @k2r2bai When something has changed... Repository Jenkins build Developer

  25. @k2r2bai A Repository B Jenkins build C D E F

    . . N
  26. @k2r2bai

  27. @k2r2bai Developer SRE/DevOps Engineer Keep our code DRY!!!

  28. @k2r2bai Jenkins Shared Library Package Prebuilt Image

  29. @k2r2bai

  30. @k2r2bai Package Prebuilt Image Jenkins Agent

  31. @k2r2bai Jenkins Shared Library

  32. @k2r2bai

  33. @k2r2bai

  34. @k2r2bai

  35. @k2r2bai

  36. @k2r2bai

  37. @k2r2bai

  38. @k2r2bai

  39. @k2r2bai

  40. @k2r2bai Multiversion (Conformance Test) Current version of our cluster Multi-node

    cluster
  41. @k2r2bai How do we implement this?

  42. @k2r2bai Bootstrapper Abstract Class Options Parser Class Setup() Reset() InstallAddons()

    getKubeletLog() cleanUp() handleSystemTimeout() checkNodes() checkPods()
  43. @k2r2bai Bootstrapper Abstract Class Options Parser Class Setup() Reset() InstallAddons()

    getKubeletLog() cleanUp() handleSystemTimeout() checkNodes() checkPods()
  44. @k2r2bai Options Parser kind(logLevel: 9, name: "e2e", image: "kindest/node:v1.19.0") {}

    kind --verbosity=9 --name="e2e" --image="kindest/node:v1.19.0"
  45. @k2r2bai Setup()

  46. @k2r2bai Reset()

  47. @k2r2bai InstallAddons() "kubectl apply -f <dir>"

  48. @k2r2bai Developers Git Repository Jenkins Commit/PR Publish reports (Coverage, ...)

    Checkout Code and Load JenkinsGles Run tests (unit, e2e, ...) Trigger build Run pipeline Runtime Agents Kubernetes Plugin Instance Agents EC2 Plugin For unit test, building, deploy For e2e, integration, ... , etc
  49. @k2r2bai Developers Git Repository Jenkins Commit/PR Publish reports (Coverage, ...)

    Checkout Code and Load JenkinsGles Run tests (unit, e2e, ...) Trigger build Run pipeline Runtime Agents Kubernetes Plugin Instance Agents EC2 Plugin Build Images (For deploy) Merged For unit test, building, deploy For e2e, integration, ... , etc
  50. @k2r2bai

  51. @k2r2bai

  52. @k2r2bai

  53. @k2r2bai =

  54. @k2r2bai Developers Git Repository Jenkins Commit/PR Publish reports (Coverage, ...)

    Checkout Code and Load JenkinsGles Run tests (unit, e2e, ...) Trigger build Run pipeline Runtime Agents Kubernetes Plugin Instance Agents EC2 Plugin Build Images (For deploy) Scan Images Merged For unit test, building, deploy For e2e, integration, ... , etc Success Check CVE reports
  55. @k2r2bai Or

  56. @k2r2bai Scanner Abstract Class Options Parser Class Scan() collectRepoL() WarningNG

    Plugin
  57. @k2r2bai Developers Git Repository Jenkins Commit/PR Publish reports (Coverage, ...)

    Checkout Code and Load JenkinsGles Run tests (unit, e2e, ...) Trigger build Run pipeline Runtime Agents Kubernetes Plugin Instance Agents EC2 Plugin Build Images (For deploy) Scan Images Merged For unit test, building, deploy For e2e, integration, ... , etc Success Check CVE reports Publish reports to Jenkins
  58. @k2r2bai

  59. @k2r2bai

  60. @k2r2bai Developers Git Repository Jenkins Commit/PR Publish reports (Coverage, ...)

    Checkout Code and Load JenkinsGles Run tests (unit, e2e, ...) Trigger build Run pipeline Runtime Agents Kubernetes Plugin Instance Agents EC2 Plugin Build Images (For deploy) Scan Images Merged For unit test, building, deploy For e2e, integration, ... , etc Success Push images Check CVE reports
  61. @k2r2bai

  62. @k2r2bai Developers Git Repository Jenkins Commit/PR Publish reports (Coverage, ...)

    Checkout Code and Load JenkinsGles Run tests (unit, e2e, ...) Trigger build Run pipeline Runtime Agents Kubernetes Plugin Instance Agents EC2 Plugin Build Images (For deploy) Scan Images Merged For unit test, building, deploy For e2e, integration, ... , etc Success Push images Check CVE reports Deploy Success kubectl helm . . .
  63. @k2r2bai kubectl

  64. @k2r2bai helm

  65. @k2r2bai Developers Git Repository Jenkins Commit/PR Publish reports (Coverage, ...)

    Checkout Code and Load JenkinsGles Run tests (unit, e2e, ...) Trigger build Run pipeline Runtime Agents Kubernetes Plugin Instance Agents EC2 Plugin Build Images (For deploy) Scan Images Merged For unit test, building, deploy For e2e, integration, ... , etc Success Push images Check CVE reports Deploy Success kubectl helm . . .
  66. @k2r2bai Developers Git Repository Jenkins Commit/PR Publish reports (Coverage, ...)

    Checkout Code and Load JenkinsGles Run tests (unit, e2e, ...) Trigger build Run pipeline Runtime Agents Kubernetes Plugin Instance Agents EC2 Plugin Build Images (For deploy) Scan Images Merged For unit test, building, deploy For e2e, integration, ... , etc Success Push images Check CVE reports Deploy Success kubectl helm . . . k8s API creds Git creds k8s API creds AWS creds Registry creds Registry creds
  67. @k2r2bai God mode

  68. @k2r2bai GitOps

  69. @k2r2bai GitOps is a way of implementing Continuous Deployment for

    cloud native applications. It focuses on a developer-centric experience when operating infrastructure, by using tools developers are already familiar with, including Git and Continuous Deployment tools. • The entire system described declaratively. • The canonical desired system state versioned in Git. • Approved changes that can be automatically applied to the system. • Software agents to ensure correctness and alert on divergence. GitOps
  70. @k2r2bai To start managing your cluster with GitOps workflows, the

    following must be in place: • The entire system described declaratively. • The canonical desired system state versioned in Git. • Approved changes that can be automatically applied to the system. • Software agents to ensure correctness and alert on divergence. Principles of GitOps
  71. @k2r2bai

  72. @k2r2bai

  73. @k2r2bai

  74. @k2r2bai

  75. @k2r2bai

  76. @k2r2bai The pull request (PR) is the foundation of Jenkins

    X CI/CD pipeline execution. In PRs, Jenkins X allows developers and reviewers to: • Verify changes. • Review PR code changes and their effects. • Approve or deny PRs or suggest changes. • Approve PRs and trigger automatic merge and promotion. • Manual promotion of PRs to production environments and software releases. ChatOps
  77. @k2r2bai

  78. @k2r2bai Kubernetes Summit Kyle Bai k2r2.bai@gmail.com THANKS YOU! We’re Hiring!!

    hips://www.cakeresume.com/companies/