Pipelines, Projekt Tekton und GitOps Next Generation CI/CD ...€¦ · Serverless CI/CD with no...

49
1 Next Generation CI/CD mit OpenShift Pipelines, Projekt Tekton und GitOps Daniel Brintzinger Senior Solution Architect Red Hat Sebastian Tiggelcamp DevOps Engineer Consol Ortwin Schneider Solution Architect Red Hat

Transcript of Pipelines, Projekt Tekton und GitOps Next Generation CI/CD ...€¦ · Serverless CI/CD with no...

Page 1: Pipelines, Projekt Tekton und GitOps Next Generation CI/CD ...€¦ · Serverless CI/CD with no single server to share and maintain Web, CLI, and Visual Studio Code and IDE plugins.

1

Next Generation CI/CD mit OpenShift Pipelines, Projekt Tekton und GitOps

Daniel BrintzingerSenior Solution ArchitectRed Hat

Sebastian TiggelcampDevOps EngineerConsol

Ortwin SchneiderSolution ArchitectRed Hat

Page 2: Pipelines, Projekt Tekton und GitOps Next Generation CI/CD ...€¦ · Serverless CI/CD with no single server to share and maintain Web, CLI, and Visual Studio Code and IDE plugins.

What we’ll discuss today

Agenda

2

Introduction to Project Tekton, OpenShift Pipelines & GitOps

Live Demo

Lessons Learned and Roadmap

Page 3: Pipelines, Projekt Tekton und GitOps Next Generation CI/CD ...€¦ · Serverless CI/CD with no single server to share and maintain Web, CLI, and Visual Studio Code and IDE plugins.

3

Introduction to Project Tekton, OpenShift Pipelines & GitOps

Page 4: Pipelines, Projekt Tekton und GitOps Next Generation CI/CD ...€¦ · Serverless CI/CD with no single server to share and maintain Web, CLI, and Visual Studio Code and IDE plugins.

CONFIDENTIAL Designator

4

What is CI/CD?

Page 5: Pipelines, Projekt Tekton und GitOps Next Generation CI/CD ...€¦ · Serverless CI/CD with no single server to share and maintain Web, CLI, and Visual Studio Code and IDE plugins.

GENERAL DISTRIBUTION

5

Continuous Integration and Continuous Delivery (CI/CD)

WHAT IS CI/CD?

Code Run Debug Build Int Test Package Deploy Stage

GIT COMMIT RELEASE

LOCAL DEVELOPMENT CONTINUOUS INTEGRATION CONTINUOUS DELIVERY

...

KubernetesKubernetes Kubernetes

Page 6: Pipelines, Projekt Tekton und GitOps Next Generation CI/CD ...€¦ · Serverless CI/CD with no single server to share and maintain Web, CLI, and Visual Studio Code and IDE plugins.

GENERAL DISTRIBUTION

6

What is Cloud-Native CI/CD?

Designed with microservices and distributed teams in mind

WHAT IS CI/CD?

ContainersBuilt for container apps and

runs on Kubernetes

ServerlessRuns serverless with no CI/CD

engine to manage and maintain

DevOps

Page 7: Pipelines, Projekt Tekton und GitOps Next Generation CI/CD ...€¦ · Serverless CI/CD with no single server to share and maintain Web, CLI, and Visual Studio Code and IDE plugins.

GENERAL DISTRIBUTION

Why Cloud-Native CI/CD?

WHAT IS CI/CD?

7

Traditional CI/CD Cloud-Native CI/CD

Designed for Virtual Machines Designed for Containers and Kubernetes

Require IT Ops for CI engine maintenance Pipeline as a service with no Ops overheard

Plugins shared across CI engine Pipelines fully isolated from each other

Plugin dependencies with undefined update cycles Everything lifecycled as container images

No interoperability with Kubernetes resources Native Kubernetes resources

Admin manages persistence Platform manages persistence

Config baked into CI engine container Configured via Kubernetes ConfigMaps

