task-postgresql-pod.yaml
2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
---
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: task-postgresql-pod
spec:
description: >-
This Task deploys (or delete) a Kubernetes resource (pod). It uses
kubectl for that.
params:
- name: kubectl-image
default: bitnami/kubectl:1.21
- name: bash-image
default: bash
- name: kustomize-image
default: us.gcr.io/k8s-artifacts-prod/kustomize/kustomize:v4.5.2
# results:
# - name: job-name
volumes:
- name: postgresql-pod-kustomization
configMap:
name: postgresql-pod-kustomization
steps:
- name: mount-postgresql-pod-kustomization
image: $(params.bash-image)
script: |
#!/usr/bin/env bash
set -ex
mkdir /workspace/kustomizations
cd /srv/postgresql-pod-kustomization-cm/
for file in *; do
translated="$(echo "$file" | sed "s,_,/,g")"
dir="$(dirname "$translated")"
base="$(basename "$translated")"
mkdir -p "/workspace/kustomizations/$dir"
cp "$file" "/workspace/kustomizations/$dir/$base"
done
volumeMounts:
- name: postgresql-pod-kustomization
mountPath: /srv/postgresql-pod-kustomization-cm
- name: run-kustomize-4-x
image: $(params.kustomize-image)
script: |
#!/bin/sh
set -ex
kustomize build /workspace/kustomizations/postgresql-pod > /workspace/postgresql-pod.yaml
env:
- name: PARENT_POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: PARENT_POD_UID
valueFrom:
fieldRef:
fieldPath: metadata.uid
- name: set-generate-name
image: $(params.bash-image)
script: |
#!/usr/bin/env bash
set -ex
cat /workspace/postgresql-pod.yaml
sed -i -e 's/^ name:/ generateName:/' /workspace/postgresql-pod.yaml
cat /workspace/postgresql-pod.yaml
- name: create-postgresql-pod
image: $(params.kubectl-image)
script: |
#!/usr/bin/env bash
set -ex
kubectl create -f /workspace/postgresql-pod.yaml -o jsonpath --template '{.metadata.name}'/ > /workspace/create-output.json
cat /workspace/create-output.json
---