Skip to content
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

wip #4

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
206 changes: 206 additions & 0 deletions codefresh-e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
version: "1.0"
mode: parallel
stages:
- "init"
- "deploy"
- "clean"

steps:
prepare_namespaces:
stage: init
image: '${{STEP_IMAGE}}:${{HELM_VERSION}}'
title: Create namespaces
fail_fast: false
working_directory: IMAGE_WORK_DIR
commands:
- |
export HELM_VERSION_STR=$(echo "${{HELM_VERSION}}" | sed "s/\./-/g")
kubectl config use-context ${{KUBE_CONTEXT}}
kubectl get ns | grep "helm-$HELM_VERSION_STR"
NS_EXIST=$(kubectl get ns | grep "helm-$HELM_VERSION_STR")
echo "fuck-$NS_EXIST"
if [ -z "$NS_EXIST" ] || [ "$NS_EXIST" = "null" ]
echo "delete helm..."
kubectl delete ns helm-$HELM_VERSION_STR
echo "deleted helm"
fi
echo "helm-deploy-$HELM_VERSION_STR"
NS_EXIST=$(kubectl get ns helm-deploy-$HELM_VERSION_STR --ignore-not-found | grep helm)
echo "$NS_EXIST"
if [ -z "$NS_EXIST" ] || [ "$NS_EXIST" = "null" ]
echo "delete helm-deploy..."
kubectl delete ns helm-deploy-$HELM_VERSION_STR
echo "deleted helm-deploy"
fi
echo "helm-promo-$HELM_VERSION_STR"
NS_EXIST=$(kubectl get ns helm-promo-$HELM_VERSION_STR --ignore-not-found | grep helm)
echo "$NS_EXIST"
if [ -z "$NS_EXIST" ] || [ "$NS_EXIST" = "null" ]
echo "delete helm-promo..."
kubectl delete ns helm-promo-$HELM_VERSION_STR
echo "deleted helm-promo"
fi
echo "create helm"
kubectl create ns helm-$HELM_VERSION_STR
kubectl create ns helm-deploy-$HELM_VERSION_STR
kubectl create ns helm-promo-$HELM_VERSION_STR
cf_export HELM_VERSION_NORMALIZED=$HELM_VERSION_STR

# auth:
# stage: deploy
# type: helm
# arguments:
# action: auth
# helm_version: ${{HELM_VERSION}}
# kube_context: ${{KUBE_CONTEXT}}
# commands:
# - helm list
# when:
# steps:
# - name: prepare_namespaces
# on:
# - finished

# deploy:
# stage: deploy
# type: helm
# arguments:
# action: install
# chart_name: tomcat
# release_name: tomcat
# helm_version: ${{HELM_VERSION}}
# kube_context: ${{KUBE_CONTEXT}}
# namespace: helm-${{HELM_VERSION_NORMALIZED}}
# skip_cf_stable_helm_repo: true
# credentials_in_arguments: true
# chart_repo_url: 'https://charts.helm.sh/stable'
# custom_values:
# - 'pat.arr="{one,two,three}"'
# - 'STR_WITH_COMAS="one\,two\,three"'
# - test_var=test_key
# when:
# steps:
# - name: prepare_namespaces
# on:
# - finished

installing_chart:
stage: deploy
create_file:
path: /codefresh/volume/cf-generated
name: values.yaml
content: |
test:
helm_test: string
image: '${{STEP_IMAGE}}:${{HELM_VERSION}}'
title: Installing chart
environment:
- CHART_NAME=tomcat
- RELEASE_NAME=tomcat
- KUBE_CONTEXT=${{KUBE_CONTEXT}}
- NAMESPACE=helm-deploy-${{HELM_VERSION_NORMALIZED}}
- CHART_VERSION=0.4.3
- 'CHART_REPO_URL=https://charts.helm.sh/stable'
- VALUE_test_var=test_key
- VALUESFILE_values=/codefresh/volume/cf-generated/values.yaml
name: installing_chart
when:
steps:
- name: prepare_namespaces
on:
- finished

check_installing_helm:
stage: deploy
image: '${{STEP_IMAGE}}:${{HELM_VERSION}}'
commands:
- env | grep HE
- export TOMCAT_INSTALLED=$(kubectl get pods -n helm-deploy-${{HELM_VERSION_NORMALIZED}} --ignore-not-found | grep tomcat)
- if [ -z "$TOMCAT_INSTALLED" ] || [ "$TOMCAT_INSTALLED" = "null" ] ; then return 1; fi
- export TOMCAT_RELEASES=$(kubectl get secret -n helm-deploy-${{HELM_VERSION_NORMALIZED}} --ignore-not-found | grep tomcat)
- if [ -z "$TOMCAT_RELEASES" ] || [ "$TOMCAT_RELEASES" = "null" ] ; then return 1; fi
when:
steps:
- name: installing_chart
on:
- success

