mirror of
https://github.com/khuedoan/homelab.git
synced 2025-01-24 10:02:23 +07:00
ci: create Pipeline and replace deprecated PipelineResources
This commit is contained in:
parent
436abf3782
commit
98a57ce9df
@ -1,4 +1,5 @@
|
|||||||
# TODO automate this
|
# TODO automate this
|
||||||
|
# kubectl apply -f https://raw.githubusercontent.com/tektoncd/catalog/main/task/git-clone/0.5/git-clone.yaml
|
||||||
# kubectl create secret generic -n tekton-pipelines kube-config --from-file=$PWD/../metal/kubeconfig.yaml
|
# kubectl create secret generic -n tekton-pipelines kube-config --from-file=$PWD/../metal/kubeconfig.yaml
|
||||||
# kubectl create secret generic -n tekton-pipelines terraform-env-vars \
|
# kubectl create secret generic -n tekton-pipelines terraform-env-vars \
|
||||||
# --from-literal=CLOUDFLARE_EMAIL=xxx@yyy.com \
|
# --from-literal=CLOUDFLARE_EMAIL=xxx@yyy.com \
|
||||||
@ -7,18 +8,6 @@
|
|||||||
# --from-literal=B2_APPLICATION_KEY=xxx \
|
# --from-literal=B2_APPLICATION_KEY=xxx \
|
||||||
# --from-literal=TF_VAR_cloudflare_account_id=xxx
|
# --from-literal=TF_VAR_cloudflare_account_id=xxx
|
||||||
|
|
||||||
apiVersion: tekton.dev/v1alpha1
|
|
||||||
kind: PipelineResource
|
|
||||||
metadata:
|
|
||||||
name: homelab-git
|
|
||||||
spec:
|
|
||||||
type: git
|
|
||||||
params:
|
|
||||||
- name: url
|
|
||||||
value: http://gitea-http.gitea:3000/ops/homelab
|
|
||||||
- name: revision
|
|
||||||
value: master
|
|
||||||
---
|
|
||||||
apiVersion: rbac.authorization.k8s.io/v1
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
kind: ClusterRoleBinding
|
kind: ClusterRoleBinding
|
||||||
metadata:
|
metadata:
|
||||||
@ -45,10 +34,8 @@ kind: Task
|
|||||||
metadata:
|
metadata:
|
||||||
name: terraform-external
|
name: terraform-external
|
||||||
spec:
|
spec:
|
||||||
resources:
|
workspaces:
|
||||||
inputs:
|
- name: source
|
||||||
- name: homelab-source
|
|
||||||
type: git
|
|
||||||
stepTemplate:
|
stepTemplate:
|
||||||
envFrom:
|
envFrom:
|
||||||
- secretRef:
|
- secretRef:
|
||||||
@ -63,21 +50,21 @@ spec:
|
|||||||
steps:
|
steps:
|
||||||
- name: init
|
- name: init
|
||||||
image: hashicorp/terraform:1.1.2
|
image: hashicorp/terraform:1.1.2
|
||||||
workingDir: /workspace/homelab-source/external # TODO
|
workingDir: $(workspaces.source.path)/external
|
||||||
command:
|
command:
|
||||||
- terraform
|
- terraform
|
||||||
args:
|
args:
|
||||||
- init
|
- init
|
||||||
- name: plan
|
- name: plan
|
||||||
image: hashicorp/terraform:1.1.2
|
image: hashicorp/terraform:1.1.2
|
||||||
workingDir: /workspace/homelab-source/external # TODO
|
workingDir: $(workspaces.source.path)/external
|
||||||
command:
|
command:
|
||||||
- terraform
|
- terraform
|
||||||
args:
|
args:
|
||||||
- plan
|
- plan
|
||||||
- name: apply
|
- name: apply
|
||||||
image: hashicorp/terraform:1.1.2
|
image: hashicorp/terraform:1.1.2
|
||||||
workingDir: /workspace/homelab-source/external # TODO
|
workingDir: $(workspaces.source.path)/external
|
||||||
command:
|
command:
|
||||||
- terraform
|
- terraform
|
||||||
args:
|
args:
|
||||||
@ -85,15 +72,46 @@ spec:
|
|||||||
- -auto-approve
|
- -auto-approve
|
||||||
---
|
---
|
||||||
apiVersion: tekton.dev/v1beta1
|
apiVersion: tekton.dev/v1beta1
|
||||||
kind: TaskRun
|
kind: Pipeline
|
||||||
metadata:
|
metadata:
|
||||||
name: terraform-external-run
|
name: homelab
|
||||||
spec:
|
spec:
|
||||||
serviceAccountName: terraform-sa
|
workspaces:
|
||||||
|
- name: shared-data
|
||||||
|
tasks:
|
||||||
|
- name: fetch-repo
|
||||||
|
taskRef:
|
||||||
|
name: git-clone
|
||||||
|
workspaces:
|
||||||
|
- name: output
|
||||||
|
workspace: shared-data
|
||||||
|
params:
|
||||||
|
- name: url
|
||||||
|
value: http://gitea-http.gitea:3000/ops/homelab
|
||||||
|
- name: revision
|
||||||
|
value: master
|
||||||
|
- name: terraform
|
||||||
|
runAfter: ["fetch-repo"] # Wait until the clone is done before reading the readme.
|
||||||
|
workspaces:
|
||||||
|
- name: source
|
||||||
|
workspace: shared-data
|
||||||
taskRef:
|
taskRef:
|
||||||
name: terraform-external
|
name: terraform-external
|
||||||
|
---
|
||||||
|
apiVersion: tekton.dev/v1beta1
|
||||||
|
kind: PipelineRun
|
||||||
|
metadata:
|
||||||
|
name: homelab-run
|
||||||
|
spec:
|
||||||
|
serviceAccountName: terraform-sa
|
||||||
|
pipelineRef:
|
||||||
|
name: homelab
|
||||||
|
workspaces:
|
||||||
|
- name: shared-data
|
||||||
|
volumeClaimTemplate:
|
||||||
|
spec:
|
||||||
|
accessModes:
|
||||||
|
- ReadWriteOnce
|
||||||
resources:
|
resources:
|
||||||
inputs:
|
requests:
|
||||||
- name: homelab-source
|
storage: 1Gi
|
||||||
resourceRef:
|
|
||||||
name: homelab-git
|
|
||||||
|
Loading…
Reference in New Issue
Block a user