update
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
**03-secret-dockerconfig.yaml
|
12
index.html
12
index.html
@ -1 +1,11 @@
|
||||
<p> test - 01 </p>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Tekton Demo</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>✅ Hello Tekton CI/CD!</h1>
|
||||
<p>This page is built automatically using Tekton Pipeline.</p>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
@ -1,34 +0,0 @@
|
||||
#task-build.yaml
|
||||
apiVersion: tekton.dev/v1
|
||||
kind: Task
|
||||
metadata:
|
||||
name: build-and-push
|
||||
namespace: tekton-demo
|
||||
spec:
|
||||
params:
|
||||
- name: IMAGE
|
||||
type: string
|
||||
description: "Target image"
|
||||
- name: GIT_URL
|
||||
type: string
|
||||
- name: GIT_REVISION
|
||||
type: string
|
||||
default: "main"
|
||||
steps:
|
||||
- name: git-clone
|
||||
image: alpine/git
|
||||
script: |
|
||||
#!/bin/sh
|
||||
git clone $(params.GIT_URL) source
|
||||
cd source
|
||||
git checkout $(params.GIT_REVISION)
|
||||
|
||||
- name: build-image
|
||||
image: gcr.io/kaniko-project/executor:latest
|
||||
args:
|
||||
- "--dockerfile=source/Dockerfile"
|
||||
- "--context=source/"
|
||||
- "--destination=$(params.IMAGE)"
|
||||
- "--insecure"
|
||||
- "--skip-tls-verify"
|
||||
|
@ -1,54 +0,0 @@
|
||||
# trigger.yaml
|
||||
apiVersion: triggers.tekton.dev/v1beta1
|
||||
kind: TriggerTemplate
|
||||
metadata:
|
||||
name: nginx-build-template
|
||||
namespace: tekton-demo
|
||||
spec:
|
||||
params:
|
||||
- name: git-repo-url
|
||||
- name: git-revision
|
||||
resourcetemplates:
|
||||
- apiVersion: tekton.dev/v1
|
||||
kind: PipelineRun
|
||||
metadata:
|
||||
generateName: nginx-build-run-
|
||||
spec:
|
||||
pipelineRef:
|
||||
name: nginx-build-pipeline
|
||||
params:
|
||||
- name: GIT_URL
|
||||
value: $(tt.params.git-repo-url)
|
||||
- name: GIT_REVISION
|
||||
value: $(tt.params.git-revision)
|
||||
- name: IMAGE
|
||||
value: harbor.icurfer.com/open/nginx-demo:latest
|
||||
|
||||
---
|
||||
apiVersion: triggers.tekton.dev/v1beta1
|
||||
kind: TriggerBinding
|
||||
metadata:
|
||||
name: nginx-build-binding
|
||||
namespace: tekton-demo
|
||||
spec:
|
||||
params:
|
||||
- name: git-repo-url
|
||||
value: $(body.repository.clone_url)
|
||||
- name: git-revision
|
||||
value: $(body.ref)
|
||||
|
||||
---
|
||||
apiVersion: triggers.tekton.dev/v1beta1
|
||||
kind: EventListener
|
||||
metadata:
|
||||
name: nginx-build-listener
|
||||
namespace: tekton-demo
|
||||
spec:
|
||||
serviceAccountName: tekton-triggers-sa
|
||||
triggers:
|
||||
- name: nginx-build-trigger
|
||||
bindings:
|
||||
- ref: nginx-build-binding
|
||||
template:
|
||||
ref: nginx-build-template
|
||||
|
64
sample-build/01-serviceaccount.yaml
Normal file
64
sample-build/01-serviceaccount.yaml
Normal file
@ -0,0 +1,64 @@
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: tekton-triggers-sa
|
||||
namespace: tekton-demo
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: Role
|
||||
metadata:
|
||||
name: tekton-build-role
|
||||
namespace: tekton-demo
|
||||
rules:
|
||||
- apiGroups: ["", "apps", "tekton.dev", "triggers.tekton.dev"]
|
||||
resources: ["pods", "pipelineruns", "tasks", "events"]
|
||||
verbs: ["get", "list", "watch", "create", "update", "delete"]
|
||||
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: RoleBinding
|
||||
metadata:
|
||||
name: tekton-build-sa-binding
|
||||
namespace: tekton-demo
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: tekton-build-sa
|
||||
roleRef:
|
||||
kind: Role
|
||||
name: tekton-build-role
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: tekton-build-sa
|
||||
namespace: tekton-demo
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
name: tekton-triggers-role
|
||||
rules:
|
||||
- apiGroups: [""] # core API
|
||||
resources: ["pods", "services", "endpoints", "configmaps", "secrets"]
|
||||
verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
|
||||
- apiGroups: ["apps"]
|
||||
resources: ["deployments"]
|
||||
verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
|
||||
- apiGroups: ["triggers.tekton.dev"]
|
||||
resources: ["eventlisteners", "triggerbindings", "triggertemplates", "triggers"]
|
||||
verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRoleBinding
|
||||
metadata:
|
||||
name: tekton-build-sa-binding
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: tekton-build-sa
|
||||
namespace: tekton-demo
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: ClusterRole
|
||||
name: cluster-admin
|
||||
|
27
sample-build/02-task-build.yaml
Normal file
27
sample-build/02-task-build.yaml
Normal file
@ -0,0 +1,27 @@
|
||||
apiVersion: tekton.dev/v1beta1
|
||||
kind: Task
|
||||
metadata:
|
||||
name: build-image
|
||||
namespace: tekton-demo
|
||||
spec:
|
||||
params:
|
||||
- name: IMAGE
|
||||
type: string
|
||||
description: Image name to build
|
||||
steps:
|
||||
- name: build-and-push
|
||||
image: gcr.io/kaniko-project/executor:latest
|
||||
args:
|
||||
- "--dockerfile=/workspace/source/Dockerfile"
|
||||
- "--context=/workspace/source/"
|
||||
- "--destination=$(params.IMAGE)"
|
||||
volumeMounts:
|
||||
- name: docker-config
|
||||
mountPath: /kaniko/.docker
|
||||
workspaces:
|
||||
- name: source
|
||||
volumes:
|
||||
- name: docker-config
|
||||
secret:
|
||||
secretName: harbor-dockerconfig
|
||||
|
10
sample-build/03-secret-dockerconfig.yaml.sample
Normal file
10
sample-build/03-secret-dockerconfig.yaml.sample
Normal file
@ -0,0 +1,10 @@
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: harbor-dockerconfig
|
||||
namespace: tekton-demo
|
||||
type: kubernetes.io/dockerconfigjson
|
||||
data:
|
||||
.dockerconfigjson: {base64} # harbor 로그인 정보
|
||||
|
||||
# cat config.json | base64 -w 0
|
39
sample-build/04-task-build.yaml
Normal file
39
sample-build/04-task-build.yaml
Normal file
@ -0,0 +1,39 @@
|
||||
apiVersion: tekton.dev/v1beta1
|
||||
kind: Task
|
||||
metadata:
|
||||
name: build-image
|
||||
namespace: tekton-demo
|
||||
spec:
|
||||
params:
|
||||
- name: IMAGE
|
||||
type: string
|
||||
description: Image name to build
|
||||
- name: GIT_URL
|
||||
type: string
|
||||
- name: GIT_REVISION
|
||||
type: string
|
||||
default: main
|
||||
steps:
|
||||
- name: clone
|
||||
image: alpine/git
|
||||
script: |
|
||||
#!/bin/sh
|
||||
git clone $(params.GIT_URL) /workspace/source
|
||||
cd /workspace/source
|
||||
git checkout $(params.GIT_REVISION)
|
||||
- name: build-and-push
|
||||
image: gcr.io/kaniko-project/executor:latest
|
||||
args:
|
||||
- "--dockerfile=/workspace/source/Dockerfile"
|
||||
- "--context=/workspace/source/"
|
||||
- "--destination=$(params.IMAGE)"
|
||||
volumeMounts:
|
||||
- name: docker-config
|
||||
mountPath: /kaniko/.docker
|
||||
workspaces:
|
||||
- name: source
|
||||
volumes:
|
||||
- name: docker-config
|
||||
secret:
|
||||
secretName: harbor-dockerconfig
|
||||
|
@ -1,24 +1,31 @@
|
||||
# pipeline-build.yaml
|
||||
apiVersion: tekton.dev/v1
|
||||
apiVersion: tekton.dev/v1beta1
|
||||
kind: Pipeline
|
||||
metadata:
|
||||
name: nginx-build-pipeline
|
||||
name: pipeline-build
|
||||
namespace: tekton-demo
|
||||
spec:
|
||||
params:
|
||||
- name: GIT_URL
|
||||
- name: GIT_REVISION
|
||||
default: "main"
|
||||
- name: IMAGE
|
||||
type: string
|
||||
- name: GIT_URL
|
||||
type: string
|
||||
- name: GIT_REVISION
|
||||
type: string
|
||||
default: main
|
||||
workspaces:
|
||||
- name: shared-data
|
||||
tasks:
|
||||
- name: build
|
||||
taskRef:
|
||||
name: build-and-push
|
||||
name: build-image
|
||||
params:
|
||||
- name: IMAGE
|
||||
value: $(params.IMAGE)
|
||||
- name: GIT_URL
|
||||
value: $(params.GIT_URL)
|
||||
- name: GIT_REVISION
|
||||
value: $(params.GIT_REVISION)
|
||||
- name: IMAGE
|
||||
value: $(params.IMAGE)
|
||||
workspaces:
|
||||
- name: source
|
||||
workspace: shared-data
|
||||
|
12
sample-build/06-trigger-binding.yaml
Normal file
12
sample-build/06-trigger-binding.yaml
Normal file
@ -0,0 +1,12 @@
|
||||
apiVersion: triggers.tekton.dev/v1beta1
|
||||
kind: TriggerBinding
|
||||
metadata:
|
||||
name: gitea-trigger-binding
|
||||
namespace: tekton-demo
|
||||
spec:
|
||||
params:
|
||||
- name: git-url
|
||||
value: $(body.repository.clone_url)
|
||||
- name: git-revision
|
||||
value: $(body.ref)
|
||||
|
36
sample-build/07-trigger-template.yaml
Normal file
36
sample-build/07-trigger-template.yaml
Normal file
@ -0,0 +1,36 @@
|
||||
apiVersion: triggers.tekton.dev/v1beta1
|
||||
kind: TriggerTemplate
|
||||
metadata:
|
||||
name: gitea-trigger-template
|
||||
namespace: tekton-demo
|
||||
spec:
|
||||
params:
|
||||
- name: git-url
|
||||
- name: git-revision
|
||||
resourcetemplates:
|
||||
- apiVersion: tekton.dev/v1beta1
|
||||
kind: PipelineRun
|
||||
metadata:
|
||||
generateName: build-run-
|
||||
spec:
|
||||
serviceAccountName: tekton-build-sa
|
||||
pipelineRef:
|
||||
name: pipeline-build
|
||||
params:
|
||||
- name: IMAGE
|
||||
value: harbor.icurfer.com/open/tekton-demo:latest
|
||||
- name: GIT_URL
|
||||
value: $(params.git-url)
|
||||
- name: GIT_REVISION
|
||||
value: $(params.git-revision)
|
||||
workspaces:
|
||||
- name: shared-data
|
||||
volumeClaimTemplate:
|
||||
metadata:
|
||||
name: source-pvc
|
||||
spec:
|
||||
accessModes: ["ReadWriteOnce"]
|
||||
resources:
|
||||
requests:
|
||||
storage: 1Gi
|
||||
|
14
sample-build/08-event-listener.yaml
Normal file
14
sample-build/08-event-listener.yaml
Normal file
@ -0,0 +1,14 @@
|
||||
apiVersion: triggers.tekton.dev/v1beta1
|
||||
kind: EventListener
|
||||
metadata:
|
||||
name: gitea-event-listener
|
||||
namespace: tekton-demo
|
||||
spec:
|
||||
serviceAccountName: tekton-build-sa
|
||||
triggers:
|
||||
- name: gitea-trigger
|
||||
bindings:
|
||||
- ref: gitea-trigger-binding
|
||||
template:
|
||||
ref: gitea-trigger-template
|
||||
|
12
sample-build/09.ing-proxy.yaml
Normal file
12
sample-build/09.ing-proxy.yaml
Normal file
@ -0,0 +1,12 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: el-tekton-demo-proxy
|
||||
namespace: tekton-pipelines
|
||||
spec:
|
||||
type: ExternalName
|
||||
externalName: el-gitea-event-listener.tekton-demo.svc.cluster.local
|
||||
ports:
|
||||
- port: 8080
|
||||
targetPort: 8080
|
||||
protocol: TCP
|
Reference in New Issue
Block a user