Life ConnectLife Connect
Table of contents
Architecture
Services
Swagger Docs
GitHub
Table of contents
Architecture
Services
Swagger Docs
GitHub

Environment How-To

This guide provides quick commands for managing your environment using kind and helm.


Reverse proxy

  • List docker machines
    Use this command to list running docker containers.

    docker ps
    
  • Exec within docker
    Use this command to execute command within containers.

    docker exec -ti <container-id> /bin/sh
    
  • View nginx config
    Use this command to view the nginx config.

    cat /etc/nginx/nginx.conf
    

Kind

  • List Clusters
    Use this command to view all clusters managed by Kind.

    kind get clusters
    
  • Export Kubeconfig
    Export the kubeconfig for a specific Kind cluster.

    kind export kubeconfig --name <cluster-name>
    
  • Delete Cluster
    Delete the cluster by name.

    kind delete cluster --name <cluster-name>
    

Terraform

  • List Terraform state
    List current Terraform state.
    terraform state list
    

Helm

  • Get Values
    Retrieve the configuration values of a Helm release in YAML format.

    helm -n $NAMESPACE get values adb-services -o yaml
    
  • List Releases
    List all Helm releases in a specific namespace.

    helm --namespace $NAMESPACE list
    
  • Rollback a Release
    Roll back a Helm release to the previous version.

    helm --namespace $NAMESPACE rollback adb-services
    
  • Dry Run an Upgrade/Install Simulate an upgrade or installation without actually applying it.

    helm --namespace $NAMESPACE upgrade adb-services -f ../envs/$ENV/values.yaml ../../charts/services/ --dry-run --debug
    
  • Upgrade a Release Upgrade an existing release with a new chart or updated values.

    helm --namespace $NAMESPACE upgrade adb-services -f ../envs/$ENV/values.yaml ../../charts/services/
    
  • Delete a Release Uninstall a release from a namespace.

    helm --namespace $NAMESPACE uninstall adb-services
    
  • Check a Release Status View the status of a specific release.

    helm --namespace $NAMESPACE status adb-services
    
  • Get Manifest Retrieve the Kubernetes manifest generated by Helm for a release.

    helm --namespace $NAMESPACE get manifest adb-services
    
  • Template Rendering templates locally without deploying.

    helm --namespace $NAMESPACE template adb-services adb-accounting
    

kubectl

  • Get Secret Get the secret as json output.

    kubectl --namespace $NAMESPACE get secrets adb-secret -o=json
    
  • Edit Secret Update the secret.

    kubectl --namespace $NAMESPACE edit secrets adb-secret
    
  • Scale Deployment Scale the deployment to specified replicas.

    kubectl --namespace $NAMESPACE scale deployment adb-persons --replicas=1
    
  • Inspect service Inspect the service

    kubectl get svc -n nginx
    
  • Inspect service Inspect the service

    kubectl get svc -n nginx
    
  • Inspect service details To see more details about the ingress controller service

    kubectl describe svc adb-ingress-nginx-controller -n nginx
    
  • Inspect ingress routes To see more details about the ingress routes

    kubectl --namespace $NAMESPACE get ingress
    

aws

  • Configure AWS CLI Check AWS Region Configuration
aws configure list
  • Select AWS CLI profile Select the AWS CLI profile to use.
aws <command> --profile <profile-name>