Page 8: Pipelines, Projekt Tekton und GitOps Next Generation CI/CD ...€¦ · Serverless CI/CD with no single server to share and maintain Web, CLI, and Visual Studio Code and IDE plugins.

GENERAL DISTRIBUTION

Why Cloud-Native CI/CD?

WHAT IS CI/CD?

8

Traditional CI/CD Cloud-Native CI/CD

Designed for Virtual Machines Designed for Containers and Kubernetes

Require IT Ops for CI engine maintenance Pipeline as a service with no Ops overheard

Plugins shared across CI engine Pipelines fully isolated from each other

Plugin dependencies with undefined update cycles Everything lifecycled as container images

No interoperability with Kubernetes resources Native Kubernetes resources

Admin manages persistence Platform manages persistence

Config baked into CI engine container Configured via Kubernetes ConfigMaps

Page 9: Pipelines, Projekt Tekton und GitOps Next Generation CI/CD ...€¦ · Serverless CI/CD with no single server to share and maintain Web, CLI, and Visual Studio Code and IDE plugins.

CONFIDENTIAL Designator

9

OpenShift Pipelines

Page 10: Pipelines, Projekt Tekton und GitOps Next Generation CI/CD ...€¦ · Serverless CI/CD with no single server to share and maintain Web, CLI, and Visual Studio Code and IDE plugins.

GENERAL DISTRIBUTION

10

OpenShift Pipelines

Kubernetes-native declarative

Pipelines with Tekton

Standard and portable to any

Kubernetes platform

Run pipelines in isolated containers with

all required dependencies

Serverless CI/CD with no single server

to share and maintain

Web, CLI, and Visual Studio Code and IDE

plugins

Page 11: Pipelines, Projekt Tekton und GitOps Next Generation CI/CD ...€¦ · Serverless CI/CD with no single server to share and maintain Web, CLI, and Visual Studio Code and IDE plugins.

GENERAL DISTRIBUTION

11

Governed by the Continuous Delivery FoundationContributions from Google, Red Hat, Cloudbees, IBM, Pivotal and many more

An open-source project for providing a set of shared and standard components for building Kubernetes-style CI/CD systems

OPENSHIFT PIPELINES

Page 12: Pipelines, Projekt Tekton und GitOps Next Generation CI/CD ...€¦ · Serverless CI/CD with no single server to share and maintain Web, CLI, and Visual Studio Code and IDE plugins.

GENERAL DISTRIBUTION

OpenShift Pipelines Architecture

OPENSHIFT PIPELINES

12

OpenShift

Dev Console

OpenShift Pipelines

Tekton CLI

Kubernetes

CI/CDCore

Developer Tools

CodeReady Workspaces(Eclipse Che)

Tekton Pipelines

IntegrationsExtensionsOperator

API

Visual Studio Code

Tasks

Page 13: Pipelines, Projekt Tekton und GitOps Next Generation CI/CD ...€¦ · Serverless CI/CD with no single server to share and maintain Web, CLI, and Visual Studio Code and IDE plugins.

GENERAL DISTRIBUTION

13

Tekton Concepts

TEKTON CONCEPTS

StepRun commands in a container

with volumes, env vars, etc

TaskA list of steps that run

sequentially in the same pod

PipelineA graph of tasks executed in

a certain order

Task RunAn invocation of a task with

inputs and outputs

Pipeline RunAn invocation of a pipeline

with inputs and outputs

ConditionAn check that can determine

if a task should be executed

Pipeline ResourceInputs and outputs to tasks

and pipelines (git, image, etc)

CatalogAn collection of reusable tasks

TriggersA Tekton sub-project to start

pipelines based on events

Page 14: Pipelines, Projekt Tekton und GitOps Next Generation CI/CD ...€¦ · Serverless CI/CD with no single server to share and maintain Web, CLI, and Visual Studio Code and IDE plugins.

GENERAL DISTRIBUTION

Steps

14

● Run command or script in a container

● Kubernetes container spec○ Env vars ○ Volumes○ Config maps○ Secrets

