Skip to content

Commit

Permalink
Add rollout namespaces (#18)
Browse files Browse the repository at this point in the history
Signed-off-by: Rizwana777 <[email protected]>
  • Loading branch information
Rizwana777 authored Mar 11, 2024
1 parent 0aa9570 commit bf6d388
Showing 1 changed file with 34 additions and 30 deletions.
64 changes: 34 additions & 30 deletions gather_gitops.sh
Original file line number Diff line number Diff line change
Expand Up @@ -379,31 +379,6 @@ function main() {
create_directory "${APPLICATION_DIR}"
get_applications "${namespace}" "${APPLICATION_DIR}"

# rollouts
echo "Creating directory for rollouts"
ROLLOUTS_DIR="${RESOURCES_DIR}/rollouts"
create_directory "${ROLLOUTS_DIR}"

ROLLOUTS_MANAGER_CR_DIR="${ROLLOUTS_DIR}/manager_cr"
create_directory "${ROLLOUTS_MANAGER_CR_DIR}"
get_rollouts_manager_cr "${namespace}" "${ROLLOUTS_MANAGER_CR_DIR}"

ROLLOUTS_CR_DIR="${ROLLOUTS_DIR}/cr"
create_directory "${ROLLOUTS_CR_DIR}"
get_rollouts_cr "${namespace}" "${ROLLOUTS_CR_DIR}"

ROLLOUTS_DEPLOYMENT_DIR="${ROLLOUTS_DIR}/rollout_deployment"
create_directory "${ROLLOUTS_DEPLOYMENT_DIR}"
get_rollout_deployments "${namespace}" "${ROLLOUTS_DEPLOYMENT_DIR}"

ROLLOUTS_REPLICASET_DIR="${ROLLOUTS_DIR}/rollout_replicaSet"
create_directory "${ROLLOUTS_REPLICASET_DIR}"
get_rollout_replicaSet "${namespace}" "${ROLLOUTS_REPLICASET_DIR}"

ROLLOUTS_SERVICES_DIR="${ROLLOUTS_DIR}/rollout_services"
create_directory "${ROLLOUTS_SERVICES_DIR}"
get_rollout_services "${namespace}" "${ROLLOUTS_SERVICES_DIR}"

echo " * Getting ArgoCD Source Namespaces in ${namespace}..."
local sourceNamespaces
run_and_log "oc get argocd -n ${namespace} -o jsonpath='{.items[*].spec.sourceNamespaces[*]}'" "${ARGOCD_DIR}/sourceNamespaces.txt"
Expand Down Expand Up @@ -433,11 +408,6 @@ function main() {
run_and_log "oc logs deployment/${argoCDName}-repo-server -n ${namespace}" "${ARGOCD_LOG_DIR}/repo-server-logs.txt"
run_and_log "oc logs deployment/${argoCDName}-redis -n ${namespace}" "${ARGOCD_LOG_DIR}/redis-logs.txt"
run_and_log "oc logs deployment/${argoCDName}-dex-server -n ${namespace}" "${ARGOCD_LOG_DIR}/dex-server-logs.txt"

echo " * Getting Rollout logs in ${namespace}..."
ROLLOUTS_LOG_DIR="${ROLLOUTS_DIR}/logs"
create_directory "${ROLLOUTS_LOG_DIR}"
run_and_log "oc logs deployment/argo-rollouts -n ${namespace}" "${ROLLOUTS_LOG_DIR}/rollout-logs.txt"

echo " * Getting ArgoCD Managed namespaces in ${namespace}..."
run_and_log "oc get namespaces --selector=argocd.argoproj.io/managed-by=${namespace}" "${ARGOCD_DIR}/managed-namespaces.txt"
Expand Down Expand Up @@ -474,6 +444,40 @@ function main() {
done
done

local rolloutNamespaces
rolloutNamespaces=$(oc get RolloutManager --all-namespaces -o jsonpath='{.items[*].metadata.namespace}')

for rolloutNamespace in ${rolloutNamespaces}; do
echo "Creating directory for rollouts"
ROLLOUTS_RESOURCES_DIR="${GITOPS_DIR}/rolloutsNamespace_${rolloutNamespace}_resources"
create_directory "${ROLLOUTS_RESOURCES_DIR}"

ROLLOUTS_MANAGER_CR_DIR="${ROLLOUTS_RESOURCES_DIR}/manager_cr"
create_directory "${ROLLOUTS_MANAGER_CR_DIR}"
get_rollouts_manager_cr "${rolloutNamespace}" "${ROLLOUTS_MANAGER_CR_DIR}"

ROLLOUTS_CR_DIR="${ROLLOUTS_RESOURCES_DIR}/cr"
create_directory "${ROLLOUTS_CR_DIR}"
get_rollouts_cr "${rolloutNamespace}" "${ROLLOUTS_CR_DIR}"

ROLLOUTS_DEPLOYMENT_DIR="${ROLLOUTS_RESOURCES_DIR}/rollout_deployment"
create_directory "${ROLLOUTS_DEPLOYMENT_DIR}"
get_rollout_deployments "${rolloutNamespace}" "${ROLLOUTS_DEPLOYMENT_DIR}"

ROLLOUTS_REPLICASET_DIR="${ROLLOUTS_RESOURCES_DIR}/rollout_replicaSet"
create_directory "${ROLLOUTS_REPLICASET_DIR}"
get_rollout_replicaSet "${rolloutNamespace}" "${ROLLOUTS_REPLICASET_DIR}"

ROLLOUTS_SERVICES_DIR="${ROLLOUTS_RESOURCES_DIR}/rollout_services"
create_directory "${ROLLOUTS_SERVICES_DIR}"
get_rollout_services "${rolloutNamespace}" "${ROLLOUTS_SERVICES_DIR}"

echo " * Getting Rollout logs in ${rolloutNamespace}..."
ROLLOUTS_LOG_DIR="${ROLLOUTS_RESOURCES_DIR}/logs"
create_directory "${ROLLOUTS_LOG_DIR}"
run_and_log "oc logs deployment/argo-rollouts -n ${rolloutNamespace}" "${ROLLOUTS_LOG_DIR}/rollout-logs.txt"
done

echo " * Getting ArgoCD AppProjects from all Namespaces..."
APPPROJECT_DIR="${ARGOCD_DIR}/appprojects"
create_directory "${APPPROJECT_DIR}"
Expand Down

0 comments on commit bf6d388

Please sign in to comment.