Skip to content

Commit 0c67d76

Browse files
authored
feat(cloud-query): add PostgreSQL sidecar container and update build process (#2453)
1 parent bdac5a4 commit 0c67d76

File tree

23 files changed

+469
-324
lines changed

23 files changed

+469
-324
lines changed

.github/workflows/cloud-query-cd.yaml

Lines changed: 157 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ env:
2222
GOBIN: /home/runner/go/bin
2323
GOPROXY: "https://proxy.golang.org"
2424
REGISTRY_IMAGE: ghcr.io/pluralsh/cloud-query
25+
REGISTRY_IMAGE_DB: ghcr.io/pluralsh/cloud-query-db
2526
DOCKER_METADATA_PR_HEAD_SHA: 'true'
2627
jobs:
2728
test:
@@ -44,8 +45,8 @@ jobs:
4445
run: go mod download
4546
- name: Test
4647
run: PATH=$PATH:$GOPATH/bin make test
47-
build-image:
48-
name: Build image
48+
build-db:
49+
name: Build db image
4950
needs: [ test ]
5051
permissions:
5152
contents: 'read'
@@ -60,6 +61,91 @@ jobs:
6061
- platform: linux/arm64
6162
runner: ubuntu-24.04-arm
6263
runs-on: ${{ matrix.platforms.runner }}
64+
defaults:
65+
run:
66+
shell: bash
67+
working-directory: go/cloud-query
68+
steps:
69+
- name: Checkout
70+
uses: actions/checkout@v4
71+
with:
72+
fetch-depth: 0
73+
- name: Prepare
74+
run: |
75+
platform=${{ matrix.platforms.platform }}
76+
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
77+
- name: Docker meta
78+
id: meta
79+
uses: docker/metadata-action@v5
80+
with:
81+
images: ${{ env.REGISTRY_IMAGE_DB }}
82+
- name: Login to GHCR
83+
uses: docker/login-action@v3
84+
with:
85+
registry: ghcr.io
86+
username: ${{ github.repository_owner }}
87+
password: ${{ secrets.GITHUB_TOKEN }}
88+
- uses: google-github-actions/auth@v1
89+
with:
90+
workload_identity_provider: 'projects/${{ secrets.GOOGLE_PROJECT_ID }}/locations/global/workloadIdentityPools/github/providers/github'
91+
service_account: '[email protected]'
92+
token_format: 'access_token'
93+
create_credentials_file: true
94+
- uses: google-github-actions/[email protected]
95+
- name: Login to GCR
96+
run: gcloud auth configure-docker -q
97+
- name: Login to Docker
98+
uses: docker/login-action@v3
99+
with:
100+
username: mjgpluralsh
101+
password: ${{ secrets.DOCKER_ACCESS_TOKEN }}
102+
- name: Set up QEMU
103+
uses: docker/setup-qemu-action@v3
104+
- name: Set up Docker Buildx
105+
uses: docker/[email protected]
106+
- name: Build and push by digest
107+
id: build
108+
uses: docker/build-push-action@v6
109+
with:
110+
context: "./go/cloud-query"
111+
file: "./go/cloud-query/db.Dockerfile"
112+
tags: ${{ env.REGISTRY_IMAGE_DB }}
113+
labels: ${{ steps.meta.outputs.labels }}
114+
platforms: ${{ matrix.platforms.platform }}
115+
outputs: type=image,push-by-digest=true,name-canonical=true,push=true
116+
cache-from: type=gha
117+
cache-to: type=gha,mode=max
118+
build-args: |
119+
GIT_COMMIT=${{ github.sha }}
120+
VERSION=${{ steps.meta.outputs.version }}
121+
- name: Export digest
122+
run: |
123+
mkdir -p ${{ runner.temp }}/digests
124+
digest="${{ steps.build.outputs.digest }}"
125+
touch "${{ runner.temp }}/digests/${digest#sha256:}"
126+
- name: Upload digest
127+
uses: actions/upload-artifact@v4
128+
with:
129+
name: digests-db-${{ env.PLATFORM_PAIR }}-${{ github.run_id }}
130+
path: ${{ runner.temp }}/digests/*
131+
if-no-files-found: error
132+
retention-days: 1
133+
build-cloud-query:
134+
name: Build cloud-query image
135+
needs: [test]
136+
permissions:
137+
contents: 'read'
138+
id-token: 'write'
139+
packages: 'write'
140+
strategy:
141+
fail-fast: false
142+
matrix:
143+
platforms:
144+
- platform: linux/amd64
145+
runner: ubuntu-24.04
146+
- platform: linux/arm64
147+
runner: ubuntu-24.04-arm
148+
runs-on: ${{ matrix.platforms.runner }}
63149
defaults:
64150
run:
65151
shell: bash
@@ -125,13 +211,76 @@ jobs:
125211
- name: Upload digest
126212
uses: actions/upload-artifact@v4
127213
with:
128-
name: digests-${{ env.PLATFORM_PAIR }}
214+
name: digests-cloudquery-${{ env.PLATFORM_PAIR }}-${{ github.run_id }}
129215
path: ${{ runner.temp }}/digests/*
130216
if-no-files-found: error
131217
retention-days: 1
132-
publish-image:
133-
name: Publish image
134-
needs: [ build-image ]
218+
publish-db:
219+
name: Publish db image
220+
needs: [build-db]
221+
permissions:
222+
contents: 'read'
223+
id-token: 'write'
224+
packages: 'write'
225+
strategy:
226+
fail-fast: false
227+
matrix:
228+
images:
229+
- ghcr.io/pluralsh/cloud-query-db
230+
- gcr.io/pluralsh/cloud-query-db
231+
- docker.io/pluralsh/cloud-query-db
232+
runs-on: ubuntu-latest
233+
steps:
234+
- name: Download digests
235+
uses: actions/download-artifact@v4
236+
with:
237+
path: ${{ runner.temp }}/digests
238+
pattern: digests-db-*
239+
merge-multiple: true
240+
- name: Login to GHCR
241+
uses: docker/login-action@v3
242+
with:
243+
registry: ghcr.io
244+
username: ${{ github.repository_owner }}
245+
password: ${{ secrets.GITHUB_TOKEN }}
246+
- uses: google-github-actions/auth@v1
247+
with:
248+
workload_identity_provider: 'projects/${{ secrets.GOOGLE_PROJECT_ID }}/locations/global/workloadIdentityPools/github/providers/github'
249+
service_account: '[email protected]'
250+
token_format: 'access_token'
251+
create_credentials_file: true
252+
- uses: google-github-actions/[email protected]
253+
- name: Login to GCR
254+
run: gcloud auth configure-docker -q
255+
- name: Login to Docker Hub
256+
uses: docker/login-action@v3
257+
with:
258+
username: mjgpluralsh
259+
password: ${{ secrets.DOCKER_ACCESS_TOKEN }}
260+
- name: Set up Docker Buildx
261+
uses: docker/setup-buildx-action@v3
262+
- name: Docker meta
263+
id: meta
264+
uses: docker/metadata-action@v5
265+
with:
266+
images: ${{ matrix.images }}
267+
tags: |
268+
type=ref,event=branch
269+
type=ref,event=tag
270+
type=ref,event=pr
271+
type=sha
272+
type=raw,value=${{ github.event.inputs.version }},enable=${{ github.event.inputs.version != '' }}
273+
- name: Create manifest list and push
274+
working-directory: ${{ runner.temp }}/digests
275+
run: |
276+
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
277+
$(printf '${{ env.REGISTRY_IMAGE_DB }}@sha256:%s ' *)
278+
- name: Inspect image
279+
run: |
280+
docker buildx imagetools inspect ${{ matrix.images }}:${{ steps.meta.outputs.version }}
281+
publish-cloud-query:
282+
name: Publish cloud-query image
283+
needs: [build-cloud-query]
135284
permissions:
136285
contents: 'read'
137286
id-token: 'write'
@@ -149,7 +298,7 @@ jobs:
149298
uses: actions/download-artifact@v4
150299
with:
151300
path: ${{ runner.temp }}/digests
152-
pattern: digests-*
301+
pattern: digests-cloudquery-*
153302
merge-multiple: true
154303
- name: Login to GHCR
155304
uses: docker/login-action@v3
@@ -191,4 +340,4 @@ jobs:
191340
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
192341
- name: Inspect image
193342
run: |
194-
docker buildx imagetools inspect ${{ matrix.images }}:${{ steps.meta.outputs.version }}
343+
docker buildx imagetools inspect ${{ matrix.images }}:${{ steps.meta.outputs.version }}

charts/console-rapid/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v2
22
name: console-rapid
33
description: rapid channel chart for the plural console (used for testing)
44
appVersion: 0.11.28
5-
version: 0.3.132
5+
version: 0.3.133
66
dependencies:
77
- name: kas
88
version: 0.3.0

charts/console/templates/cloud-query/deployment.yaml

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,20 @@ spec:
4242
{{- toYaml . | nindent 8 }}
4343
{{- end }}
4444
containers:
45+
- name: cloud-query-db
46+
image: "{{ .Values.cloudQuery.database.image.repository }}:{{ .Values.cloudQuery.database.image.tag | default (printf "v%s" .Chart.AppVersion) }}"
47+
imagePullPolicy: {{ .Values.cloudQuery.database.image.pullPolicy }}
48+
env:
49+
- name: POSTGRES_PASSWORD
50+
valueFrom:
51+
secretKeyRef:
52+
{{- if .Values.cloudQuery.database.password.existingSecret.name }}
53+
name: {{ .Values.cloudQuery.database.password.existingSecret.name }}
54+
key: {{ .Values.cloudQuery.database.password.existingSecret.key }}
55+
{{- else }}
56+
name: {{ include "console.cloudquery.db.secret" . }}
57+
key: password
58+
{{- end }}
4559
- name: cloud-query
4660
{{- with .Values.cloudQuery.securityContext }}
4761
securityContext:
@@ -72,25 +86,23 @@ spec:
7286
livenessProbe:
7387
{{- toYaml . | nindent 12 }}
7488
{{- end }}
75-
{{- with .Values.cloudQuery.readinessProbe }}
7689
readinessProbe:
77-
{{- toYaml . | nindent 12 }}
78-
{{- end }}
90+
httpGet:
91+
path: /healthz
92+
port: 8080
93+
initialDelaySeconds: 5
94+
periodSeconds: 30
95+
failureThreshold: 1
7996
{{- with .Values.cloudQuery.resources }}
8097
resources:
8198
{{- toYaml . | nindent 12 }}
8299
{{- end }}
83-
volumeMounts:
84-
- name: {{ .Values.cloudQuery.database.volume.name }}
85-
mountPath: {{ .Values.cloudQuery.database.volume.mountPath }}
86100
{{- with .Values.cloudQuery.volumeMounts }}
101+
volumeMounts:
87102
{{- toYaml . | nindent 12 }}
88103
{{- end }}
89-
volumes:
90-
- name: {{ .Values.cloudQuery.database.volume.name }}
91-
emptyDir:
92-
medium: {{ .Values.cloudQuery.database.volume.medium }}
93104
{{- with .Values.cloudQuery.volumes }}
105+
volumes:
94106
{{- toYaml . | nindent 8 }}
95107
{{- end }}
96108
{{- with .Values.cloudQuery.nodeSelector }}

0 commit comments

Comments
 (0)