TEKTON CONCEPTS

- name: build

image: maven:3.6.0-jdk-8-slim

command: [“mvn”]

args: [“install”]

- name: parse-yaml

image: python3

script:|-

#!/usr/bin/env python3

...

Page 15: Pipelines, Projekt Tekton und GitOps Next Generation CI/CD ...€¦ · Serverless CI/CD with no single server to share and maintain Web, CLI, and Visual Studio Code and IDE plugins.

GENERAL DISTRIBUTION

Task

15

● Defines a unit of work to be executed

● A list of steps to run sequentially

● Step containers run in the task pod

● Has inputs, outputs and parameters

● Workspaces and results for sharing data

● Can run independent of pipelines

Task

Step

Step

Step

Step

TEKTON CONCEPTS

Example Tasks: Maven Install, AWS CLI, Kubectl Deploy, Security Scan, etc

Page 16: Pipelines, Projekt Tekton und GitOps Next Generation CI/CD ...€¦ · Serverless CI/CD with no single server to share and maintain Web, CLI, and Visual Studio Code and IDE plugins.

GENERAL DISTRIBUTION

16

Maven Task Example

kind: Task

metadata:

name: maven

spec:

params:

- name: goal

type: string

default: package

steps:

- name: mvn

image: maven:3.6.0-jdk-8-slim

command: [ mvn ]

args: [ $(params.goal) ]

Page 17: Pipelines, Projekt Tekton und GitOps Next Generation CI/CD ...€¦ · Serverless CI/CD with no single server to share and maintain Web, CLI, and Visual Studio Code and IDE plugins.

GENERAL DISTRIBUTION

Pipeline

18

● Define Tasks execution order (graph)

● Inputs and parameters

● Retries tasks

● Conditional task execution

● Workspaces for sharing data between tasks

● Reusable across projects

Pipeline

Task

Task

Task

Task

TEKTON CONCEPTS

Page 18: Pipelines, Projekt Tekton und GitOps Next Generation CI/CD ...€¦ · Serverless CI/CD with no single server to share and maintain Web, CLI, and Visual Studio Code and IDE plugins.

GENERAL DISTRIBUTION

Sharing Data Between Tasks

TEKTON CONCEPTS

19

Task: results● Task exposes data as variables● Suitable for small pieces of data● Examples: commit id and branch name

Task: workspaces● Shared volumes between tasks

○ Persistent volumes○ Config maps○ Secrets

● Suitable for large data● Examples: code, binaries, reports

Pipeline

Task Task

/workspace/myw

PersistentVolumeClaim

Page 19: Pipelines, Projekt Tekton und GitOps Next Generation CI/CD ...€¦ · Serverless CI/CD with no single server to share and maintain Web, CLI, and Visual Studio Code and IDE plugins.

GENERAL DISTRIBUTION

Conditions

TEKTON CONCEPTS

20

● Defines a single checks

● Used in conditional tasks

● Parameterized

● Command run in container

○ True: exit code - 0

○ False: non-zero exit code

kind: Condition

metadata:

name: deployment-exists

spec:

params:

- name: appName

check:

image: openshift-cli

script: oc get deployment $(params.app)

kind: Pipeline

spec:

tasks:

- name: run-tests

taskRef: { image: ui-test-runner }

conditions:

- conditionRef: deployment-exists

params:

- {name: appName, value: api }

Page 20: Pipelines, Projekt Tekton und GitOps Next Generation CI/CD ...€¦ · Serverless CI/CD with no single server to share and maintain Web, CLI, and Visual Studio Code and IDE plugins.

GENERAL DISTRIBUTION

PipelineResource

22

● Inputs and outputs of tasks and pipelines

○ git repository

○ image in a registry

○ cluster credentials

○ storage

○ ...and mo

● Decoupled from pipeline definition

● Reusable across pipelines

Pipeline

PipelineResourceGit

PipelineResourceImage

TEKTON CONCEPTS

Page 21: Pipelines, Projekt Tekton und GitOps Next Generation CI/CD ...€¦ · Serverless CI/CD with no single server to share and maintain Web, CLI, and Visual Studio Code and IDE plugins.

GENERAL DISTRIBUTION

Triggers

23

TEKTON CONCEPTS

Run pipelines based on events like HTTP webhooks on commit, pull request, etc

EventListener

TriggerTemplate

webhook

TriggerBinding

How to map webhook JSON payload to variables

What resources to create (e.g. PipelineRun) using the variables

from payload mapping

Interceptors

PipelineRun

Filter or modify webhook payload e.g. match branch or files changes

Page 22: Pipelines, Projekt Tekton und GitOps Next Generation CI/CD ...€¦ · Serverless CI/CD with no single server to share and maintain Web, CLI, and Visual Studio Code and IDE plugins.

25

Task CatalogsA growing collection of reusable tasks

Page 23: Pipelines, Projekt Tekton und GitOps Next Generation CI/CD ...€¦ · Serverless CI/CD with no single server to share and maintain Web, CLI, and Visual Studio Code and IDE plugins.

GENERAL DISTRIBUTION

OpenShift Pipelines ArchitectureTEKTON CONCEPTS

26

PipelineResource

Pipeline

Task Task

Define pipelineRun pipelines

Pipeline Controllers(Tekton, ext, ...)

pipeline-pod-a

pipeline-pod-b

PipelineRun

TaskRun TaskRun

pipeline-pod-c

Page 24: Pipelines, Projekt Tekton und GitOps Next Generation CI/CD ...€¦ · Serverless CI/CD with no single server to share and maintain Web, CLI, and Visual Studio Code and IDE plugins.

GENERAL DISTRIBUTION

27

PIPELINE RUN

PIPELINE

Tekton Pipeline Example

Build JAR

Code analysis

Build app image

Deploy to DEV cluster

Integration Tests

Deploy to STAGE cluster

Container Registry

git url registry url dev cluster cred

stage cluster cred

DEVCluster

STAGECluster

TASK PIPELINE RESOURCE

Page 25: Pipelines, Projekt Tekton und GitOps Next Generation CI/CD ...€¦ · Serverless CI/CD with no single server to share and maintain Web, CLI, and Visual Studio Code and IDE plugins.

GENERAL DISTRIBUTION

28

Install OpenShift Pipelines Operator

Page 26: Pipelines, Projekt Tekton und GitOps Next Generation CI/CD ...€¦ · Serverless CI/CD with no single server to share and maintain Web, CLI, and Visual Studio Code and IDE plugins.

GENERAL DISTRIBUTION

29

OPENSHIFT PIPELINES

Page 27: Pipelines, Projekt Tekton und GitOps Next Generation CI/CD ...€¦ · Serverless CI/CD with no single server to share and maintain Web, CLI, and Visual Studio Code and IDE plugins.

GENERAL DISTRIBUTION

30

OPENSHIFT PIPELINES

Page 28: Pipelines, Projekt Tekton und GitOps Next Generation CI/CD ...€¦ · Serverless CI/CD with no single server to share and maintain Web, CLI, and Visual Studio Code and IDE plugins.

GENERAL DISTRIBUTION

31

OPENSHIFT PIPELINES

Page 29: Pipelines, Projekt Tekton und GitOps Next Generation CI/CD ...€¦ · Serverless CI/CD with no single server to share and maintain Web, CLI, and Visual Studio Code and IDE plugins.

GENERAL DISTRIBUTION

32

Pipeline Builder to compose Pipelines from Task libraryOPENSHIFT PIPELINES

Page 30: Pipelines, Projekt Tekton und GitOps Next Generation CI/CD ...€¦ · Serverless CI/CD with no single server to share and maintain Web, CLI, and Visual Studio Code and IDE plugins.

GENERAL DISTRIBUTION

33

Manage Pipelines with Tekton CLI

Page 31: Pipelines, Projekt Tekton und GitOps Next Generation CI/CD ...€¦ · Serverless CI/CD with no single server to share and maintain Web, CLI, and Visual Studio Code and IDE plugins.

GENERAL DISTRIBUTION

34

Tekton Pipelines VS Code Extension

Page 32: Pipelines, Projekt Tekton und GitOps Next Generation CI/CD ...€¦ · Serverless CI/CD with no single server to share and maintain Web, CLI, and Visual Studio Code and IDE plugins.

CONFIDENTIAL Designator

35

GitOps

Page 33: Pipelines, Projekt Tekton und GitOps Next Generation CI/CD ...€¦ · Serverless CI/CD with no single server to share and maintain Web, CLI, and Visual Studio Code and IDE plugins.

Git as the source of truth for the state of the entire system. Changes in Git drive

changes in the system

What is GitOps?

37

Repeatable Predictable Auditable Accessible

Page 34: Pipelines, Projekt Tekton und GitOps Next Generation CI/CD ...€¦ · Serverless CI/CD with no single server to share and maintain Web, CLI, and Visual Studio Code and IDE plugins.

DeploymentServiceRoute

ConfigMapPipeline

Task...

GitOps Workflow

38

currentstate

desiredstate

DeploymentServiceRoute

ConfigMapPipeline

Task...

Page 35: Pipelines, Projekt Tekton und GitOps Next Generation CI/CD ...€¦ · Serverless CI/CD with no single server to share and maintain Web, CLI, and Visual Studio Code and IDE plugins.

DeploymentServiceRoute

ConfigMapPipeline

Task...

GitOps Workflow

39

currentstate

desiredstate

reconcile

DeploymentServiceRoute

ConfigMapPipeline

Task...

Page 36: Pipelines, Projekt Tekton und GitOps Next Generation CI/CD ...€¦ · Serverless CI/CD with no single server to share and maintain Web, CLI, and Visual Studio Code and IDE plugins.

oc apply -k(kustomize)

GitOps Workflow

40

currentstate

desiredstate

Page 37: Pipelines, Projekt Tekton und GitOps Next Generation CI/CD ...€¦ · Serverless CI/CD with no single server to share and maintain Web, CLI, and Visual Studio Code and IDE plugins.

GitOps Workflow

41

currentstate

desiredstate

git commitgit merge

oc apply -k(kustomize)

Page 38: Pipelines, Projekt Tekton und GitOps Next Generation CI/CD ...€¦ · Serverless CI/CD with no single server to share and maintain Web, CLI, and Visual Studio Code and IDE plugins.

GitOps Tooling

https://argoproj.github.io/argo-cd

https://kustomize.io/

Argo CD Kustomize

Page 39: Pipelines, Projekt Tekton und GitOps Next Generation CI/CD ...€¦ · Serverless CI/CD with no single server to share and maintain Web, CLI, and Visual Studio Code and IDE plugins.

Argo CD - What is It?

Argo CD is a declarative, GitOps continuous delivery tool for Kubernetes.

● Easily deploy applications in a declarative way

● Synchronizes cluster state with git repos

● Works with a variety of Kubernetes deployment tools including:○ Helm○ Kustomize○ Ksonnet/Jsonnet○ Directories of yaml

● It is not a CI tool

Page 40: Pipelines, Projekt Tekton und GitOps Next Generation CI/CD ...€¦ · Serverless CI/CD with no single server to share and maintain Web, CLI, and Visual Studio Code and IDE plugins.

Argo CD - Synchronizing

Poll/Push

Change in git Pushed to Argo CD CheckSync Status

Synchronize

Page 41: Pipelines, Projekt Tekton und GitOps Next Generation CI/CD ...€¦ · Serverless CI/CD with no single server to share and maintain Web, CLI, and Visual Studio Code and IDE plugins.

46

Live Demo

Page 42: Pipelines, Projekt Tekton und GitOps Next Generation CI/CD ...€¦ · Serverless CI/CD with no single server to share and maintain Web, CLI, and Visual Studio Code and IDE plugins.

47

