Skip to content

Commit d88fcb4

Browse files
last fixes
1 parent 1f6c356 commit d88fcb4

File tree

9 files changed

+72
-61
lines changed

9 files changed

+72
-61
lines changed

csdp/components/workflows/kustomization.yaml

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

installer/helm/templates/job.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@ spec:
7979
secretKeyRef:
8080
name: csdp-installer
8181
key: runtime.ingressController
82+
- name: CSDP_MANAGED_RUNTIME
83+
valueFrom:
84+
secretKeyRef:
85+
name: csdp-installer
86+
key: runtime.managed
87+
optional: true
8288
- name: CSDP_GIT_INTEGRATION_PROVIDER
8389
valueFrom:
8490
secretKeyRef:

installer/helm/templates/secret.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ stringData:
1313
runtime.ingressClass: {{ .Values.csdpInstaller.runtime.ingressClass }}
1414
runtime.ingressController: {{ .Values.csdpInstaller.runtime.ingressController }}
1515
runtime.cluster: {{ .Values.csdpInstaller.runtime.cluster }}
16+
runtime.managed: {{ .Values.csdpInstaller.runtime.managed }}
1617
{{- end }}

installer/helm/values.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ csdpInstaller:
5353
ingressController: ""
5454
# Kubernetes cluster address or name that will be used to identify this cluster
5555
cluster: https://kubernetes.docker.internal:6443
56+
# Is managed runtime
57+
managed: false
5658

5759
# Controlls the spec of the csdp installer job
5860
installer:

installer/install.sh

