Commit 93ee50ee authored by Jorge Moratinos's avatar Jorge Moratinos
Browse files

Upgraded all deployments in order to use deployment scripts.

parent 6a36840b
Loading
Loading
Loading
Loading
+246 −162
Original line number Diff line number Diff line
@@ -600,6 +600,8 @@ deploy_ocf_main:
      whoami
      kubectl cluster-info
      yq --version
      if [[ -d helm/capif ]]; then
        echo "### helm capif directory exists ###"
        ls -rtt helm/capif
        cat helm/capif/Chart.yaml
        yq e -i ".appVersion = \"main\"" helm/capif/Chart.yaml
@@ -762,6 +764,88 @@ deploy_ocf_main:
        --set celery-worker.env.redisPort=6379 \
        --set celery-worker.env.logLevel="DEBUG" \
        --wait --timeout=10m --create-namespace --atomic
      else
        echo "### helm capif directory does not exist ###"
        echo "New deployment behaviour, creating env file and installing helm chart with it"

        echo "Generate env file for helm scripts"

        cat <<EOF > helm/scripts/envs/$NAMESPACE_PRE_PROD.template
      # --------------------------------------------------------------------------------------------------------------
      # This file is generated by the GitLab CI pipeline for deploying CAPIF to the staging environment. 
      # It contains environment variables that are used in the deployment process. 
      # The values of these variables are set based on the current GitLab CI environment and the configuration 
      # of the CAPIF deployment.

      # Common variables
      ## Non Default values on next variables
      export CAPIF_NAMESPACE=$NAMESPACE_PRE_PROD
      export CAPIF_CI_ENV_ENDPOINT=main
      export CAPIF_NAME_VERSION_CHART=ocf-main
      export CAPIF_DOMAIN=$DOMAIN_PRE_PROD
      export BASE_DOCKER_REGISTRY=labs.etsi.org:5050/ocf/capif
      export CAPIF_DOCKER_REGISTRY=$CI_REGISTRY/ocf/capif/$CI_COMMIT_REF_SLUG
      export CAPIF_IMAGE_TAG=$CI_COMMIT_REF_SLUG
      export VAULT_INTERNAL_HOSTNAME=$VAULT_HOSTNAME
      export VAULT_PORT=$VAULT_PORT
      export VAULT_ACCESS_TOKEN=<REDACTED>

      export CAPIF_HOSTNAME=capif-$CI_ENV_ENDPOINT-mr.$DOMAIN_PRE_PROD
      export REGISTER_HOSTNAME=register-$CI_ENV_ENDPOINT-mr.$DOMAIN_PRE_PROD

      ## Default values on next variables
      export LOG_LEVEL=DEBUG

      # Step 0 CAPIF Monitoring configuration
      ## Configuration of the monitoring components of CAPIF, such as Grafana, Loki, Fluentbit, Tempo and Otelcollector.
      export PROMETHEUS_URL=http://prometheus.ocf.pre-production

      ## Default values on next variables
      ### Storage configuration
      # export CAPIF_STORAGE_CLASS=nfs-01
      # export CAPIF_GRAFANA_STORAGE_SIZE=10Gi
      # export CAPIF_LOKI_STORAGE_SIZE=100Mi
      # export CAPIF_TEMPO_STORAGE_SIZE=100Mi
      # export CAPIF_TEMPO_STORAGE_SIZE=3Gi
      ### OpenCAPIF Monitoring configuration
      # export CAPIF_GRAFANA_ENABLED=true
      # export CAPIF_LOKI_ENABLED=true
      # export CAPIF_FLUENTBIT_ENABLED=true
      # export CAPIF_TEMPO_ENABLED=true
      # export CAPIF_OTELCOLLECTOR_ENABLED=true

      # Step 1: OpenCAPIF Mongo configuration
      ## Default values on next variables
      # export CAPIF_MONGO_REGISTER_STORAGE_SIZE=8Gi
      # export CAPIF_MONGO_STORAGE_SIZE=8Gi

      # Step 2: OpenCAPIF Mongo Express configuration
      # Only Common configuration of env apply to both mongo express components.

      # Step 3: OpenCAPIF Common Core Components configuration
      # Only Common configuration of env apply to both mongo express components.

      # Step 4: OpenCAPIF Core Components configuration
      # Only Common configuration of env apply to both mongo express components. CAPIF_HOSTNAME

      # Step 5: OpenCAPIF Register configuration
      # Only Common configuration of env apply to both mongo express components. REGISTER_HOSTNAME
      # --------------------------------------------------------------------------------------------------------------
      EOF
        sed -e "s/^[ ]*export VAULT_ACCESS_TOKEN=.*/export VAULT_ACCESS_TOKEN=$VAULT_ACCESS_TOKEN_PROD/" \
        helm/scripts/envs/$NAMESPACE_PRE_PROD.template > helm/scripts/envs/$NAMESPACE_PRE_PROD.env
        ./helm/scripts/install_capif.sh $NAMESPACE_PRE_PROD
        kubectl delete pod --field-selector=status.phase=Failed -n $NAMESPACE_PRE_PROD
        kubectl delete pod --field-selector=status.phase=Succeeded -n $NAMESPACE_PRE_PROD

      fi
  
  artifacts:
    name: "$NAMESPACE_PRE_PROD.template"
    paths:
      - helm/scripts/envs/$NAMESPACE_PRE_PROD.template
    expire_in: 1 day
    when: always

main_rf_testing:
  needs: ["deploy_ocf_main"]