Lessons Learned and Roadmap

Page 43: Pipelines, Projekt Tekton und GitOps Next Generation CI/CD ...€¦ · Serverless CI/CD with no single server to share and maintain Web, CLI, and Visual Studio Code and IDE plugins.

GENERAL DISTRIBUTION

Learnings

48

● We used Tekton in some internal projects

● Feels native because it is!

Lessons Learned

Page 44: Pipelines, Projekt Tekton und GitOps Next Generation CI/CD ...€¦ · Serverless CI/CD with no single server to share and maintain Web, CLI, and Visual Studio Code and IDE plugins.

GENERAL DISTRIBUTION

Learnings

49

● Feels uncommon at first

● A lot of writing bash scripts and building container

images

● Debug? Metrics? Human Input? SCM Connect?

● Sometimes not that easy to write tasks generic

Lessons Learned

Page 45: Pipelines, Projekt Tekton und GitOps Next Generation CI/CD ...€¦ · Serverless CI/CD with no single server to share and maintain Web, CLI, and Visual Studio Code and IDE plugins.

GENERAL DISTRIBUTION

Learnings

50

● Moderate UI experience

○ VSCode plugin, good but...

○ Tekton Dashboard, good but...

○ OpenShift Dev Console (Pipeline

Builder), good but...

Lessons Learned

Page 46: Pipelines, Projekt Tekton und GitOps Next Generation CI/CD ...€¦ · Serverless CI/CD with no single server to share and maintain Web, CLI, and Visual Studio Code and IDE plugins.

GENERAL DISTRIBUTION

Learnings

51

● OLM update broke Tekton Operator

● Handling Task Results

● Some CRDs went to beta, Pipeline Resources -> Future?

● A lot of resources left after a build (Pods, PVCs etc.). Where

is my build history?

● Triggering Subpipelines -> Results?

Lessons Learned

Page 47: Pipelines, Projekt Tekton und GitOps Next Generation CI/CD ...€¦ · Serverless CI/CD with no single server to share and maintain Web, CLI, and Visual Studio Code and IDE plugins.

GENERAL DISTRIBUTION

Why it’s great?

52

● Cloud native! Declarative config, easy to share, easy to understand

● Environment promotion through GitOps

● Member of cd.foundation and part of Jenkins X, Kabanero, Relay…

● Task Catalog and new: Tekton Hub

● Foundational platform for Continuous Delivery

● Focus on core API -> enable 3rd party tooling

● Reusable!! Serverless!

● Will be a supported “product” within OpenShift!!

Lessons Learned

Page 48: Pipelines, Projekt Tekton und GitOps Next Generation CI/CD ...€¦ · Serverless CI/CD with no single server to share and maintain Web, CLI, and Visual Studio Code and IDE plugins.

GENERAL DISTRIBUTION

53

OpenShift PipelinesRoadmap

Dec 2019

Dev Preview 4WebhooksDefault tasksRBAC UX improvements (cont.)Tekton CLI (more commands)VSCode Plugin (cont.)Console Dev (view, graph, logs)

Webhook event filteringMore tasks in the catalogConsole - generate pipelinesConsole - task snippetsConsole - pipeline builderWorkspace and sharing artifactsTekton CLI (more commands)VSCode Plugin (cont.)

Tech Preview

May 2020

2HCY20

GADisconnected installProxy supportImage stream supportSupport for finally clausesEnhanced pipeline resourcesConsole - catalog integration

Page 49: Pipelines, Projekt Tekton und GitOps Next Generation CI/CD ...€¦ · Serverless CI/CD with no single server to share and maintain Web, CLI, and Visual Studio Code and IDE plugins.

CONFIDENTIAL Designator

linkedin.com/company/red-hat

youtube.com/user/RedHatVideos

facebook.com/redhatinc

twitter.com/RedHat

Red Hat is the world’s leading provider of

enterprise open source software solutions.

Award-winning support, training, and consulting

services make

Red Hat a trusted adviser to the Fortune 500.

Thank you

54