promote_chart:
stage: deploy
create_file:
path: /codefresh/volume/cf-generated
name: values.yaml
content: |
test:
helm_test: string
var: test_key_1
image: '${{STEP_IMAGE}}:${{HELM_VERSION}}'
title: Promote chart
environment:
- ACTION=promotion
- RELEASE_NAME=tomcat
- KUBE_CONTEXT=${{KUBE_CONTEXT}}
- NAMESPACE=helm-promo-${{HELM_VERSION_NORMALIZED}}
- CHART_NAME=tomcat
- CHART_VERSION=0.4.3
- >-
CHART_JSON_GZIP=H4sIAAAAAAAAA+Va73LbNhJ/FYySTBLXpOzkrs1pxp3x2W7rXuJobCeZjpmJIBKSWFMAS5CydY6f4b7fp3uMe557gXuF212AJEhRsp10+uXUTiyBix8Wu4v9B17c9CSfi96gdzDjWe4v+TzpbfcinnMYw0cDlqt5yPNAzhT+ejrL81QP+v1pnM+KsR+qeX/JZ3wxfhrIhch0rOSA7fh/8l8GMhI6zOI0p7HvvUAydng0PD062D8/OmQeOxRpopaMszHXcWhXYjxNkxi+wCymRQag7AoWYzqORMgzxjW7EmME41k4ixeChUrmPJYiC2Qc4lrEJTBpEH2e8nAmfJVN+5nQ/XjOp/DHPkzlFFjnafy+5H6xi7/T6vfT7/ydp7ibNAMGchGBULJCBLJ3u10JMBfzNIGHun/y9vzozM+v81qSuz77UeQsn4nG7t6dvmbjJcsKKWM5xccaNzOfcxnpQSBvbjwWT5j/nieF0D7QAPvaF5KPExGx21tDknE5FStUM6VzTTSMoThubhDrcZssT5BIw1MhERKkBt99+AZ/VqhTDooo1zUT7PcEWAd8qwrNgt6JisRQZXnQq3hDdcah8PNlKixr4joFGnby9vDo0/Dt6fne42eXxViEecKmIDLPQ/lqUKBgyNepSATXwj+pRm9vmafYr1pJZG4v6N34OhWhj7D6YuejLy0ft8CIZUAjVqkxYNWawqRIElwOOQbc523+joct7hBafxmPMSxP7Omc54X2eRShhAWN2R/AseEhnClmTfqx5WTwuBL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bDLIG7XoGLd13LpN10bACeEzcIQFLTaex22xGbrHRRLYlx2g9srZlaDfyxUfEa7cGVzj9UKnH8RR1aVbjrS3RcBko0kYrTLjLHMlFnClJ4AuexXh0Vzmv2HZrtw5gwEOC8u5jw7qreKZEbIvVxTNd1i7UJl6zFh114GEh4nTI1+OVlekaIX6uOptrt1riYWWLiO5FZ6cETYpbvqNXnpsOREyEXES3umkcdScolKjpKsvEo4vnVkYNPMvhBOwm70Jy8JqImN917rmDQ8oFVxDdGgyROzqCTX3/dH4+pOISUy1IeMNLSk6reRWyLT0RdLVjPGJfDVqVpd2m9JkdDN/130A4h7Nd0lIiKSC69un9IG1Ab24Rz63DO2WKL56yssfTuSZz8Zx6totDi+e2njbiBfJUQGmAArqwgR2v1j8+c348ryoLejUJMlovUldQSsg6O8OcHvw+viPF2Ty+zouMUnTHYiiTIJPEVImyHOMm4wVlNRxf5kyRE9Hl7EzOfEap75IJqIrq1MXmfpS7eR6+3XYplnu0hYvt6uvHEfA3LQgWVhm5iezIZ1iV277O9sNS3iDA7oNZuOxlq7mARffeLJkpVrcp8Jzz6R4EajuDrU2WQYpjtRArGfN5O1+mPJGXaXP5pt6oWnZkUkcsfqFuM7NN6C/fQqLEgbK5/YQcCeojWUIhxn7Zf/Oa3hM02rFlh01BjYFUpuGkkfgKLVRLqSlXgMcZQrSScPMi4VcI3Zswx0ZLSZo/lSSdgqF8uRdf80MGynR2vdmXZRcKCnI3aRpAABn09mX1HkAZ9KC+mcSZLqt83LbA8nmoIup0aB1PpXl1kNMhNaWuuKa0HOpGbCjgX5K1nVUW4kqaYfQmPvvQQDa1RYR+fg6jSGIKe4keimvsLdGGec5Nj0rUzFNrA+uKCOcI6hv0tsqyIgM7y6mwvCj7KGzfqaTJ+s7r2r9Miquo3tmguqx8Qt+qXvfzTIj+nONLwqhDqKWn/V9hSciRrNl6tkB/ji28j/8DeGFAdAwyAAA=
- VALUESFILE_values=/codefresh/volume/cf-generated/values.yaml
name: promote_chart
when:
steps:
- name: check_installing_helm
on:
- success

