Aller au contenu

Service zones#

Prerequisites#

Inputs#

export GIT_PATH="${HOME}/git/"
export ZONE_NAME="kub-..."
export ENVS_NG="${GIT_PATH}/caascad/terraform/envs-ng"

1 - Requirements#

Contract zone#

A service belongs to a contract. The contract zone must be fully deployed.

Cluster zone#

A service is deployed on a cluster. The cluster zone must be fully deployed. The cluster is also responsible of the ingress stack management. This is needed because several service zones may use the same loadbalancer.

2 - Declare zone in zones module (envs-ng)#

Clone envs-ng:

Repository: caascad/terraform/envs-ng

# git clone git@git.corp.caascad.com:caascad/terraform/envs-ng.git "${ENVS_NG}"
cd "${ENVS_NG}"
git pull
git switch -c "${ZONE_NAME}"
nix-shell

Example declaration in values.yaml:

// central signon service on staging
"svc-signon-stg": {
  type:               "service"
  subtype:            "signon"
  parent_zone_name:   "kub-10000"
  contract_zone_name: "obs-signon-stg"
}

Several loadbalancers can be added through the service zone:

"svc-signon-stg": {
  parameters: loadbalancers: lb1: _ // will provider loadbalancer, ingress controller and whitelist
  parameters: loadbalancers: lb2: ingress_controller: false // will deploy only loadbalancer and whitelist
  }

Those parameters will populate the cluster zone run list (not the service zone itself) with loadbalancers, ingress controllers and whitelist.

Generate static files and commit your changes

# Run script to generate static files from zones
generate-static-zones-files
# Add all modifications to the commit
git add zones/
git add gen/
git commit -m "Add ${ZONE_NAME} zone"
# Create target branch
git push -u origin "${ZONE_NAME}"

Create and submit your MR

- Comment your MR with message : `check zones` to trigger `check-zones` pipeline and validate the impacts of your changes on environments.

!!! info
    Please wait for the CI job completion before asking a validation.

3 - Deploy optional ingress stack#

If a loadbalancer parameter has been added, you must first deploy those objects on the cluster zone carrying the service zone.

ZONE_NAME="<your zone name>" # example ZONE_NAME="svc-signon-stg"
cd ${ENVS_NG}/zones/ngot_zones
INGRESSES=($(cue export | jq --arg ZONE_NAME ${ZONE_NAME} -r '.zones[$ZONE_NAME].parameters.loadbalancers|to_entries[]|" -c ingress_controller_v2_\(.key)"'))
CLUSTER_ZONE="$(cue export | jq --arg ZONE_NAME ${ZONE_NAME} -r '.zones[$ZONE_NAME].cluster_zone_name')"

echo "INGRESSES=${INGRESSES[@]}"
echo "CLUSTER_ZONE=${CLUSTER_ZONE}"
cd ${ENVS_NG}/context/ngot
# Verify the command to execute:
cat <<EOC
trackbone apply -z "${CLUSTER_ZONE}" \
    -c fe_loadbalancer_v3 \
    -c fe_whitelist \
    ${INGRESSES[@]}
EOC

Run the command printed above or copy/paste it to a CAASCHR.

4 - Update External DNS on the cluster zone#

The external DNS configuration of the cluster zone needs to be updated in order to take into account the new domain name of the service zone. Example:

trackbone apply -z kub-10000 -c external_dns

5 - Build the service zone#

Start trackbone:

cd ${ENVS_NG}/contexts/ngot
trackbone apply -z ${ZONE_NAME} --add-services -t bootstrap=true --non-interactive --detailed-exitcode -n 8

The deployment should run smoothly. If it fails on a step, you can restart the deployment from it:

trackbone apply -c <failed_conf> -z ${ZONE_NAME} --add-services -t bootstrap=true --cascade --non-interactive --detailed-exitcode -n 8

6 - Refresh CoreDNS addon (rewrite rules)#

Run the cce configuration to patch the rules.
The configuration will automatically:

  • use envs-ng configurations tree to find all ingress_controller_v2_xxxx configurations from loadbalancers attached to the CLUSTER_ZONE.
  • request the cluster to find all ingresses object using one of the ingress class
  • use host attribute of each ingress object to create a rewrite rule
trackbone apply -c cce -z ${CLUSTER_ZONE}

7 - Update drifts pipeline#

Follow this page to update the list of configuration's zones and update concourse pipelines