Skip to content

Commit 669a7e0

Browse files
authored
Merge pull request #10 from jpopelka/import-images
Helm Chart for import-images cron job
2 parents 7389fa7 + bb167b7 commit 669a7e0

File tree

24 files changed

+253
-66
lines changed

24 files changed

+253
-66
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Deploy import-images cron job
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
paths:
9+
- 'helm-charts/import-images/**/*.yaml'
10+
- 'values/import-images/*.yaml'
11+
12+
jobs:
13+
deploy:
14+
# To not run in forks
15+
if: github.repository_owner == 'packit'
16+
runs-on: ubuntu-latest
17+
environment: prod
18+
env:
19+
OC_SERVER: https://api.auto-prod.gi0n.p1.openshiftapps.com:6443
20+
strategy:
21+
matrix:
22+
project: [packit-prod, stream-prod, fedora-source-git-prod]
23+
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v3
27+
28+
- name: Deploy
29+
run: |
30+
if [ ${{ matrix.project }} == 'packit-prod' ]; then
31+
TOKEN=${{ secrets.PACKIT_PROD_TOKEN }}
32+
elif [ ${{ matrix.project }} == 'stream-prod' ]; then
33+
TOKEN=${{ secrets.STREAM_PROD_TOKEN }}
34+
elif [ ${{ matrix.project }} == 'fedora-source-git-prod' ]; then
35+
TOKEN=${{ secrets.FEDORA_SOURCE_GIT_PROD_TOKEN }}
36+
fi
37+
oc login --token=$TOKEN --server=$OC_SERVER
38+
make -C values/import-images/ install PROJECT=${{ matrix.project }}

.github/workflows/release.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ on:
77

88
jobs:
99
release:
10+
# To not run in forks
11+
if: github.repository_owner == 'packit'
1012
runs-on: ubuntu-latest
1113
steps:
1214
- name: Checkout
13-
uses: actions/checkout@v2
15+
uses: actions/checkout@v3
1416
with:
1517
fetch-depth: 0
1618

@@ -19,14 +21,9 @@ jobs:
1921
git config user.name "$GITHUB_ACTOR"
2022
git config user.email "[email protected]"
2123
22-
- name: Install Helm
23-
uses: azure/setup-helm@v3
24-
with:
25-
token: ${{ secrets.GITHUB_TOKEN }}
26-
2724
- name: Run chart-releaser
2825
uses: helm/chart-releaser-action@v1
2926
with:
30-
charts_dir: ocp-helm-charts
27+
charts_dir: helm-charts
3128
env:
3229
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

.pre-commit-config.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
repos:
66
- repo: https://github.com/pre-commit/pre-commit-hooks
7-
rev: v4.3.0
7+
rev: v4.4.0
88
hooks:
99
- id: check-merge-conflict
1010
- id: check-symlinks
@@ -23,3 +23,7 @@ repos:
2323
args:
2424
- https://github.com/packit/udp.git
2525
stages: [manual, push]
26+
27+
ci:
28+
# requires helm binary
29+
skip: [helmlint]

Makefile

Lines changed: 0 additions & 5 deletions
This file was deleted.

README.md

Lines changed: 15 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,19 @@
1-
# [Unified Openshift Deployment Process](https://docs.google.com/presentation/d/1MlLuuawzxJg6U15zbPby6JAtNNEWZAhfGEWNcpYSWeo)
1+
# Helm Charts
22