Lines changed: 55 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ check_required_param() {
1414

1515
# Constants:
1616
CODEFRESH_SECRET_NAME="codefresh-token"
17+
CODEFRESH_CM_NAME="codefresh-cm"
1718
REPO_CREDS_SECRET_NAME="autopilot-secret"
1819
ARGOCD_TOKEN_SECRET_NAME="argocd-token"
1920
ARGOCD_INITIAL_TOKEN_SECRET_NAME="argocd-initial-admin-secret"
2021
BOOTSTRAP_APP_NAME="csdp-bootstrap"
22+
ADDITIONAL_COMPONENTS_MANAGED="\nevents-reporter"
2123
ADDITIONAL_COMPONENTS="\nevents-reporter\nrollout-reporter\nworkflow-reporter"
2224
RUNTIME_DEF_URL="https://github.com/codefresh-io/csdp-official-poc/releases/VERSION/download/runtime.yaml"
2325

@@ -37,6 +39,7 @@ CSDP_GIT_INTEGRATION_PROVIDER="${CSDP_GIT_INTEGRATION_PROVIDER:-GITHUB}"
3739
CSDP_GIT_INTEGRATION_API_URL="${CSDP_GIT_INTEGRATION_API_URL:-https://api.github.com}"
3840
CSDP_GIT_INTEGRATION_TOKEN="${CSDP_GIT_INTEGRATION_TOKEN:-${CSDP_RUNTIME_GIT_TOKEN}}"
3941
CSDP_RUNTIME_REPO_CREDS_PATTERN=`echo ${CSDP_RUNTIME_REPO} | grep --color=never -E -o '^http[s]?:\/\/([a-zA-Z0-9\.]*)'`
42+
CSDP_MANAGED_RUNTIME="${CSDP_MANAGED_RUNTIME:-false}"
4043

4144
create_codefresh_secret() {
4245
# Download runtime definition
@@ -50,12 +53,16 @@ create_codefresh_secret() {
5053
echo ""
5154

5255
# Prepare components for request
56+
57+
if [[ "$CSDP_MANAGED_RUNTIME" == "true" ]] ; then
58+
ADDITIONAL_COMPONENTS=${ADDITIONAL_COMPONENTS_MANAGED}
59+
fi
5360
COMPONENT_NAMES=`echo "$RUNTIME_DEF" | yq e '.spec.components.[].name' -`
5461
COMPONENT_NAMES=`printf "${COMPONENT_NAMES}${ADDITIONAL_COMPONENTS}" | tr '\n' ' '`
55-
COMPONENTS="[\"argo-cd\""
62+
COMPONENTS="[\"csdp-argo-cd\""
5663
for COMPONENT in $COMPONENT_NAMES
5764
do
58-
CUR_COMPONENT=`echo -n "\"${CSDP_RUNTIME_NAME}-${COMPONENT}\""`
65+
CUR_COMPONENT=`echo -n "\"csdp-${COMPONENT}\""`
5966
COMPONENTS="${COMPONENTS},${CUR_COMPONENT}"
6067
done
6168
COMPONENTS="${COMPONENTS}]"
@@ -83,6 +90,13 @@ create_codefresh_secret() {
8390
--compressed \
8491
--insecure \
8592
--data-raw "$RUNTIME_CREATE_DATA"`
93+
94+
if `echo "$RUNTIME_CREATE_RESPONSE" | jq -e 'has("errors")'`; then
95+
echo "Failed to create runtime"
96+
echo ${RUNTIME_CREATE_RESPONSE}
97+
exit 1
98+
fi
99+
86100
RUNTIME_ACCESS_TOKEN=`echo $RUNTIME_CREATE_RESPONSE | jq '.data.createRuntime.newAccessToken'`
87101
RUNTIME_ENCRYPTION_IV=`hexdump -n 16 -e '4/4 "%08x" 1 "\n"' /dev/urandom`
88102
echo " --> Runtime created!"
@@ -163,6 +177,24 @@ create_repo_creds_secret() {
163177
" | kubectl apply -f -
164178
}
165179

180+
create_managed_repo_creds_secret() {
181+
echo " --> Creating managed repo credentials secret"
182+
echo "
183+
apiVersion: v1
184+
kind: Secret
185+
metadata:
186+
labels:
187+
argocd.argoproj.io/secret-type: repository
188+
name: $REPO_CREDS_SECRET_NAME
189+
namespace: $NAMESPACE
190+
stringData:
191+
type: git
192+
url: $CSDP_RUNTIME_REPO
193+
password: $CSDP_RUNTIME_GIT_TOKEN
194+
username: username
195+
" | kubectl apply -f -
196+
}
197+
166198
create_argocd_token_secret() {
167199
echo " --> Reading ArgoCD intial admin token..."
168200
INITIAL_PASSWORD=`kubectl -n ${NAMESPACE} get secret ${ARGOCD_INITIAL_TOKEN_SECRET_NAME} -o=jsonpath="{.data.password}" | base64 -d`
@@ -214,7 +246,9 @@ create_git_integration() {
214246
echo " --> Created git integration:"
215247
echo "${GIT_INTEGRATION_CREATE_RESPONSE}"
216248
echo ""
249+
}
217250

251+
register_to_git_integration() {
218252
echo " --> Registering user to default git integration"
219253

220254
GIT_INTEGRATION_REGISTER_ARGS="{
@@ -233,7 +267,13 @@ create_git_integration() {
233267
--insecure \
234268
--data-raw "$GIT_INTEGRATION_REGISTER_DATA"`
235269

236-
echo " --> Register to default git integration:"
270+
if `echo "$GIT_INTEGRATION_REGISTER_RESPONSE" | jq -e 'has("errors")'`; then
271+
echo "Failed to register git integration"
272+
echo ${GIT_INTEGRATION_REGISTER_RESPONSE}
273+
exit 1
274+
fi
275+
276+
echo " --> Registered to default git integration:"
237277
echo "${GIT_INTEGRATION_REGISTER_RESPONSE}"
238278
echo ""
239279
}
@@ -255,6 +295,7 @@ echo " runtime git-token: ****"
255295
echo " runtime cluster: ${CSDP_RUNTIME_CLUSTER}"
256296
echo " runtime name: ${CSDP_RUNTIME_NAME}"
257297
echo " runtime version: ${CSDP_RUNTIME_VERSION}"
298+
echo " managed runtime: ${CSDP_MANAGED_RUNTIME}"
258299
echo " runtime ingress: ${CSDP_RUNTIME_INGRESS_URL}"
259300
echo " ingress class name: ${CSDP_INGRESS_CLASS_NAME}"
260301
echo " ingress controller: ${CSDP_INGRESS_CONTROLLER}"
@@ -280,7 +321,12 @@ if kubectl -n "$NAMESPACE" get secret "$REPO_CREDS_SECRET_NAME"; then
280321
else
281322
echo " --> Secret $REPO_CREDS_SECRET_NAME doesn't exists."
282323
echo ""
283-
create_repo_creds_secret
324+
325+
if [[ "$CSDP_MANAGED_RUNTIME" == "true" ]] ; then
326+
create_managed_repo_creds_secret
327+
else
328+
create_repo_creds_secret
329+
fi
284330
fi
285331
echo ""
286332
echo ""
@@ -310,6 +356,11 @@ if kubectl -n "$NAMESPACE" get secret -l io.codefresh.integration-type=git -l io
310356
else
311357
echo " --> Default git integration exists"
312358
fi
359+
360+
# 6. Register to git integration
361+
if [[ "$CSDP_MANAGED_RUNTIME" == "true" ]] ; then
362+
register_to_git_integration
363+
fi
313364
echo ""
314365

315366
echo "Done!"

installer/kustomize/csdp-installer.job.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ spec:
7575
secretKeyRef:
7676
name: csdp-installer
7777
key: runtime.ingressController
78+
- name: CSDP_MANAGED_RUNTIME
79+
valueFrom:
80+
secretKeyRef:
81+
name: csdp-installer
82+
key: runtime.managed
83+
optional: true
7884
- name: CSDP_GIT_INTEGRATION_PROVIDER
7985
valueFrom:
8086
secretKeyRef:

installer/kustomize/example/kustomization.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ secretGenerator:
1717
- "runtime.repo=<RUNTIME_REPO>"
1818
- "runtime.gitToken=<RUNTIME_GIT_TOKEN>"
1919
- "runtime.cluster=<RUNTIME_CLUSTER>"
20+
- "runtime.managed=<IS_MANAGED>"
2021
- "runtime.ingressURL=<RUNTIME_INGRESS_URL>"
2122
- "runtime.ingressClass=<RUNTIME_INGRESS_CLASS>"
2223
- "runtime.ingressController=<RUNTIME_INGRESS_CONTROLLER>"

installer/kustomize/kustomization.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
apiVersion: kustomize.config.k8s.io/v1beta1
22
kind: Kustomization
3+
namespace: csdp
34
resources:
45
- ../../csdp/components/argo-cd
56
- ./csdp-installer.secret.yaml

runtime.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,6 @@ spec:
1212
type: kustomize
1313
url: github.com/codefresh-io/cli-v2/manifests/argo-events
1414
wait: true
15-
- name: rollouts
16-
type: kustomize
17-
url: github.com/codefresh-io/cli-v2/manifests/argo-rollouts
18-
- name: workflows
19-
type: kustomize
20-
url: github.com/codefresh-io/cli-v2/manifests/argo-workflows
2115
- name: app-proxy
2216
type: kustomize
2317
url: github.com/codefresh-io/cli-v2/manifests/app-proxy

0 commit comments

Comments
 (0)