Skip to content

Commit

Permalink
Merge pull request #132 from eth-cscs/dev
Browse files Browse the repository at this point in the history
Merge to master (version 1.8.2)
  • Loading branch information
aledabin authored Dec 3, 2021
2 parents 558fc8b + 53fc4d1 commit 0a19d75
Show file tree
Hide file tree
Showing 9 changed files with 1,051 additions and 155 deletions.
72 changes: 47 additions & 25 deletions ci/k8s/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ spec:
}
environment {
DEPLOY_NAMESPACE = "firecrest-dev"
TDS_NAMESPACE = "firecrest-tds"
GIT_COMMIT = "${env.GIT_COMMIT}"
GIT_COMMIT_SHORT = "${env.GIT_COMMIT.take(7)}"
}
Expand Down Expand Up @@ -66,20 +67,17 @@ spec:
pwd
ls -la
#/kaniko/executor --context ./ --dockerfile deploy/docker/base/Dockerfile\
# --destination $REPO_PREFIX/f7t-base:$GIT_COMMIT_SHORT --cleanup
# build microservices
for ms in certificator compute reservations status storage tasks utilities; do
/kaniko/executor --build-arg BASE_IMAGE=$REPO_PREFIX/f7t-base:latest --registry-mirror $REGISTRY \
--context ./ --dockerfile deploy/docker/$ms/Dockerfile --destination $REPO_PREFIX/$ms:$GIT_COMMIT_SHORT --cleanup
done
#/kaniko/executor --context deploy/test-build --dockerfile ./cluster/Dockerfile \
#--destination $REPO_PREFIX/cluster:$GIT_COMMIT_SHORT --cleanup
# build web client
/kaniko/executor --context src/tests/template_client --dockerfile ./Dockerfile \
--destination $REPO_PREFIX/client:$GIT_COMMIT_SHORT --cleanup
# build tester
/kaniko/executor --context ./ --dockerfile deploy/docker/tester/Dockerfile \
--destination $REPO_PREFIX/tester:$GIT_COMMIT_SHORT --cleanup
'''
Expand All @@ -98,8 +96,7 @@ spec:
export PATH=$PATH:$(pwd)/linux-amd64
helm list -n "$DEPLOY_NAMESPACE"
#cd ${BUILD_NUMBER}/firecrest
cd deploy/k8s
ls -la
echo "registry: $REPO_PREFIX\ntag: '$GIT_COMMIT_SHORT'\nnamespace: "$DEPLOY_NAMESPACE"\nregistry_secret_creds: registry-credentials\n" > values-dev.yaml
Expand All @@ -125,8 +122,7 @@ spec:
tar -xvf helm-v3.7.1-linux-amd64.tar.gz
export PATH=$PATH:$(pwd)/linux-amd64
helm list -n "$DEPLOY_NAMESPACE"
#cd ${BUILD_NUMBER}/firecrest
cd deploy/k8s
ls -la
Expand Down Expand Up @@ -198,21 +194,47 @@ spec:
}
}
}
stage('Tag for TDS'){
stage('TDS environment deployment'){
when {
branch 'dev-k8s'
branch 'dev'
}
steps {
withVault([vaultSecrets: vault_secrets, configuration: vault_config]) {
sh '''
tag="tds"
for ms in certificator client compute reservations status storage tasks utilities; do
img="https://$REGISTRY/artifactory/api/copy/$REGISTRY_GROUP/$ms/$GIT_COMMIT_SHORT?to=/$REGISTRY_GROUP/$ms/$tag"
echo "URL: $img"
response=$(curl -s -o /dev/null -w "%{http_code}" -u $REGISTRY_USER:$JFROG_API_KEY -X POST $img)
if [ "$response" = "200" ]; then echo "Image $ms/$GIT_COMMIT_SHORT copued successfully to $tag (status_code=$response)"; else echo "Image $ms/$GIT_COMMIT_SHORT couldn't be copied (status_code=$response)"; fi
done
'''
withKubeConfig([credentialsId: 'firecrest-cicd-secret', serverUrl: K8S_CLUSTER_URL]) {
sh '''
# Download jfrog CLI
curl -fL https://getcli.jfrog.io | sh
tag="tds"
for ms in certificator client compute reservations status storage tasks utilities; do
./jfrog rt copy --flat=true --url="https://$REGISTRY/artifactory" --user="$REGISTRY_USER" --password="$JFROG_API_KEY" "$REGISTRY_GROUP/$ms/$GIT_COMMIT_SHORT/" "$REGISTRY_GROUP/$ms/$tag/"
done
'''

sh '''
# Deploy TDS openapi server in firecrest-tds
# Install helm
curl -s -O https://get.helm.sh/helm-v3.7.1-linux-amd64.tar.gz
tar -xvf helm-v3.7.1-linux-amd64.tar.gz
pwd
export PATH=$PATH:$(pwd)/linux-amd64
# removing old openapi (if exists)
helm uninstall "openapi-env-tds" -n "$TDS_NAMESPACE" || true
# create new openapi
cd deploy/k8s
ls -la
echo "registry: $REPO_PREFIX\ntag: tds\nnamespace: "$TDS_NAMESPACE"\nregistry_secret_creds: registry-credentials\n" > values-tds.yaml
helm install --wait --timeout 60s openapi-env-tds openapi -n "$TDS_NAMESPACE" -f values-tds.yaml
'''
}
}

}
Expand Down Expand Up @@ -247,12 +269,12 @@ spec:
helm uninstall "$app-env-dev" -n "$DEPLOY_NAMESPACE" || true
done
# Download jfrog CLI
curl -fL https://getcli.jfrog.io | sh
# remove images
for ms in certificator client compute reservations status storage tasks tester utilities; do
img="https://$REGISTRY/artifactory/$REGISTRY_GROUP/$ms/$GIT_COMMIT_SHORT"
response=$(curl -s -o /dev/null -w "%{http_code}" --connect-timeout 20 -u $REGISTRY_USER:$JFROG_API_KEY -XDELETE $img)
if [ "$response" = "204" ]; then echo "Image $ms/$GIT_COMMIT_SHORT deleted successfully (status_code=$response)"; else echo "Image $ms/$GIT_COMMIT_SHORT couldn't be deleted (status_code=$response)"; fi
sleep 20s
./jfrog rt del --recursive --quiet --url="https://$REGISTRY/artifactory" --user="$REGISTRY_USER" --password="$JFROG_API_KEY" "$REGISTRY_GROUP/$ms/$GIT_COMMIT_SHORT/"
done
'''
}
Expand Down
Loading

0 comments on commit 0a19d75

Please sign in to comment.