3-
for the [Packit Service Validation](https://github.com/packit/deployment/tree/main/cron-jobs/packit-service-validation).
3+
for
4+
* [Packit Service Validation cron job](https://github.com/packit/deployment/tree/main/cron-jobs/packit-service-validation)
5+
* [Import-images cron job](https://github.com/packit/deployment/tree/main/cron-jobs/import-images)
46

5-
To deploy the *Packit Service Validation* through *Helm* follow this steps:
7+
## Deployment
68

7-
### Setup deployment
9+
All charts are deployed automatically via GitHub/Gitlab CI/CI.
810

9-
Helm uses an **image** created through a GitHub action and pushed to Quay.io,
10-
the **tag** for this image is the first *7 digit for the commit SHA* of the packit/deployment repo.
11+
For instructions how to do it manually, see
12+
* [packit-service-validation/README.md](values/packit-service-validation/README.md)
13+
* [import-images/README.md](values/import-images/README.md)
1114

12-
To use a new image update the referenced tag
13-
[here](https://github.com/packit/udp/blob/main/ocp-deployments/packit-service-validation-prod.yaml#L18).
15+
## Releases
1416

15-
### Install Helm Chart
16-
17-
Login to OpenShift cluster and switch to proper project. In case of packit-service validation
18-
it's `cyborg` project @ [PSI Cluster](https://ocp4.psi.redhat.com).
19-
20-
oc login --token=sha256~.... --server= ....
21-
oc project cyborg
22-
23-
Get secrets from Bitwarden.
24-
Sentry from `extra-vars.yml` in `secrets-packit-[prod|stg]` item and
25-
GitHub token from `Release/usercont bot` item.
26-
27-
export SENTRY=$( echo -n 'token from bitwarden' | base64 )
28-
export GITHUB=$( echo -n 'token from bitwarden' | base64 )
29-
30-
#### Install from this repo
31-
32-
make packit-service-validation-install DEPLOYMENT=[production|staging]
33-
34-
#### Install from chart repository
35-
36-
If you're going to use the chart from outside (without having this repo cloned),
37-
you can install the chart from our chart repository. You just need to have a file
38-
with keys overriding those defined in `values.yaml` with `~` value.
39-
40-
helm repo add packit https://helm.packit.dev
41-
helm repo update
42-
helm upgrade --install --cleanup-on-fail packit-service-validation packit/packit-service-validation --set secrets.sentry=${SENTRY} --set secrets.github=${GITHUB} --values your-values-file.yaml
43-
44-
### Render templates
45-
46-
If you just want to see how the rendered templates would look like:
47-
48-
make packit-service-validation-dryrun DEPLOYMENT=[production|staging]
49-
50-
### Releases
5117
There's a [release workflow](https://github.com/packit/udp/blob/main/.github/workflows/release.yml)
5218
to automate releasing the Helm charts. It uses
5319
[Helm Chart Releaser Action](https://github.com/marketplace/actions/helm-chart-releaser)
@@ -57,3 +23,8 @@ and whenever there's a new chart version, creates a corresponding GitHub release
5723
named for the chart version, adds Helm chart artifacts to the release,
5824
and creates or updates an `index.yaml` file with metadata about those releases,
5925
which is then hosted on GitHub Pages at [helm.packit.dev](https://helm.packit.dev).
26+
27+
## [Unified Openshift Deployment Process](https://docs.google.com/presentation/d/1MlLuuawzxJg6U15zbPby6JAtNNEWZAhfGEWNcpYSWeo)
28+
29+
We use images created by a GitHub workflow and pushed to Quay.io,
30+
the **tag** for an image is the first *7 digit for the commit SHA*.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
# Common backup files
9+
*.swp
10+
*.tmp
11+
*.orig
12+
*~
13+
# Various IDEs
14+
.project
15+
.idea/
16+
*.tmproj
17+
.vscode/
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: v2
2+
name: import-images
3+
description: A Helm chart for import-images CronJob
4+
type: application
5+
6+
# Increment each time you make changes
7+
# to the chart and its templates.
8+
version: 0.1.0
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# https://docs.openshift.com/container-platform/latest/rest_api/workloads_apis/cronjob-batch-v1.html
2+
apiVersion: batch/v1
3+
kind: CronJob
4+
metadata:
5+
name: {{ .Release.Name }}
6+
spec:
7+
schedule: {{ .Values.cronjob.schedule | quote }}
8+
jobTemplate:
9+
spec:
10+
template:
11+
spec:
12+
containers:
13+
- name: import-images
14+
image: "{{ .Values.image.repo }}:{{ .Values.image.tag }}"
15+
env:
16+
- name: KUBECONFIG
17+
value: /tmp/.kube/config
18+
- name: HOST
19+
value: {{ .Values.host }}
20+
- name: TOKEN
21+
valueFrom:
22+
secretKeyRef:
23+
name: {{ .Values.secret.name }}
24+
key: {{ .Values.secret.key }}
25+
- name: SERVICE
26+
value: {{ .Values.service }}
27+
- name: DEPLOYMENT
28+
value: {{ .Values.deployment }}
29+
resources:
30+
{{- toYaml .Values.resources | nindent 16 }}
31+
restartPolicy: OnFailure
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Cron job parameters
2+
cronjob:
3+
# At 02:00 on Tuesday
4+
schedule: "0 2 * * 2"
5+
6+
# Container image
7+
image:
8+
# Image repository without a tag
9+
repo: quay.io/packit/import-images
10+
# Image tag
11+
tag: ~
12+
13+
# Openshift cluster
14+
host: ~
15+
16+
# name of the secret with token of a service account used to login to the cluster
17+
secret:
18+
name: ~
19+
key: token
20+
21+
# packit / stream / fedora-source-git
22+
service: packit
23+
24+
# prod / stg
25+
deployment: prod
26+
27+
# Pod resources maximum
28+
resources:
29+
limits:
30+
cpu: "100m"
31+
memory: "80Mi"
32+
requests:
33+
cpu: "100m"
34+
memory: "80Mi"

0 commit comments

Comments
 (0)