check_promote_helm:
stage: deploy
image: '${{STEP_IMAGE}}:${{HELM_VERSION}}'
commands:
- export TOMCAT_INSTALLED=$(kubectl get pods -n helm-promo-${{HELM_VERSION_NORMALIZED}} --ignore-not-found | grep tomcat)
- if [ -z "$TOMCAT_INSTALLED" ] || [ "$TOMCAT_INSTALLED" = "null" ] ; then return 1; fi
- export TOMCAT_RELEASES=$(kubectl get secret -n helm-promo-${{HELM_VERSION_NORMALIZED}} --ignore-not-found | grep tomcat)
- if [ -z "$TOMCAT_RELEASES" ] || [ "$TOMCAT_RELEASES" = "null" ] ; then return 1; fi
when:
steps:
- name: promote_chart
on:
- success

deleting_release_tomcat:
stage: clean
image: '${{STEP_IMAGE}}:${{HELM_VERSION}}'
title: Deleting release tomcat
fail_fast: false
working_directory: IMAGE_WORK_DIR
commands:
- |
kubectl config use-context ${{KUBE_CONTEXT}}
echo 'Running: helm delete tomcat'
TOMCAT_INSTALLED=$(kubectl get pods -n helm-${{HELM_VERSION_NORMALIZED}} --ignore-not-found | grep tomcat)
if [ -z "$TOMCAT_INSTALLED" ] || [ "$TOMCAT_INSTALLED" = "null" ]
helm delete tomcat --timeout 300s --namespace helm-${{HELM_VERSION_NORMALIZED}}
kubectl delete ns helm-${{HELM_VERSION_NORMALIZED}}
fi
TOMCAT_INSTALLED=$(kubectl get pods -n helm-deploy-${{HELM_VERSION_NORMALIZED}} --ignore-not-found | grep tomcat)
if [ -z "$TOMCAT_INSTALLED" ] || [ "$TOMCAT_INSTALLED" = "null" ]
helm delete tomcat --timeout 300s --namespace helm-deploy-${{HELM_VERSION_NORMALIZED}}
kubectl delete ns helm-deploy-${{HELM_VERSION_NORMALIZED}}
fi
TOMCAT_INSTALLED=$(kubectl get pods -n helm-promo-${{HELM_VERSION_NORMALIZED}} --ignore-not-found | grep tomcat)
if [ -z "$TOMCAT_INSTALLED" ] || [ "$TOMCAT_INSTALLED" = "null" ]
helm delete tomcat --timeout 300s --namespace helm-promo-${{HELM_VERSION_NORMALIZED}}
kubectl delete ns helm-promo-${{HELM_VERSION_NORMALIZED}}
fi
when:
steps:
- name: check_promote_helm
on:
- finished
# - name: auth
# on:
# - finished
# - name: deploy
# on:
# - finished

29 changes: 29 additions & 0 deletions codefresh-helm3.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
version: '1.0'
stages:
- "init"
- "build"
- "push"

steps:
define_the_versions_list:
stage: 'init'
image: alpine
commands:
- |-
Expand All @@ -14,6 +19,7 @@ steps:
notRecursivelyInvoked: 'includes("${{HELM_VERSION}}", "${{") == true'

run-cli-loop:
stage: 'init'
image: codefresh/cli
commands:
- for VAR in $(cat helmVersionsList); do codefresh wait $(codefresh run ${{CF_PIPELINE_NAME}} -d --branch ${{CF_BRANCH}} --variable HELM_VERSION=${VAR} --trigger ${{CF_PIPELINE_TRIGGER_ID}} --context github && sleep 10) & done
Expand All @@ -24,6 +30,7 @@ steps:
notRecursivelyInvoked: 'includes("${{HELM_VERSION}}", "${{") == true'

debug:
stage: 'build'
type: freestyle
image: alpine
commands:
Expand All @@ -35,6 +42,7 @@ steps:
recursivelyInvoked: 'includes("${{HELM_VERSION}}", "${{") == false'

clone:
stage: 'build'
type: git-clone
arguments:
repo: '${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}'
Expand All @@ -46,6 +54,7 @@ steps:
recursivelyInvoked: 'includes("${{HELM_VERSION}}", "${{") == false'

build_image:
stage: 'build'
type: build
registry: pysarenko
working_directory: '${{clone}}'
Expand All @@ -61,7 +70,27 @@ steps:
all:
recursivelyInvoked: 'includes("${{HELM_VERSION}}", "${{") == false'

run_e2e:
stage: 'build'
type: codefresh-run
arguments:
FOLLOW_LOGS: false
PIPELINE_ID: Helm/e2e
DETACH: false
# TRIGGER_ID: trigger
# BRANCH: ${{CF_BRANCH}}
RESET_VOLUME: true
# VARIABLE_FILE: ${{CF_VOLUME_PATH}}/env_vars_to_run_pipe.yml
VARIABLE:
- HELM_VERSION=${{HELM_VERSION}}-${{CF_SHORT_REVISION}}
- CF_BRANCH=${{CF_BRANCH}}
when:
condition:
all:
recursivelyInvoked: 'includes("${{HELM_VERSION}}", "${{") == false'

push:
stage: 'push'
type: push
tag: ${{HELM_VERSION}}
candidate: ${{build_image}}
Expand Down