Skip to content

Commit 0ad8a18

Browse files
feat: system runtimes in git (#586)
1 parent effa98b commit 0ad8a18

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+758
-137
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
global:
2+
runtimeName: system/test-ci-runtime
3+
4+
runtime:
5+
agent: false
6+
inCluster: false
7+
description: "Test runtime created by venona-helm-chart-ci pipeline"
8+
kubeconfigFilePath: /opt/codefresh/kubeconfigs/prod-ue1-runtime-free-1/kubeconfig
9+
kubeconfigName: prod-ue1-runtime-free-1
10+
dind:
11+
pvcs:
12+
dind:
13+
storageClassName: dind-ebs-csi-us-east-1a-workflows
14+
nodeSelector:
15+
node-type: dind
16+
topology.kubernetes.io/zone: us-east-1a
17+
tolerations:
18+
- key: codefresh.io
19+
operator: Equal
20+
value: dinds
21+
effect: NoSchedule
22+
schedulerName: default-scheduler
23+
engine:
24+
nodeSelector:
25+
node-type: engine
26+
topology.kubernetes.io/zone: us-east-1a
27+
tolerations:
28+
- key: codefresh.io
29+
operator: Equal
30+
value: engines
31+
effect: NoSchedule
32+
schedulerName: default-scheduler
33+
accounts:
34+
- 5672d8deb6724b6e359adf62 # codefresh-inc
35+
36+
volumeProvisioner:
37+
enabled: false
38+
39+
monitor:
40+
enabled: false
41+
42+
appProxy:
43+
enabled: false

charts/cf-runtime/Chart.yaml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apiVersion: v2
22
description: A Helm chart for Codefresh Runner
33
name: cf-runtime
4-
version: 7.7.4
4+
version: 7.8.0
55
keywords:
66
- codefresh
77
- runner
@@ -17,14 +17,16 @@ annotations:
1717
artifacthub.io/containsSecurityUpdates: "true"
1818
# Supported kinds: `added`, `changed`, `deprecated`, `removed`, `fixed`, `security`:
1919
artifacthub.io/changes: |
20-
- kind: security
21-
description: "updated pikolo with security fixes"
22-
- kind: security
23-
description: "updated compose with security fixes"
24-
- kind: security
25-
description: "updated cf-docker-pusher with security fixes"
26-
- kind: security
27-
description: "updated cf-cosign-image-signer with security fixes"
20+
- kind: changed
21+
description: "(on-premise) Fix kubeconfigFilePath for agentless runtime"
22+
- kind: added
23+
description: "(on-premise) Add option to create extra agentless runtimes"
24+
- kind: added
25+
description: "Add cronjob to continuously patch runtime spec"
26+
- kind: fixed
27+
description: "Fix missing codefresh-dind-config ConfigMap in runtime spec"
28+
- kind: changed
29+
description: "Misc templates renaming"
2830
dependencies:
2931
- name: cf-common
3032
repository: oci://quay.io/codefresh/charts

charts/cf-runtime/README.md

Lines changed: 13 additions & 5 deletions
Large diffs are not rendered by default.

charts/cf-runtime/README.md.gotmpl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Helm chart for deploying [Codefresh Runner](https://codefresh.io/docs/docs/insta
1717
- [To 4.x](#to-4-x)
1818
- [To 5.x](#to-5-x)
1919
- [To 6.x](#to-6-x)
20-
- [To 7.x](#to-7-x)
20+
- [To 7.x](#to-7-x)
2121
- [Architecture](#architecture)
2222
- [Configuration](#configuration)
2323
- [EBS backend volume configuration in AWS](#ebs-backend-volume-configuration)
@@ -272,7 +272,7 @@ runtime:
272272
digest: sha256:d547c2044c1488e911ff726462cc417adf2dda731cafd736493c4de4eb9e357b
273273
```
274274

275-
Which means any overrides for tags won't be used and underlying Kubernetes runtime will pull the image by the digest.
275+
Which means any overrides for tags won't be used and underlying Kubernetes runtime will pull the image by the digest.
276276

277277
See [Pull an image by digest (immutable identifier)](https://docs.docker.com/reference/cli/docker/image/pull/#pull-an-image-by-digest-immutable-identifier)
278278

@@ -957,7 +957,7 @@ NAMESPACE=cf-runtime
957957
CLUSTER_NAME=prod-ue1-some-cluster-name
958958
CURRENT_CONTEXT=$(kubectl config current-context)
959959

960-
USER_TOKEN_VALUE=$(kubectl -n cf-runtime get secret/codefresh-runtime-user-token -o=go-template='{{ `{{.data.token}}` }}' | base64 --decode)
960+
USER_TOKEN_VALUE=$(kubectl -n $NAMESPACE get secret/codefresh-runtime-user-token -o=go-template='{{ `{{.data.token}}` }}' | base64 --decode)
961961
CURRENT_CLUSTER=$(kubectl config view --raw -o=go-template='{{ `{{range .contexts}}{{if eq .name "'''${CURRENT_CONTEXT}'''"}}{{ index .context "cluster" }}{{end}}{{end}}` }}')
962962
CLUSTER_CA=$(kubectl config view --raw -o=go-template='{{ `{{range .clusters}}{{if eq .name "'''${CURRENT_CLUSTER}'''"}}"{{with index .cluster "certificate-authority-data" }}{{.}}{{end}}"{{ end }}{{ end }}` }}')
963963
CLUSTER_SERVER=$(kubectl config view --raw -o=go-template='{{ `{{range .clusters}}{{if eq .name "'''${CURRENT_CLUSTER}'''"}}{{ .cluster.server }}{{end}}{{ end }}` }}')
@@ -984,7 +984,7 @@ clusters:
984984
certificate-authority-data: ${CLUSTER_CA}
985985
server: ${CLUSTER_SERVER}
986986
users:
987-
- name: ${CLUSTER_NAME}
987+
- name: codefresh-runtime-user
988988
user:
989989
token: ${USER_TOKEN_VALUE}
990990
EOF

charts/cf-runtime/files/configure-dind-certs.sh

100644100755
File mode changed.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/bash
2+
3+
set -x
4+
5+
NAMESPACE=$1
6+
if [ -z "$NAMESPACE" ]; then
7+
echo "Usage: $0 <namespace> <cluster-name>"
8+
exit 1
9+
fi
10+
CLUSTER_NAME=$2
11+
if [ -z "$CLUSTER_NAME" ]; then
12+
echo "Usage: $0 <namespace> <cluster-name>"
13+
exit 1
14+
fi
15+
CURRENT_CONTEXT=$(kubectl config current-context)
16+
17+
USER_TOKEN_VALUE=$(kubectl -n $NAMESPACE get secret/codefresh-runtime-user-token -o=go-template='{{.data.token}}' | base64 --decode)
18+
CURRENT_CLUSTER=$(kubectl config view --raw -o=go-template='{{range .contexts}}{{if eq .name "'''${CURRENT_CONTEXT}'''"}}{{ index .context "cluster" }}{{end}}{{end}}')
19+
CLUSTER_CA=$(kubectl config view --raw -o=go-template='{{range .clusters}}{{if eq .name "'''${CURRENT_CLUSTER}'''"}}"{{with index .cluster "certificate-authority-data" }}{{.}}{{end}}"{{ end }}{{ end }}')
20+
CLUSTER_SERVER=$(kubectl config view --raw -o=go-template='{{range .clusters}}{{if eq .name "'''${CURRENT_CLUSTER}'''"}}{{ .cluster.server }}{{end}}{{ end }}')
21+
22+
export -p USER_TOKEN_VALUE CURRENT_CONTEXT CURRENT_CLUSTER CLUSTER_CA CLUSTER_SERVER CLUSTER_NAME
23+
24+
cat << EOF > $CLUSTER_NAME-kubeconfig
25+
apiVersion: v1
26+
kind: Config
27+
current-context: ${CLUSTER_NAME}
28+
contexts:
29+
- name: ${CLUSTER_NAME}
30+
context:
31+
cluster: ${CLUSTER_NAME}
32+
user: codefresh-runtime-user
33+
namespace: ${NAMESPACE}
34+
clusters:
35+
- name: ${CLUSTER_NAME}
36+
cluster:
37+
certificate-authority-data: ${CLUSTER_CA}
38+
server: ${CLUSTER_SERVER}
39+
users:
40+
- name: codefresh-runtime-user
41+
user:
42+
token: ${USER_TOKEN_VALUE}
43+
EOF
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/bin/bash
2+
3+
set -x
4+
5+
AGENT=${AGENT:-true}
6+
API_HOST=${API_HOST:-""}
7+
API_KEY=${API_KEY:-""}
8+
9+
(set +x; codefresh auth create-context --api-key $API_KEY --url $API_HOST)
10+
11+
if [[ "$AGENT" == "true" ]]; then
12+
patch_type="re"
13+
else
14+
patch_type="sys-re"
15+
fi
16+
17+
modify_accounts() {
18+
local runtime_name_encoded
19+
runtime_name_encoded=$(yq '.metadata.name' "$1" | jq -r @uri)
20+
local accounts
21+
accounts=$(yq '.accounts' "$1")
22+
23+
if [[ -n $accounts ]]; then
24+
local payload
25+
payload=$(echo "$accounts" | jq '{accounts: .}')
26+
set +x
27+
curl -X PUT \
28+
-H "Content-Type: application/json" \
29+
-H "Authorization: $API_KEY" \
30+
-d "$payload" \
31+
"$API_HOST/api/admin/runtime-environments/account/modify/$runtime_name_encoded"
32+
else
33+
echo "No accounts to add for $1"
34+
fi
35+
}
36+
37+
for runtime in /opt/codefresh/*.yaml; do
38+
if [[ -f $runtime ]]; then
39+
codefresh patch $patch_type -f $runtime
40+
modify_accounts "$runtime"
41+
fi
42+
done
43+
44+
for runtime in /opt/codefresh/runtime.d/system/*.yaml; do
45+
if [[ -f $runtime ]]; then
46+
codefresh patch sys-re -f $runtime
47+
modify_accounts "$runtime"
48+
fi
49+
done

charts/cf-runtime/templates/_components/event-exporter/_helpers.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this
1111
If release name contains chart name it will be used as a full name.
1212
*/}}
1313
{{- define "event-exporter.fullname" -}}
14-
{{- printf "%s-%s" (include "cf-runtime.fullname" .) "event-exporter" | trunc 63 | trimSuffix "-" }}
14+
{{- coalesce .Values.name (printf "%s-%s" (include "cf-runtime.fullname" .) "event-exporter" | trunc 63 | trimSuffix "-") }}
1515
{{- end }}
1616

1717
{{/*

charts/cf-runtime/templates/_components/runner/_helpers.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this
1111
If release name contains chart name it will be used as a full name.
1212
*/}}
1313
{{- define "runner.fullname" -}}
14-
{{- printf "%s-%s" (include "cf-runtime.fullname" .) "runner" | trunc 63 | trimSuffix "-" }}
14+
{{- coalesce .Values.name (printf "%s-%s" (include "cf-runtime.fullname" .) "runner" | trunc 63 | trimSuffix "-") }}
1515
{{- end }}
1616

1717
{{/*

charts/cf-runtime/templates/_components/volume-provisioner/_helpers.tpl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this
1111
If release name contains chart name it will be used as a full name.
1212
*/}}
1313
{{- define "dind-volume-provisioner.fullname" -}}
14-
{{- printf "%s-%s" (include "cf-runtime.fullname" .) "volume-provisioner" | trunc 63 | trimSuffix "-" }}
14+
{{- coalesce .Values.name (printf "%s-%s" (include "cf-runtime.fullname" .) "volume-provisioner" | trunc 63 | trimSuffix "-") }}
1515
{{- end }}
1616

1717
{{- define "dind-volume-cleanup.fullname" -}}
18-
{{- printf "%s-%s" (include "cf-runtime.fullname" .) "volume-cleanup" | trunc 52 | trimSuffix "-" }}
18+
{{- coalesce .Values.name (printf "%s-%s" (include "cf-runtime.fullname" .) "volume-cleanup" | trunc 52 | trimSuffix "-") }}
1919
{{- end }}
2020

2121
{{- define "dind-lv-monitor.fullname" -}}
22-
{{- printf "%s-%s" (include "cf-runtime.fullname" .) "lv-monitor" | trunc 63 | trimSuffix "-" }}
22+
{{- coalesce .Values.name (printf "%s-%s" (include "cf-runtime.fullname" .) "lv-monitor" | trunc 63 | trimSuffix "-") }}
2323
{{- end }}
2424

2525
{{/*
@@ -89,5 +89,5 @@ Create the name of the service account to use
8989
{{- end }}
9090

9191
{{- define "dind-volume-provisioner.storageClassName" }}
92-
{{- printf "dind-local-volumes-runner-%s" .Release.Namespace }}
93-
{{- end }}
92+
{{- coalesce .Values.storage.fullnameOverride (printf "dind-local-volumes-runner-%s" .Release.Namespace) }}
93+
{{- end }}

0 commit comments

Comments
 (0)