Skip to content

Instantly share code, notes, and snippets.

@jwntrs
Last active September 11, 2020 20:30
Show Gist options
  • Save jwntrs/48239bacf1802dcc2b5c955d62f34759 to your computer and use it in GitHub Desktop.
Save jwntrs/48239bacf1802dcc2b5c955d62f34759 to your computer and use it in GitHub Desktop.
apiVersion: experimental.kontinue.io/v1
kind: Workflow
metadata:
name: app
spec:
sources:
- name: repo
sourceRefs:
- name: app
kind: GitSource
apiVersion: experimental.kontinue.io/v1
- name: golang
sourceRefs:
- name: golang-1-14
kind: RegistrySource
apiVersion: experimental.kontinue.io/v1
- name: golang-1-15
kind: RegistrySource
apiVersion: experimental.kontinue.io/v1
- name: builder
sourceRefs:
- name: builder-base
kind: RegistrySource
apiVersion: experimental.kontinue.io/v1
- name: redis
sourceRefs:
- name: redis-6
kind: RegistrySource
apiVersion: experimental.kontinue.io/v1
steps:
- name: unit
sources: [repo,golang]
templates:
- template: |-
apiVersion: tekton.dev/v1beta1
kind: TaskRun
metadata:
generateName: 'app-unit-'
spec:
serviceAccountName: service-account
taskRef:
name: unit-tests
params:
- name: image
value: '{{ .Sources.golang.url }}@{{ .Sources.golang.revision }}'
- name: url
value: '{{ .Sources.repo.url }}'
- name: revision
value: '{{ .Sources.repo.revision }}'
- name: build
sources: [repo, builder]
outputs:
- name: latestImage
valueFrom:
template:
jsonPath: '{.status.latestImage}'
templates:
- template: |-
kind: Build
apiVersion: kpack.io/v1alpha1
metadata:
generateName: 'app-'
spec:
tags: [ 'kontinue/app' ]
serviceAccount: service-account
builder:
image: '{{ .Sources.builder.url }}@{{ .Sources.builder.revision }}'
source:
git:
url: 'https://github.com/{{ .Sources.repo.url }}'
revision: '{{ .Sources.repo.revision }}'
- name: deploy-redis
sources: [redis]
outputs:
- name: serviceName
valueFrom:
template:
jsonPath: '{.metadata.name}'
templates:
- lifecycle: DeleteAfterRun
template: |-
apiVersion: v1
kind: Service
metadata:
labels:
app.kubernetes.io/name: redis-{{ .StepId }}
name: redis-{{ .StepId }}
spec:
ports:
- port: 6379
protocol: TCP
targetPort: 6379
selector:
app.kubernetes.io/name: redis-{{ .StepId }}
type: ClusterIP
- lifecycle: DeleteAfterRun
template: |-
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app.kubernetes.io/name: redis-{{ .StepId }}
name: redis-{{ .StepId }}
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/name: redis-{{ .StepId }}
template:
metadata:
labels:
app.kubernetes.io/name: redis-{{ .StepId }}
spec:
containers:
- image: '{{ .Sources.redis.url }}@{{ .Sources.redis.revision }}'
name: redis
ports:
- containerPort: 6379
- name: deploy-app
sources: [repo]
outputs:
- name: serviceName
valueFrom:
template:
jsonPath: '{.metadata.name}'
inputs:
- name: latestImage
valueFrom:
output:
step: build
name: latestImage
- name: serviceName
valueFrom:
output:
step: deploy-redis
name: serviceName
templates:
- lifecycle: DeleteAfterRun
template: |-
apiVersion: v1
kind: Service
metadata:
labels:
app.kubernetes.io/name: app-{{ .StepId }}
name: app-{{ .StepId }}
spec:
ports:
- port: 8080
protocol: TCP
targetPort: 8080
selector:
app.kubernetes.io/name: app-{{ .StepId }}
type: ClusterIP
- lifecycle: DeleteAfterRun
template: |-
apiVersion: apps/v1
kind: Deployment
metadata:
generateName: 'app-'
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/name: app-{{ .StepId }}
template:
metadata:
labels:
app.kubernetes.io/name: app-{{ .StepId }}
spec:
containers:
- image: '{{ .Inputs.latestImage }}'
command: [ /cnb/lifecycle/launcher ]
env:
- name: REDIS_ADDR
value: "{{ .Inputs.serviceName }}:6379"
name: app
- name: integration-test
sources: [repo]
inputs:
- name: serviceName
valueFrom:
output:
step: deploy-app
name: serviceName
templates:
- template: |-
apiVersion: tekton.dev/v1beta1
kind: TaskRun
metadata:
generateName: 'app-integr-'
spec:
serviceAccountName: service-account
taskRef:
name: integration-tests
params:
- name: addr
value: '{{ .Inputs.serviceName }}'
apiVersion: experimental.kontinue.io/v1
kind: GitSource
metadata:
name: app
spec:
repository: kontinue/example-app
serviceAccountName: service-account
---
apiVersion: experimental.kontinue.io/v1
kind: RegistrySource
metadata:
name: redis-6
spec:
repository: library/redis
tagFilter: '^6$'
serviceAccountName: service-account
---
apiVersion: experimental.kontinue.io/v1
kind: RegistrySource
metadata:
name: golang-1-15
spec:
repository: library/golang
tagFilter: '^1.15$'
serviceAccountName: service-account
---
apiVersion: experimental.kontinue.io/v1
kind: RegistrySource
metadata:
name: golang-1-14
spec:
repository: library/golang
tagFilter: '^1.14$'
serviceAccountName: service-account
---
apiVersion: experimental.kontinue.io/v1
kind: RegistrySource
metadata:
name: builder-base
spec:
repository: gcr.io/paketo-buildpacks/builder
tagFilter: "^base$"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment