Skip to content

0.2.13 alpha - fix csv generation for private registry utility and add pdb for eventbus #57

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions charts/gitops-runtime/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
appVersion: 0.1.30
description: A Helm chart for Codefresh gitops runtime
name: gitops-runtime
version: 0.2.12-alpha
version: 0.2.13-alpha
home: https://github.com/codefresh-io/gitops-runtime-helm
icon: https://avatars1.githubusercontent.com/u/11412079?v=3
keywords:
Expand All @@ -15,8 +15,10 @@ annotations:
artifacthub.io/alternativeName: "codefresh-gitops-runtime"
artifacthub.io/prerelease: "true"
artifacthub.io/changes: |
- kind: changed
description: re-enabled pre-install hook by default, after validation code was fixed.
- kind: fixed
description: csv generation for private registry utility
- kind: added
description: pdb for eventbus
dependencies:
- name: argo-cd
repository: https://codefresh-io.github.io/argo-helm
Expand Down
11 changes: 6 additions & 5 deletions charts/gitops-runtime/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## Codefresh gitops runtime
![Version: 0.2.12-alpha](https://img.shields.io/badge/Version-0.2.12--alpha-informational?style=flat-square) ![AppVersion: 0.1.30](https://img.shields.io/badge/AppVersion-0.1.30-informational?style=flat-square)
![Version: 0.2.13-alpha](https://img.shields.io/badge/Version-0.2.13--alpha-informational?style=flat-square) ![AppVersion: 0.1.30](https://img.shields.io/badge/AppVersion-0.1.30-informational?style=flat-square)

## Codefresh official documentation:
Prior to running the installation please see the official documentation at: https://codefresh.io/docs/docs/installation/gitops/hybrid-gitops-helm-installation/
Expand All @@ -15,7 +15,7 @@ We have created a helper utility to resolve this issue:
The utility is packaged in a container image. Below are instructions on executing the utility using Docker:

```
docker run -v <output_dir>:/output quay.io/codefresh/gitops-runtime-private-registry-utils:0.2.12-alpha <local_registry>
docker run -v <output_dir>:/output quay.io/codefresh/gitops-runtime-private-registry-utils:0.2.13-alpha <local_registry>
```
`output_dir` - is a local directory where the utility will output files. <br>
`local_registry` - is your local registry where you want to mirror the images to
Expand Down Expand Up @@ -142,10 +142,11 @@ The utility will output 4 files into the folder:
| global.codefresh.userToken | object | `{"secretKeyRef":{},"token":""}` | User token. Used for runtime registration against the patform. One of token (for plain text value) or secretKeyRef must be provided. |
| global.codefresh.userToken.secretKeyRef | object | `{}` | User token that references an existing secret containing the token. |
| global.codefresh.userToken.token | string | `""` | User token in plain text. The chart creates and manages the secret for this token. |
| global.runtime | object | `{"cluster":"https://kubernetes.default.svc","eventBus":{"nats":{"native":{"auth":"token","containerTemplate":{"resources":{"limits":{"cpu":"500m","ephemeral-storage":"2Gi","memory":"4Gi"},"requests":{"cpu":"200m","ephemeral-storage":"2Gi","memory":"1Gi"}}},"maxPayload":"4MB","replicas":3}}},"eventBusName":"codefresh-eventbus","gitCredentials":{"password":{"secretKeyRef":{},"value":null},"username":"username"},"ingress":{"annotations":{},"className":"nginx","enabled":false,"hosts":[],"protocol":"https","tls":[]},"ingressUrl":"","name":null}` | Runtime level settings |
| global.runtime | object | `{"cluster":"https://kubernetes.default.svc","eventBus":{"name":"codefresh-eventbus","nats":{"native":{"auth":"token","containerTemplate":{"resources":{"limits":{"cpu":"500m","ephemeral-storage":"2Gi","memory":"4Gi"},"requests":{"cpu":"200m","ephemeral-storage":"2Gi","memory":"1Gi"}}},"maxPayload":"4MB","replicas":3}},"pdb":{"enabled":true,"minAvailable":2}},"gitCredentials":{"password":{"secretKeyRef":{},"value":null},"username":"username"},"ingress":{"annotations":{},"className":"nginx","enabled":false,"hosts":[],"protocol":"https","tls":[]},"ingressUrl":"","name":null}` | Runtime level settings |
| global.runtime.cluster | string | `"https://kubernetes.default.svc"` | Runtime cluster. Should not be changed. |
| global.runtime.eventBus | object | `{"nats":{"native":{"auth":"token","containerTemplate":{"resources":{"limits":{"cpu":"500m","ephemeral-storage":"2Gi","memory":"4Gi"},"requests":{"cpu":"200m","ephemeral-storage":"2Gi","memory":"1Gi"}}},"maxPayload":"4MB","replicas":3}}}` | EventBus spec |
| global.runtime.eventBusName | string | `"codefresh-eventbus"` | Eventbus name |
| global.runtime.eventBus.name | string | `"codefresh-eventbus"` | Eventbus name |
| global.runtime.eventBus.pdb | object | `{"enabled":true,"minAvailable":2}` | Pod disruption budget for the eventbus |
| global.runtime.eventBus.pdb.minAvailable | int | `2` | Minimum number of available eventbus pods. For eventbus to stay functional the majority of its replicas should always be available. |
| global.runtime.gitCredentials | object | `{"password":{"secretKeyRef":{},"value":null},"username":"username"}` | Git credentials runtime. Runtime is not fully functional without those credentials. If not provided through the installation, they must be provided through the Codefresh UI. |
| global.runtime.gitCredentials.password | object | `{"secretKeyRef":{},"value":null}` | Password. If using GitHub token, please provide it here. |
| global.runtime.gitCredentials.password.secretKeyRef | object | `{}` | secretKeyReference for Git credentials password. Provide name and key fields. |
Expand Down
13 changes: 0 additions & 13 deletions charts/gitops-runtime/templates/argo-events/eventbus.yaml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{{- $eventBusName := default "codefresh-eventbus" .Values.global.runtime.eventBus.name }}
{{- $eventBusSpec := .Values.global.runtime.eventBus }}
{{/* Remove name from eventbus spec */}}
{{- if hasKey $eventBusSpec "name" }}
{{- $eventBusSpec = unset $eventBusSpec "name" }}
{{- end }}
{{/* Remove pdb from eventbus spec */}}
{{- if hasKey $eventBusSpec "pdb" }}
{{- $eventBusSpec = unset $eventBusSpec "pdb" }}
{{- end }}
apiVersion: argoproj.io/v1alpha1
kind: EventBus
metadata:
name: {{ $eventBusName }}
annotations:
argocd.argoproj.io/sync-wave: "2"
labels:
app.kubernetes.io/part-of: argo-events
codefresh.io/internal: "true"
spec:
{{- $eventBusSpec | toYaml | nindent 2}}
12 changes: 12 additions & 0 deletions charts/gitops-runtime/templates/eventbus/pdb.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{- $eventBusName := default "codefresh-eventbus" .Values.global.runtime.eventBus.name }}
{{- if .Values.global.runtime.eventBus.pdb.enabled }}
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: {{ $eventBusName }}
spec:
minAvailable: 2
selector:
matchLabels:
eventbus-name: {{ $eventBusName }}
{{- end }}
11 changes: 8 additions & 3 deletions charts/gitops-runtime/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,15 @@ global:
# -- secretKeyReference for Git credentials password. Provide name and key fields.
secretKeyRef: {}

# -- Eventbus name
eventBusName: 'codefresh-eventbus'
# -- EventBus spec
# -- Runtime eventbus
eventBus:
# -- Eventbus name
name: 'codefresh-eventbus'
# -- Pod disruption budget for the eventbus
pdb:
enabled: true
# -- Minimum number of available eventbus pods. For eventbus to stay functional the majority of its replicas should always be available.
minAvailable: 2
nats:
native:
replicas: 3
Expand Down
5 changes: 3 additions & 2 deletions scripts/private-registry-utils/private-registry-utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ def replace_registry_in_image(image_string, new_registry):
parts[0] = new_registry
return '/'.join(parts)
else:
return new_registry + '/' + image_string
newimage = new_registry + '/' + image_string
return newimage

# Try to identify whether a string is a docker image
def is_docker_image(image_string):
Expand Down Expand Up @@ -86,7 +87,7 @@ def recurse_get_source_target(currValue,new_registry,lstSourceTarget):
recurse_get_source_target(item,new_registry,lstSourceTarget)
elif type(currValue) is str:
if is_docker_image(currValue):
lstSourceTarget.append({"source_image": currValue, "target_image": replace_registry_in_image(sourceImage,new_registry)})
lstSourceTarget.append({"source_image": currValue, "target_image": replace_registry_in_image(currValue,new_registry)})

def generate_file_from_field(list_of_dicts, field_name, output_file):
with open(output_file, 'w+') as file:
Expand Down