+3 −3
Original line number Diff line number Diff line
@@ -756,10 +756,10 @@ deploy_ocf_dev:
    - prep_ocf_cd_dev
  <<: *dev_common
  environment:
    name: review/$CI_COMMIT_REF_SLUG
    name: review/dev/$CI_COMMIT_REF_SLUG
    url: https://capif-$CI_ENV_ENDPOINT-dev.$DOMAIN_DEV
    on_stop: delete_ocf_dev
    auto_stop_in: 3 day
    auto_stop_in: 30 minutes
#  rules:
#    - if: $CI_COMMIT_BRANCH == "main"
#      when: never
@@ -1110,5 +1110,5 @@ delete_ocf_dev:

  when: manual
  environment:
    name: review/$CI_COMMIT_REF_SLUG
    name: review/dev/$CI_COMMIT_REF_SLUG
    action: stop
+234 −150
Original line number Diff line number Diff line
@@ -139,6 +139,8 @@ deploy_ocf_prod:
      whoami
      kubectl cluster-info
      yq --version
      if [[ -d helm/capif ]]; then
        echo "### helm capif directory exists ###"
        ls -rtt helm/capif
        cat helm/capif/Chart.yaml
        yq e -i ".appVersion = \"prod\"" helm/capif/Chart.yaml
@@ -292,3 +294,85 @@ deploy_ocf_prod:
        --set celery-worker.env.redisPort=6379 \
        --set celery-worker.env.logLevel="DEBUG" \
        --wait --timeout=10m --create-namespace --atomic
      else
        echo "### helm capif directory does not exist ###"
        echo "New deployment behaviour, creating env file and installing helm chart with it"

        echo "Generate env file for helm scripts"

        cat <<EOF > helm/scripts/envs/$NAMESPACE_PROD.template
      # --------------------------------------------------------------------------------------------------------------
      # This file is generated by the GitLab CI pipeline for deploying CAPIF to the staging environment. 
      # It contains environment variables that are used in the deployment process. 
      # The values of these variables are set based on the current GitLab CI environment and the configuration 
      # of the CAPIF deployment.

      # Common variables
      ## Non Default values on next variables
      export CAPIF_NAMESPACE=$NAMESPACE_PROD
      export CAPIF_CI_ENV_ENDPOINT=prod
      export CAPIF_NAME_VERSION_CHART=ocf-prod
      export CAPIF_DOMAIN=$DOMAIN_PROD
      export BASE_DOCKER_REGISTRY=labs.etsi.org:5050/ocf/capif
      export CAPIF_DOCKER_REGISTRY=$CI_REGISTRY/ocf/capif/$PATH_PROD
      export CAPIF_IMAGE_TAG=$CI_COMMIT_TAG
      export VAULT_INTERNAL_HOSTNAME=$VAULT_HOSTNAME
      export VAULT_PORT=$VAULT_PORT
      export VAULT_ACCESS_TOKEN=<REDACTED>

      export CAPIF_HOSTNAME=capif-prod.$DOMAIN_PROD
      export REGISTER_HOSTNAME=register-prod.$DOMAIN_PROD

      ## Default values on next variables
      export LOG_LEVEL=DEBUG

      # Step 0 CAPIF Monitoring configuration
      ## Configuration of the monitoring components of CAPIF, such as Grafana, Loki, Fluentbit, Tempo and Otelcollector.
      export PROMETHEUS_URL=http://prometheus.$DOMAIN_PROD

      ## Default values on next variables
      ### Storage configuration
      # export CAPIF_STORAGE_CLASS=nfs-01
      # export CAPIF_GRAFANA_STORAGE_SIZE=10Gi
      # export CAPIF_LOKI_STORAGE_SIZE=100Mi
      # export CAPIF_TEMPO_STORAGE_SIZE=100Mi
      # export CAPIF_TEMPO_STORAGE_SIZE=3Gi
      ### OpenCAPIF Monitoring configuration
      # export CAPIF_GRAFANA_ENABLED=true
      # export CAPIF_LOKI_ENABLED=true
      # export CAPIF_FLUENTBIT_ENABLED=true
      # export CAPIF_TEMPO_ENABLED=true
      # export CAPIF_OTELCOLLECTOR_ENABLED=true

      # Step 1: OpenCAPIF Mongo configuration
      ## Default values on next variables
      # export CAPIF_MONGO_REGISTER_STORAGE_SIZE=8Gi
      # export CAPIF_MONGO_STORAGE_SIZE=8Gi

      # Step 2: OpenCAPIF Mongo Express configuration
      # Only Common configuration of env apply to both mongo express components.

      # Step 3: OpenCAPIF Common Core Components configuration
      # Only Common configuration of env apply to both mongo express components.

      # Step 4: OpenCAPIF Core Components configuration
      # Only Common configuration of env apply to both mongo express components. CAPIF_HOSTNAME

      # Step 5: OpenCAPIF Register configuration
      # Only Common configuration of env apply to both mongo express components. REGISTER_HOSTNAME
      # --------------------------------------------------------------------------------------------------------------
      EOF
        sed -e "s/^[ ]*export VAULT_ACCESS_TOKEN=.*/export VAULT_ACCESS_TOKEN=$VAULT_ACCESS_TOKEN_PROD/" \
        helm/scripts/envs/$NAMESPACE_PROD.template > helm/scripts/envs/$NAMESPACE_PROD.env
        ./helm/scripts/install_capif.sh $NAMESPACE_PROD
        kubectl delete pod --field-selector=status.phase=Failed -n $NAMESPACE_PROD
        kubectl delete pod --field-selector=status.phase=Succeeded -n $NAMESPACE_PROD

      fi

  artifacts:
    name: "$NAMESPACE_PROD.template"
    paths:
      - helm/scripts/envs/$NAMESPACE_PROD.template
    expire_in: 1 day
    when: always