Initial set of files; haven't tried to use these remotely yet.
Showing
6 changed files
with
213 additions
and
0 deletions
kustomization.yaml
0 → 100644
1 | apiVersion: kustomize.config.k8s.io/v1beta1 | ||
2 | kind: Kustomization | ||
3 | |||
4 | resources: | ||
5 | - ./task-postgresql-pod.yaml | ||
6 | |||
7 | configMapGenerator: | ||
8 | - name: task-postgresql-pod-kustomization | ||
9 | options: | ||
10 | disableNameSuffixHash: true | ||
11 | files: | ||
12 | - postgresql-pod_kustomization.yaml=postgresql-pod/kustomization.yaml | ||
13 | - postgresql-pod_postgresql-pod.yaml=postgresql-pod/postgresql-pod.yaml | ||
14 | - postgresql-pod_set-deployment-config_deployment-config.env=postgresql-pod/set-deployment-config/deployment-config.env | ||
15 | - postgresql-pod_set-deployment-config_kustomization.yaml=postgresql-pod/set-deployment-config/kustomization.yaml | ||
16 | |||
17 | --- |
postgresql-pod/kustomization.yaml
0 → 100644
postgresql-pod/postgresql-pod.yaml
0 → 100644
1 | --- | ||
2 | apiVersion: v1 | ||
3 | kind: Service | ||
4 | metadata: | ||
5 | name: postgresql-server- | ||
6 | ownerReferences: | ||
7 | - apiVersion: v1 | ||
8 | kind: Pod | ||
9 | blockOwnerDeletion: true | ||
10 | controller: true | ||
11 | name: PARENT_POD_NAME | ||
12 | uid: PARENT_POD_UID | ||
13 | spec: | ||
14 | type: ClusterIP | ||
15 | selector: | ||
16 | owner-uid: PARENT_POD_UID | ||
17 | ports: | ||
18 | - name: pgsql | ||
19 | protocol: TCP | ||
20 | port: 5432 | ||
21 | targetPort: 5432 | ||
22 | --- | ||
23 | apiVersion: v1 | ||
24 | kind: Pod | ||
25 | metadata: | ||
26 | name: postgresql-server- | ||
27 | labels: | ||
28 | owner-uid: PARENT_POD_UID | ||
29 | ownerReferences: | ||
30 | - apiVersion: v1 | ||
31 | kind: Pod | ||
32 | blockOwnerDeletion: true | ||
33 | controller: true | ||
34 | name: PARENT_POD_NAME | ||
35 | uid: PARENT_POD_UID | ||
36 | spec: | ||
37 | volumes: | ||
38 | - name: postgresql-data | ||
39 | emptyDir: {} | ||
40 | containers: | ||
41 | - name: postgresql | ||
42 | image: bitnami/postgresql:14.1.0-debian-10-r66 | ||
43 | #securityContext: | ||
44 | # runAsUser: 1001 | ||
45 | # runAsGroup: 1001 | ||
46 | env: | ||
47 | - name: POSTGRESQL_PASSWORD | ||
48 | value: CHANGEME | ||
49 | |||
50 | volumeMounts: | ||
51 | - name: postgresql-data | ||
52 | mountPath: /bitnami/postgresql | ||
53 | --- |
1 | apiVersion: kustomize.config.k8s.io/v1alpha1 | ||
2 | kind: Component | ||
3 | |||
4 | configMapGenerator: | ||
5 | - name: deployment-config | ||
6 | options: | ||
7 | disableNameSuffixHash: true | ||
8 | # behavior: merge | ||
9 | envs: | ||
10 | - deployment-config.env | ||
11 | |||
12 | replacements: | ||
13 | - source: | ||
14 | kind: ConfigMap | ||
15 | version: v1 | ||
16 | name: deployment-config | ||
17 | fieldPath: data.PARENT_POD_NAME | ||
18 | targets: | ||
19 | - select: | ||
20 | kind: Pod | ||
21 | name: postgresql-server- | ||
22 | fieldPaths: | ||
23 | - metadata.ownerReferences.0.name | ||
24 | - select: | ||
25 | kind: Service | ||
26 | name: postgresql-server- | ||
27 | fieldPaths: | ||
28 | - metadata.ownerReferences.0.name | ||
29 | - source: | ||
30 | kind: ConfigMap | ||
31 | version: v1 | ||
32 | name: deployment-config | ||
33 | fieldPath: data.PARENT_POD_UID | ||
34 | targets: | ||
35 | - select: | ||
36 | kind: Pod | ||
37 | name: postgresql-server- | ||
38 | fieldPaths: | ||
39 | - metadata.ownerReferences.0.uid | ||
40 | - metadata.labels.owner-uid | ||
41 | - select: | ||
42 | kind: Service | ||
43 | name: postgresql-server- | ||
44 | fieldPaths: | ||
45 | - metadata.ownerReferences.0.uid | ||
46 | - spec.selector.owner-uid | ||
47 |
task-postgresql-pod.yaml
0 → 100644
1 | --- | ||
2 | apiVersion: tekton.dev/v1beta1 | ||
3 | kind: Task | ||
4 | metadata: | ||
5 | name: postgresql-pod | ||
6 | spec: | ||
7 | description: >- | ||
8 | This Task deploys (or delete) a Kubernetes resource (pod). It uses | ||
9 | kubectl for that. | ||
10 | |||
11 | params: | ||
12 | - name: kubectl-image | ||
13 | default: bitnami/kubectl:1.21 | ||
14 | - name: bash-image | ||
15 | default: bash | ||
16 | - name: kustomize-image | ||
17 | default: us.gcr.io/k8s-artifacts-prod/kustomize/kustomize:v4.5.2 | ||
18 | # results: | ||
19 | # - name: job-name | ||
20 | volumes: | ||
21 | - name: postgresql-pod-kustomization | ||
22 | configMap: | ||
23 | name: postgresql-pod-kustomization | ||
24 | steps: | ||
25 | - name: mount-postgresql-pod-kustomization | ||
26 | image: $(params.bash-image) | ||
27 | script: | | ||
28 | #!/usr/bin/env bash | ||
29 | set -ex | ||
30 | mkdir /workspace/kustomizations | ||
31 | cd /srv/postgresql-pod-kustomization-cm/ | ||
32 | for file in *; do | ||
33 | translated="$(echo "$file" | sed "s,_,/,g")" | ||
34 | dir="$(dirname "$translated")" | ||
35 | base="$(basename "$translated")" | ||
36 | mkdir -p "/workspace/kustomizations/$dir" | ||
37 | cp "$file" "/workspace/kustomizations/$dir/$base" | ||
38 | done | ||
39 | volumeMounts: | ||
40 | - name: postgresql-pod-kustomization | ||
41 | mountPath: /srv/postgresql-pod-kustomization-cm | ||
42 | - name: run-kustomize-4-x | ||
43 | image: $(params.kustomize-image) | ||
44 | script: | | ||
45 | #!/bin/sh | ||
46 | set -ex | ||
47 | kustomize build /workspace/kustomizations/postgresql-pod > /workspace/postgresql-pod.yaml | ||
48 | env: | ||
49 | - name: PARENT_POD_NAME | ||
50 | valueFrom: | ||
51 | fieldRef: | ||
52 | fieldPath: metadata.name | ||
53 | - name: PARENT_POD_UID | ||
54 | valueFrom: | ||
55 | fieldRef: | ||
56 | fieldPath: metadata.uid | ||
57 | |||
58 | - name: set-generate-name | ||
59 | image: $(params.bash-image) | ||
60 | script: | | ||
61 | #!/usr/bin/env bash | ||
62 | set -ex | ||
63 | cat /workspace/postgresql-pod.yaml | ||
64 | sed -i -e 's/^ name:/ generateName:/' /workspace/postgresql-pod.yaml | ||
65 | cat /workspace/postgresql-pod.yaml | ||
66 | - name: create-postgresql-pod | ||
67 | image: $(params.kubectl-image) | ||
68 | script: | | ||
69 | #!/usr/bin/env bash | ||
70 | |||
71 | set -ex | ||
72 | kubectl create -f /workspace/postgresql-pod.yaml -o jsonpath --template '{.metadata.name}'/ > /workspace/create-output.json | ||
73 | cat /workspace/create-output.json | ||
74 | |||
75 | --- |
-
Please register or sign in to post a comment