github.com/freiheit-com/kuberpult@v1.24.2-0.20240328135542-315d5630abe6/deploy.sh (about)

     1  #!/bin/bash
     2  
     3  # Runs through all manifests and applies them in kubernetes
     4  # Expects a directory structure of "environment/$environment/applications/$appname/...
     5  # Run with "environment" directory as first parameter and "namespace" as second parameter and server url as third.
     6  # The output is intended to be piped into kubectl, e.g.
     7  # ./deploy.sh my-dir development "https://8.8.8.8" | kubectl apply -f -
     8  
     9  set -eup
    10  
    11  ROOT="$1"
    12  NAMESPACE="$2"
    13  URL="$3"
    14  
    15  cd "$ROOT"
    16  for env in $(ls); do
    17    if $(test -d "$env"/applications); then
    18      cd "$env"/applications
    19      for appname in $(ls); do
    20        if $(test -d $appname); then
    21          echo "Applying manifest for $appname ..." > /dev/stderr
    22          manifestsDir="environments/$env/applications/$appname/manifests"
    23          cat << EOF
    24  apiVersion: argoproj.io/v1alpha1
    25  kind: Application
    26  metadata:
    27    name: "$NAMESPACE-$appname"
    28    namespace: tools
    29  spec:
    30    destination:
    31      name: ""
    32      namespace: $NAMESPACE
    33      server: "$URL"
    34    source:
    35      path: $manifestsDir
    36      repoURL: "git@github.com:freiheit-com/nmww-manifests.git"
    37      targetRevision: kuberpult
    38    project: default
    39    syncPolicy:
    40      automated:
    41        prune: false
    42        selfHeal: false
    43  ---
    44  EOF
    45        fi
    46      done
    47    fi
    48  done
    49  
    50  echo "$0 done" > /dev/stderr
    51  
    52  exit 0