aws secret manager

  • Create Secret Create a secret

    aws secretsmanager create-secret \
      --name adb/dev \
      --secret-string '{
       "odin": {"username": "dev_user", "password": "dev_password"},
       "achille": {"username": "stage_user", "password": "stage_password"}
      }'
    aws secretsmanager create-secret --name adb/dev --secret-string "$(cat adb-aws-secret.json)"  --profile <profile-name>
    
  • Retrieve a Secret Retrieve a secret

    aws secretsmanager get-secret-value --secret-id adb/dev  --profile <profile-name>
    aws secretsmanager get-secret-value --secret-id adb/dev --query SecretString --output text --profile <profile-name>
    
  • Update a Secret Update a secret

    aws secretsmanager update-secret \
      --secret-id adb/dev \
      --secret-string '{
       "odin": {"username": "dev_user", "password": "dev_password"},
       "achille": {"username": "stage_user", "password": "stage_password"}
      }' \
      --profile <profile-name>
    
    OR from a file
    
    aws secretsmanager update-secret --secret-id adb/dev --secret-string "$(cat adb-aws-secrets.json)" --profile <profile-name>
    
  • List Secrets List the secrets

    aws secretsmanager list-secrets
    
  • Delete a Secret Delete a Secret

    aws secretsmanager delete-secret --secret-id adb/dev --recovery-window-in-days 30
    
    OR
    
    aws secretsmanager delete-secret --secret-id adb/dev --force-delete-without-recovery
    

Atlas CLI

  • init config Initialize the configuration file
    /opt/devops/software/mongodb-atlas-cli_1.34.0_linux_x86_64/bin/atlas config init
    

Mongo

    #!/bin/bash    
    export_uri="<uri_to_export_from>"
    import_uri="<uri_to_import_into>"
    output_dir="/home/marwan_singer/exports"
    
    # List of databases to drop completely
    declare -a databases=(
        "adb-persons"
        "adb-utilities"
        "adb-accounting"
        "adb-contracts"
        "adb-files"
        "adb-parts"
        "adb-tickets"
        "adb-utilities"
        "adb-reports"
        "adb-views"
    )
      
    # Step 1: Drop databases
    for db in "${databases[@]}"; do
        echo "Clearing all collections in database: $db"
        
        clear_command="mongosh $import_uri --quiet --eval '
            const db = db.getSiblingDB(\"$db\");
            db.getCollectionNames().forEach(collection => {
                db.getCollection(collection).deleteMany({});
            });
        '"
        
        eval $clear_command
    done

      
    # Define a tuple-like array of parameters: db, collection, query, fields
    declare -a exports=(
       "adb-persons organization '' ''"
       "adb-persons company_settings '' ''"
       "adb-persons persons '{\"contactCategories\": \"CONTACT_CATEGORY.ORGANIZATION\"}' ''"
       "adb-persons persons '{\"emailAddresses.qualifier\": \"MAIL.AUTHORIZED\"}' ''"
       "adb-utilities catalog '' ''"
       "adb-utilities indexes '' ''"
       "adb-utilities configurations '' ''"
       "adb-utilities dashboard '' ''"
       "adb-accounting ledger_account_definition '' ''"
       "adb-accounting ledger_account '' '_id,accountType,accountCategory,allowedAsParent,writable,qualifier,accountNumber,parentAccountNumber,accountNature,activity,description,target,organisationId,_class'"
       "adb-accounting fiscal_year '' ''"
       "adb-accounting journals '' ''"
       "adb-reports template_meta_data '' ''"
    )
    
  
    # Iterate over the tuple and perform export, delete, and import
    for export in "${exports[@]}"; do
        # Extract fields: db, collection, query, fields
        db=$(echo $export | awk '{print $1}')
        collection=$(echo $export | awk '{print $2}')
        query=$(echo $export | awk '{print $3}')
        fields=$(echo $export | awk '{print $4}')
        output_file="$output_dir/${collection}.json"
    
        # Build the export command
        export_command="mongoexport --uri=\"$export_uri\" --db=$db --collection=$collection --out=$output_file --jsonArray"
        
        # Add query if it exists
        if [ "$query" != "''" ]; then
            export_command="$export_command --query=$query"
        fi
        
        # Add fields if they exist
        if [ "$fields" != "''" ]; then
            export_command="$export_command --fields=$fields"
        fi
    
        # Execute the export command
        echo "Executing export: $export_command"
        eval $export_command
    
        # Build the import command
        import_command="mongoimport --uri=\"$import_uri\" --db=$db --collection=$collection --file=$output_file --jsonArray"
    
        # Execute the import command
        echo "Executing import: $import_command"
        eval $import_command
    done
Edit this page
Last Updated:
Contributors: gregory