Commit c35820fe authored by Daniel Scholl's avatar Daniel Scholl
Browse files

Azure AKS Support

parent 59fac9f4
......@@ -102,6 +102,7 @@ azure_debug:
echo "export AZURE_BUILD_SUBDIR=\"$AZURE_BUILD_SUBDIR\""
echo "export AZURE_TEST_SUBDIR=\"$AZURE_TEST_SUBDIR\""
echo "# Group Level Variables"
echo "export AZURE_UNIQUE=\"$AZURE_UNIQUE\""
echo "export AZURE_APP_ID=\"$AZURE_APP_ID\""
echo "export AZURE_APP_ID_OTHER=\"$AZURE_APP_ID_OTHER\""
echo "export AZURE_BASE=\"$AZURE_BASE\""
......@@ -236,6 +237,53 @@ azure_containerize:
variables:
- $AZURE_DEBUG == 'true'
azure_containerize_aks:
tags: ["osdu-medium"]
image: danielscholl/azure-build-image
stage: containerize
needs: ["compile-and-unit-test"]
variables:
SHA_IMAGE: ${CI_PROJECT_NAME}-${CI_COMMIT_REF_SLUG}:${CI_COMMIT_SHA}
LATEST_IMAGE: ${CI_PROJECT_NAME}-${CI_COMMIT_REF_SLUG}:latest
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- az --version
- az login --service-principal -u $AZURE_AKS_PRINCIPAL_ID -p $AZURE_AKS_PRINCIPAL_SECRET --tenant $AZURE_TENANT_ID
script:
# Dockerfile
- |
echo 'FROM openjdk:8-jdk-alpine
VOLUME /tmp
ARG JAR_FILE
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-jar","/app.jar"]' > Dockerfile
- |
if [ "$AZURE_SERVICE" == "entitlements" ]; then
TARGET=$(find ./$AZURE_BUILD_SUBDIR/target -name '*.jar' |head -n 1)
else
TARGET=$(find ./$AZURE_BUILD_SUBDIR/target -name '*-spring-boot.jar' |head -n 1)
fi
# Gitlab Container Registry
- echo "Startup Jar is $TARGET"
- docker build --build-arg JAR_FILE=$TARGET -t $CI_REGISTRY_IMAGE/$SHA_IMAGE .
- docker push ${CI_REGISTRY_IMAGE}/$SHA_IMAGE
# Azure Container Registry
- az acr login -n $AZURE_AKS_REGISTRY
- docker tag $CI_REGISTRY_IMAGE/$SHA_IMAGE ${AZURE_AKS_REGISTRY}.azurecr.io/$SHA_IMAGE
- docker push ${AZURE_AKS_REGISTRY}.azurecr.io/$SHA_IMAGE
- docker tag $CI_REGISTRY_IMAGE/$SHA_IMAGE ${AZURE_AKS_REGISTRY}.azurecr.io/$LATEST_IMAGE
- docker push ${AZURE_AKS_REGISTRY}.azurecr.io/$LATEST_IMAGE
only:
variables:
- $AZURE == 'true' && $AZURE_AKS == 'true'
except:
variables:
- $AZURE_DEBUG == 'true'
azure_deploy:
extends:
- .maven
......@@ -260,6 +308,40 @@ azure_deploy:
variables:
- $AZURE_DEBUG == 'true'
azure_deploy_aks:
image: danielscholl/azure-build-image
tags: ["osdu-medium"]
stage: deploy
needs: ["azure_containerize_aks"]
variables:
BRANCH: ${CI_COMMIT_REF_SLUG}
TAG: $CI_COMMIT_SHA
extends:
- .azure_variables
before_script:
- az login --service-principal -u $AZURE_AKS_PRINCIPAL_ID -p $AZURE_AKS_PRINCIPAL_SECRET --tenant $AZURE_TENANT_ID
- az aks get-credentials -g $AZURE_UNIQUE-rg -n $AZURE_UNIQUE-aks
- echo "--set image.branch=$BRANCH --set image.tag=$TAG"
script:
- az aks get-credentials -g $AZURE_UNIQUE-rg -n $AZURE_UNIQUE-aks
- cd devops/azure
# Delete Service
- kubectl delete deployment -n osdu osdu-gitlab-$CI_PROJECT_NAME
- kubectl delete service -n osdu osdu-gitlab-$CI_PROJECT_NAME
# Install Service
- helm upgrade -i osdu-gitlab chart --set image.repository=${AZURE_AKS_REGISTRY}.azurecr.io --set image.branch=$BRANCH --set image.tag=$TAG
- pod=$(kubectl get pod -n osdu|grep $CI_PROJECT_NAME |tail -1 |awk '{print $1}')
- status=$(kubectl wait -n osdu --for=condition=Ready pod/$pod --timeout=60s)
- if [[ "$status" != *"met"* ]]; then echo "POD didn't start correctly" ; exit 1 ; fi
only:
variables:
- $AZURE == 'true' && $AZURE_AKS == 'true'
except:
variables:
- $AZURE_DEBUG == 'true'
azure_config:
image: mcr.microsoft.com/azure-cli
tags: ["osdu-medium"]
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment