Skip to content

Commit 4fc1da2

Browse files
committed
Enable github actions for REL_5_8.
Use go to install kuttl.
1 parent 406b7d5 commit 4fc1da2

File tree

15 files changed

+1181
-138
lines changed

15 files changed

+1181
-138
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
name: Report a Bug
3+
about: Found an issue? Let us fix it.
4+
---
5+
6+
Please ensure you do the following when reporting a bug:
7+
8+
- [ ] Provide a concise description of what the bug is.
9+
- [ ] Provide information about your environment.
10+
- [ ] Provide clear steps to reproduce the bug.
11+
- [ ] Attach applicable logs. Please do not attach screenshots showing logs unless you are unable to copy and paste the log data.
12+
- [ ] Ensure any code / output examples are [properly formatted](https://docs.github.com/en/github/writing-on-github/basic-writing-and-formatting-syntax#quoting-code) for legibility.
13+
14+
Note that some logs needed to troubleshoot may be found in the `/pgdata/<CLUSTERNAME>/pg_log` directory on your Postgres instance.
15+
16+
An incomplete bug report can lead to delays in resolving the issue or the closing of a ticket, so please be as detailed as possible.
17+
18+
If you are looking for [general support](https://access.crunchydata.com/documentation/postgres-operator/latest/support/), please view the [support](https://access.crunchydata.com/documentation/postgres-operator/latest/support/) page for where you can ask questions.
19+
20+
Thanks for reporting the issue, we're looking forward to helping you!
21+
22+
## Overview
23+
24+
Add a concise description of what the bug is.
25+
26+
## Environment
27+
28+
Please provide the following details:
29+
30+
- Platform: (`Kubernetes`, `OpenShift`, `Rancher`, `GKE`, `EKS`, `AKS` etc.)
31+
- Platform Version: (e.g. `1.20.3`, `4.7.0`)
32+
- PGO Image Tag: (e.g. `ubi8-5.x.y-0`)
33+
- Postgres Version (e.g. `15`)
34+
- Storage: (e.g. `hostpath`, `nfs`, or the name of your storage class)
35+
36+
## Steps to Reproduce
37+
38+
### REPRO
39+
40+
Provide steps to get to the error condition:
41+
42+
1. Run `...`
43+
1. Do `...`
44+
1. Try `...`
45+
46+
### EXPECTED
47+
48+
1. Provide the behavior that you expected.
49+
50+
### ACTUAL
51+
52+
1. Describe what actually happens
53+
54+
## Logs
55+
56+
Please provided appropriate log output or any configuration files that may help troubleshoot the issue. **DO NOT** include sensitive information, such as passwords.
57+
58+
## Additional Information
59+
60+
Please provide any additional information that may be helpful.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
name: Feature Request
3+
about: Help us improve PGO!
4+
---
5+
6+
Have an idea to improve PGO? We'd love to hear it! We're going to need some information from you to learn more about your feature requests.
7+
8+
Please be sure you've done the following:
9+
10+
- [ ] Provide a concise description of your feature request.
11+
- [ ] Describe your use case. Detail the problem you are trying to solve.
12+
- [ ] Describe how you envision that the feature would work.
13+
- [ ] Provide general information about your current PGO environment.
14+
15+
## Overview
16+
17+
Provide a concise description of your feature request.
18+
19+
## Use Case
20+
21+
Describe your use case. Why do you want this feature? What problem will it solve? Why will it help you? Why will it make it easier to use PGO?
22+
23+
## Desired Behavior
24+
25+
Describe how the feature would work. How do you envision interfacing with it?
26+
27+
## Environment
28+
29+
Tell us about your environment:
30+
31+
Please provide the following details:
32+
33+
- Platform: (`Kubernetes`, `OpenShift`, `Rancher`, `GKE`, `EKS`, `AKS` etc.)
34+
- Platform Version: (e.g. `1.20.3`, `4.7.0`)
35+
- PGO Image Tag: (e.g. `ubi8-5.x.y-0`)
36+
- Postgres Version (e.g. `15`)
37+
- Storage: (e.g. `hostpath`, `nfs`, or the name of your storage class)
38+
- Number of Postgres clusters: (`XYZ`)
39+
40+
## Additional Information
41+
42+
Please provide any additional information that may be helpful.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
name: Support
3+
about: "Learn how to interact with the PGO community"
4+
---
5+
6+
If you believe you have found have found a bug, please open up [Bug Report](https://github.com/CrunchyData/postgres-operator/issues/new?template=bug_report.md)
7+
8+
If you have a feature request, please open up a [Feature Request](https://github.com/CrunchyData/postgres-operator/issues/new?template=feature_request.md)
9+
10+
You can find information about general PGO [support](https://access.crunchydata.com/documentation/postgres-operator/latest/support/) at:
11+
12+
[https://access.crunchydata.com/documentation/postgres-operator/latest/support/](https://access.crunchydata.com/documentation/postgres-operator/latest/support/)
13+
14+
## Questions
15+
16+
For questions that are neither bugs nor feature requests, please be sure to
17+
18+
- [ ] Provide information about your environment (see below for more information).
19+
- [ ] Provide any steps or other relevant details related to your question.
20+
- [ ] Attach logs, where applicable. Please do not attach screenshots showing logs unless you are unable to copy and paste the log data.
21+
- [ ] Ensure any code / output examples are [properly formatted](https://docs.github.com/en/github/writing-on-github/basic-writing-and-formatting-syntax#quoting-code) for legibility.
22+
23+
Besides Pod logs, logs may also be found in the `/pgdata/pg<MAJOR_VERSION>/log` directory on your Postgres instance.
24+
25+
If you are looking for [general support](https://access.crunchydata.com/documentation/postgres-operator/latest/support/), please view the [support](https://access.crunchydata.com/documentation/postgres-operator/latest/support/) page for where you can ask questions.
26+
27+
### Environment
28+
29+
Please provide the following details:
30+
31+
- Platform: (`Kubernetes`, `OpenShift`, `Rancher`, `GKE`, `EKS`, `AKS` etc.)
32+
- Platform Version: (e.g. `1.20.3`, `4.7.0`)
33+
- PGO Image Tag: (e.g. `ubi8-5.x.y-0`)
34+
- Postgres Version (e.g. `15`)
35+
- Storage: (e.g. `hostpath`, `nfs`, or the name of your storage class)

.github/actions/k3d/action.yaml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: k3d
2+
description: Start k3s using k3d
3+
inputs:
4+
k3d-tag:
5+
default: latest
6+
required: true
7+
description: >
8+
Git tag from https://github.com/k3d-io/k3d/releases or "latest"
9+
k3s-channel:
10+
default: latest
11+
required: true
12+
description: >
13+
https://docs.k3s.io/upgrades/manual#release-channels
14+
prefetch-images:
15+
required: true
16+
description: >
17+
Each line is the name of an image to fetch onto all Kubernetes nodes
18+
prefetch-timeout:
19+
default: 3m
20+
required: true
21+
description: >
22+
Amount of time to wait for images to be fetched
23+
24+
outputs:
25+
k3d-version:
26+
value: ${{ steps.k3d.outputs.k3d }}
27+
description: >
28+
K3d version
29+
kubernetes-version:
30+
value: ${{ steps.k3s.outputs.server }}
31+
description: >
32+
Kubernetes server version, as reported by the Kubernetes API
33+
pause-image:
34+
value: ${{ steps.k3s.outputs.pause-image }}
35+
description: >
36+
Pause image for prefetch images DaemonSet
37+
38+
runs:
39+
using: composite
40+
steps:
41+
- id: k3d
42+
name: Install k3d
43+
shell: bash
44+
env:
45+
K3D_TAG: ${{ inputs.k3d-tag }}
46+
run: |
47+
curl --fail --silent https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh |
48+
TAG="${K3D_TAG#latest}" bash
49+
k3d version | awk '{ print "${tolower($1)}=${$3}" >> $GITHUB_OUTPUT }'
50+
51+
- id: k3s
52+
name: Start k3s
53+
shell: bash
54+
run: |
55+
k3d cluster create --image '+${{ inputs.k3s-channel }}' --no-lb --timeout=2m --wait
56+
kubectl version | awk '{ print "${tolower($1)}=${$3}" >> $GITHUB_OUTPUT }'
57+
58+
PAUSE_IMAGE=$(docker exec $(k3d node list --output json | jq --raw-output 'first.name') \
59+
k3s agent --help | awk '$1 == "--pause-image" {
60+
match($0, /default: "[^"]*"/);
61+
print substr($0, RSTART+10, RLENGTH-11)
62+
}')
63+
echo "pause-image=${PAUSE_IMAGE}" >> $GITHUB_OUTPUT
64+
65+
- name: Prefetch container images
66+
shell: bash
67+
env:
68+
INPUT_IMAGES: ${{ inputs.prefetch-images }}
69+
INPUT_TIMEOUT: ${{ inputs.prefetch-timeout }}
70+
run: |
71+
jq <<< "$INPUT_IMAGES" --raw-input 'select(. != "")' |
72+
jq --slurp \
73+
--arg pause '${{ steps.k3s.outputs.pause-image }}' \
74+
--argjson labels '{"name":"image-prefetch"}' \
75+
--argjson name '"image-prefetch"' \
76+
'{
77+
apiVersion: "apps/v1", kind: "DaemonSet",
78+
metadata: { name: $name, labels: $labels },
79+
spec: {
80+
selector: { matchLabels: $labels },
81+
template: {
82+
metadata: { labels: $labels },
83+
spec: {
84+
initContainers: to_entries | map({
85+
name: "c\(.key)", image: .value, command: ["true"],
86+
}),
87+
containers: [{ name: "pause", image: $pause }]
88+
}
89+
}
90+
}
91+
}' |
92+
kubectl create --filename=-
93+
kubectl rollout status daemonset.apps/image-prefetch --timeout "$INPUT_TIMEOUT" ||
94+
kubectl describe daemonset.apps/image-prefetch

.github/actions/trivy/action.yaml

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
# Copyright 2024 - 2025 Crunchy Data Solutions, Inc.
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
#
5+
# schema documentation: https://docs.github.com/actions/sharing-automations/creating-actions/metadata-syntax-for-github-actions
6+
# yaml-language-server: $schema=https://json.schemastore.org/github-action.json
7+
8+
name: Trivy
9+
description: Scan this project using Trivy
10+
11+
# The Trivy team maintains an action, but it has trouble caching its vulnerability data:
12+
# https://github.com/aquasecurity/trivy-action/issues/389
13+
#
14+
# 1. It caches vulnerability data once per calendar day, despite Trivy wanting
15+
# to download more frequently than that.
16+
# 2. When it fails to download the data, it fails the workflow *and* caches
17+
# the incomplete data.
18+
# 3. When (1) and (2) coincide, every following run that day *must* update the data,
19+
# producing more opportunities for (2) and more failed workflows.
20+
#
21+
# The action below uses any recent cache matching `cache-prefix` and calculates a cache key
22+
# derived from the data Trivy downloads. An older database is better than no scans at all.
23+
# When a run successfully updates the data, that data is cached and available to other runs.
24+
25+
inputs:
26+
cache:
27+
default: restore,success,use
28+
description: >-
29+
What Trivy data to cache; one or more of restore, save, success, or use.
30+
The value "use" instructs Trivy to read and write to its cache.
31+
The value "restore" loads the Trivy cache from GitHub.
32+
The value "success" saves the Trivy cache to GitHub when Trivy succeeds.
33+
The value "save" saves the Trivy cache to GitHub regardless of Trivy.
34+
35+
database:
36+
default: update
37+
description: >-
38+
How Trivy should handle its data; one of update or skip.
39+
The value "skip" fetches no Trivy data at all.
40+
41+
setup:
42+
default: v0.65.0,cache
43+
description: >-
44+
How to install Trivy; one or more of version, none, or cache.
45+
The value "none" does not install Trivy at all.
46+
47+
cache-directory:
48+
default: ${{ github.workspace }}/.cache/trivy
49+
description: >-
50+
Directory where Trivy should store its data
51+
52+
cache-prefix:
53+
default: cache-trivy
54+
description: >-
55+
Name (key) where Trivy data should be stored in the GitHub cache
56+
57+
scan-target:
58+
default: .
59+
description: >-
60+
What Trivy should scan
61+
62+
scan-type:
63+
default: repository
64+
description: >-
65+
How Trivy should interpret scan-target; one of filesystem, image, repository, or sbom.
66+
67+
runs:
68+
using: composite
69+
steps:
70+
# Parse list inputs as separated by commas and spaces.
71+
# Select the maximum version-looking string from `inputs.setup`.
72+
- id: parsed
73+
shell: bash
74+
run: |
75+
# Validate inputs
76+
(
77+
<<< '${{ inputs.cache }}' jq -rRsS '"cache=\(split("[,\\s]+"; "") - [""])"'
78+
<<< '${{ inputs.setup }}' jq -rRsS '
79+
"setup=\(split("[,\\s]+"; "") - [""])",
80+
"version=\(split("[,\\s]+"; "") | max_by(split("[v.]"; "") | map(tonumber?)))"
81+
'
82+
) | tee --append "${GITHUB_OUTPUT}"
83+
84+
# Install Trivy as requested.
85+
# NOTE: `setup-trivy` can download a "latest" version but cannot cache it.
86+
- if: ${{ ! contains(fromJSON(steps.parsed.outputs.setup), 'none') }}
87+
uses: aquasecurity/setup-trivy@v0.2.4
88+
with:
89+
cache: ${{ contains(fromJSON(steps.parsed.outputs.setup), 'cache') }}
90+
version: ${{ steps.parsed.outputs.version }}
91+
92+
# Restore a recent cache beginning with the prefix.
93+
- id: restore
94+
if: ${{ contains(fromJSON(steps.parsed.outputs.cache), 'restore') }}
95+
uses: actions/cache/restore@v4
96+
with:
97+
path: ${{ inputs.cache-directory }}
98+
key: ${{ inputs.cache-prefix }}-
99+
100+
- id: trivy
101+
shell: bash
102+
env:
103+
TRIVY_CACHE_DIR: >-
104+
${{ contains(fromJSON(steps.parsed.outputs.cache), 'use') && inputs.cache-directory || '' }}
105+
TRIVY_SKIP_CHECK_UPDATE: ${{ inputs.database == 'skip' }}
106+
TRIVY_SKIP_DB_UPDATE: ${{ inputs.database == 'skip' }}
107+
TRIVY_SKIP_JAVA_DB_UPDATE: ${{ inputs.database == 'skip' }}
108+
TRIVY_SKIP_VEX_REPO_UPDATE: ${{ inputs.database == 'skip' }}
109+
run: |
110+
# Run Trivy
111+
trivy '${{ inputs.scan-type }}' '${{ inputs.scan-target }}' || result=$?
112+
113+
checksum=$([[ -z "${TRIVY_CACHE_DIR}" ]] || cat "${TRIVY_CACHE_DIR}/"*/metadata.json | sha256sum)
114+
echo 'cache-key=${{ inputs.cache-prefix }}-'"${checksum%% *}" >> "${GITHUB_OUTPUT}"
115+
116+
exit "${result-0}"
117+
118+
# Save updated data to the cache when requested.
119+
- if: >-
120+
${{
121+
steps.restore.outcome == 'success' &&
122+
steps.restore.outputs.cache-matched-key == steps.trivy.outputs.cache-key
123+
}}
124+
shell: bash
125+
run: |
126+
# Cache hit on ${{ steps.restore.outputs.cache-matched-key }}
127+
- if: >-
128+
${{
129+
steps.restore.outputs.cache-matched-key != steps.trivy.outputs.cache-key &&
130+
(
131+
(contains(fromJSON(steps.parsed.outputs.cache), 'save') && !cancelled()) ||
132+
(contains(fromJSON(steps.parsed.outputs.cache), 'success') && success())
133+
)
134+
}}
135+
uses: actions/cache/save@v4
136+
with:
137+
key: ${{ steps.trivy.outputs.cache-key }}
138+
path: ${{ inputs.cache-directory }}

0 commit comments

Comments
 (0)