Skip to content

Commit 8e02655

Browse files
authoredJun 12, 2023
CR-18322-validate-values (#51)
* cleanup dockerfile (no need for argocd, update cli-v2) * added `installer.skipValidation` * run pre-install only once, keep failed pod for 5m * updated chart version to `0.2.10-alpha`
1 parent 2296662 commit 8e02655

File tree

9 files changed

+105
-14
lines changed

9 files changed

+105
-14
lines changed
 

‎README.md

+10
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,13 @@ See official documentation here: https://codefresh.io/docs/docs/installation/git
77

88
1. Make sure kubectl is on the runtime cluster context
99
2. Run scripts/adopt-crds.sh [runtime Helm release name] [Runtime Namespace]
10+
11+
## pre-install hook failure:
12+
13+
run
14+
```shell
15+
kubectl logs jobs/validate-values -n ${NAMESPACE}
16+
```
17+
(use your selected namespace)
18+
the output should help find the error in the values file.
19+
in order to install while skipping the values validation, install with `--set installer.skipValidation="true"` (or set it in values file)

‎charts/gitops-runtime/Chart.yaml

+3-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v2
22
appVersion: 0.1.30
33
description: A Helm chart for Codefresh gitops runtime
44
name: gitops-runtime
5-
version: 0.2.9-alpha
5+
version: 0.2.10-alpha
66
home: https://github.com/codefresh-io/gitops-runtime-helm
77
icon: https://avatars1.githubusercontent.com/u/11412079?v=3
88
keywords:
@@ -15,10 +15,8 @@ annotations:
1515
artifacthub.io/alternativeName: "codefresh-gitops-runtime"
1616
artifacthub.io/prerelease: "true"
1717
artifacthub.io/changes: |
18-
- kind: changed
19-
description: Updated `app-proxy` to `1.2268.0`
20-
- kind: changed
21-
description: updated default value of workflow-reporter SA to "codefresh-sa"
18+
- kind: added
19+
description: pre-install hook to valide values - fails installation quickly in case anything is wrong or missing
2220
dependencies:
2321
- name: argo-cd
2422
repository: https://codefresh-io.github.io/argo-helm

‎charts/gitops-runtime/README.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
## Codefresh gitops runtime
2-
![Version: 0.2.9-alpha](https://img.shields.io/badge/Version-0.2.9--alpha-informational?style=flat-square) ![AppVersion: 0.1.30](https://img.shields.io/badge/AppVersion-0.1.30-informational?style=flat-square)
2+
![Version: 0.2.10-alpha](https://img.shields.io/badge/Version-0.2.10--alpha-informational?style=flat-square) ![AppVersion: 0.1.30](https://img.shields.io/badge/AppVersion-0.1.30-informational?style=flat-square)
33

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

1717
```
18-
docker run -v <output_dir>:/output quay.io/codefresh/gitops-runtime-private-registry-utils:0.2.9-alpha <local_registry>
18+
docker run -v <output_dir>:/output quay.io/codefresh/gitops-runtime-private-registry-utils:0.2.10-alpha <local_registry>
1919
```
2020
`output_dir` - is a local directory where the utility will output files. <br>
2121
`local_registry` - is your local registry where you want to mirror the images to
@@ -157,7 +157,8 @@ The utility will output 4 files into the folder:
157157
| global.runtime.ingress.protocol | string | `"https"` | The protocol that Codefresh platform will use to access the runtime ingress. Can be http or https. |
158158
| global.runtime.ingressUrl | string | `""` | Explicit url for runtime ingress. Provide this value only if you don't want the chart to create and ingress (global.runtime.ingress.enabled=false) and tunnel-client is not used (tunnel-client.enabled=false) |
159159
| global.runtime.name | string | `nil` | Runtime name. Must be unique per platform account. |
160-
| installer | object | `{"image":{"pullPolicy":"IfNotPresent","repository":"quay.io/codefresh/gitops-runtime-installer","tag":""}}` | Runtime installer used for running hooks and checks on the release |
160+
| installer | object | `{"image":{"pullPolicy":"IfNotPresent","repository":"quay.io/codefresh/gitops-runtime-installer","tag":""},"skipValidation":false}` | Runtime installer used for running hooks and checks on the release |
161+
| installer.skipValidation | bool | `false` | if set to true, pre-install hook will *not* run |
161162
| internal-router.affinity | object | `{}` | |
162163
| internal-router.env | object | `{}` | Environment variables - see values.yaml inside the chart for usage |
163164
| internal-router.fullnameOverride | string | `"internal-router"` | |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{{- if not .Values.installer.skipValidation }}
2+
apiVersion: rbac.authorization.k8s.io/v1
3+
kind: ClusterRole
4+
metadata:
5+
name: validate-values-cr
6+
annotations:
7+
helm.sh/hook: pre-install,pre-upgrade
8+
helm.sh/hook-delete-policy: hook-succeeded,before-hook-creation,hook-failed
9+
helm.sh/hook-weight: "-10"
10+
rules:
11+
- apiGroups:
12+
- "*"
13+
resources:
14+
- "*"
15+
verbs:
16+
- "*"
17+
---
18+
apiVersion: rbac.authorization.k8s.io/v1
19+
kind: ClusterRoleBinding
20+
metadata:
21+
name: validate-values-crb
22+
annotations:
23+
helm.sh/hook: pre-install,pre-upgrade
24+
helm.sh/hook-delete-policy: hook-succeeded,before-hook-creation,hook-failed
25+
helm.sh/hook-weight: "-10"
26+
roleRef:
27+
apiGroup: rbac.authorization.k8s.io
28+
kind: ClusterRole
29+
name: validate-values-cr
30+
subjects:
31+
- kind: ServiceAccount
32+
name: validate-values-sa
33+
namespace: {{ .Release.Namespace }}
34+
---
35+
apiVersion: v1
36+
kind: ServiceAccount
37+
metadata:
38+
name: validate-values-sa
39+
annotations:
40+
helm.sh/hook: pre-install,pre-upgrade
41+
helm.sh/hook-delete-policy: hook-succeeded,before-hook-creation,hook-failed
42+
helm.sh/hook-weight: "-10"
43+
{{- end }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{{- if not .Values.installer.skipValidation }}
2+
apiVersion: batch/v1
3+
kind: Job
4+
metadata:
5+
name: validate-values
6+
annotations:
7+
helm.sh/hook: pre-install,pre-upgrade
8+
helm.sh/hook-delete-policy: hook-succeeded,before-hook-creation
9+
spec:
10+
backoffLimit: 0
11+
ttlSecondsAfterFinished: 300
12+
template:
13+
spec:
14+
serviceAccount: validate-values-sa
15+
restartPolicy: Never
16+
containers:
17+
- name: validate-values
18+
image: "{{ .Values.installer.image.repository }}:{{ .Values.installer.image.tag | default .Chart.Version }}"
19+
imagePullPolicy: {{ .Values.installer.image.pullPolicy }}
20+
env:
21+
- name: NAMESPACE
22+
valueFrom:
23+
fieldRef:
24+
fieldPath: metadata.namespace
25+
- name: VERSION
26+
value: {{ .Chart.Version }}
27+
command: ["sh", "-c"]
28+
args:
29+
- |
30+
echo {{ .Values | toYaml | quote }} > values.yaml
31+
cf helm validate --values values.yaml --namespace ${NAMESPACE} --version ${VERSION} --hook --log-level debug
32+
{{- end }}

‎charts/gitops-runtime/templates/hooks/pre-uninstall/cleanup-resources.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ spec:
2121
kubectl patch EventBus $(kubectl get eventbus -l codefresh.io/internal=true | awk 'NR>1{print $1}' | xargs) -p '{"metadata":{"finalizers":null}}' --type=merge && \
2222
kubectl patch Eventsource $(kubectl get EventSource -l codefresh.io/internal=true | awk 'NR>1{print $1}' | xargs) -p '{"metadata":{"finalizers":null}}' --type=merge && \
2323
kubectl patch Sensor $(kubectl get Sensor -l codefresh.io/internal=true | awk 'NR>1{print $1}' | xargs) -p '{"metadata":{"finalizers":null}}' --type=merge ;
24-
return 0
24+
return 0

‎charts/gitops-runtime/templates/hooks/pre-uninstall/rbac.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ metadata:
3434
name: runtime-cleanup
3535
annotations:
3636
"helm.sh/hook": pre-delete
37-
"helm.sh/hook-delete-policy": hook-succeeded,before-hook-creation,hook-failed
37+
"helm.sh/hook-delete-policy": hook-succeeded,before-hook-creation,hook-failed

‎charts/gitops-runtime/values.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ global:
9999
# -------------------------------------------------------------------------------------------------------------------------
100100
# -- Runtime installer used for running hooks and checks on the release
101101
installer:
102+
# -- if set to true, pre-install hook will *not* run
103+
skipValidation: false
102104
image:
103105
repository: quay.io/codefresh/gitops-runtime-installer
104106
tag: ""

‎installer-image/Dockerfile

+9-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
FROM --platform=$BUILDPLATFORM debian:bullseye-slim
2-
RUN apt-get update -y && apt-get install curl -y
3-
ARG CF_CLI_VERSION=v0.1.25
4-
ARG KUBECTL_VERSION=v1.26.0
2+
3+
ARG CF_CLI_VERSION=v0.1.48
4+
ARG KUBECTL_VERSION=v1.27.2
55
ARG TARGETARCH
6+
7+
RUN apt-get update && apt-get install curl -y
68
RUN curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/${CF_CLI_VERSION}/cf-linux-${TARGETARCH}.tar.gz | tar zx && mv ./cf-linux-${TARGETARCH} /usr/local/bin/cf
79
RUN curl -LO https://dl.k8s.io/release/${KUBECTL_VERSION}/bin/linux/${TARGETARCH}/kubectl && chmod +x kubectl && mv ./kubectl /usr/local/bin/kubectl
8-
USER 1000
10+
11+
RUN adduser --shell /bin/bash codefresh
12+
USER codefresh
13+
WORKDIR /home/codefresh

0 commit comments

Comments
 (0)
Please sign in to comment.