Last active
March 30, 2022 20:41
-
-
Save amazingandyyy/682c0ed12e0006118fb5287146247844 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
if ! [ -x "$(command -v gsed)" ]; then | |
echo "insall gsed" | |
brew install gnu-sed | |
fi | |
set -e | |
export SERVICE_NAME=$1 | |
export CLUSTER_VERSION=$2 | |
export CURRENT=$3 | |
function migrate() { | |
export ENVIRONMENT=$1 | |
cp -r ${CURRENT}/deployments/${SERVICE_NAME}/clusters/${ENVIRONMENT}/ ${CURRENT}/deployments/${SERVICE_NAME}/clusters/${ENVIRONMENT}-${CLUSTER_VERSION} | |
touch ${CURRENT}/deployments/${SERVICE_NAME}/clusters/${ENVIRONMENT}-${CLUSTER_VERSION}/ingress.${CLUSTER_VERSION}-dns.patch.yaml | |
echo "- op: replace" > ${CURRENT}/deployments/${SERVICE_NAME}/clusters/${ENVIRONMENT}-${CLUSTER_VERSION}/ingress.${CLUSTER_VERSION}-dns.patch.yaml | |
echo " path: /spec/rules/0/host" >> ${CURRENT}/deployments/${SERVICE_NAME}/clusters/${ENVIRONMENT}-${CLUSTER_VERSION}/ingress.${CLUSTER_VERSION}-dns.patch.yaml | |
echo " value: ${SERVICE_NAME}-internal-${CLUSTER_VERSION}.${ENVIRONMENT}.rr.mu" >> ${CURRENT}/deployments/${SERVICE_NAME}/clusters/${ENVIRONMENT}-${CLUSTER_VERSION}/ingress.${CLUSTER_VERSION}-dns.patch.yaml | |
tmpfile=${CURRENT}/deployments/${SERVICE_NAME}/clusters/${ENVIRONMENT}-${CLUSTER_VERSION}/kustomization-tmp.yaml | |
touch $tmpfile | |
set -x | |
echo " - path: ingress.${CLUSTER_VERSION}-dns.patch.yaml | |
target: | |
kind: Ingress | |
name: ${SERVICE_NAME}-ingress" > $tmpfile | |
gsed -Ei "/^patches/r $tmpfile" ${CURRENT}/deployments/${SERVICE_NAME}/clusters/${ENVIRONMENT}-${CLUSTER_VERSION}/kustomization.yaml | |
rm -rf $tmpfile | |
# git add . && git commit -m "feat(deployment): create $ENVIRONMENT-$CLUSTER_VERSION deployment" --no-verify | |
mkdir -p ${CURRENT}/argo-applications/clusters/${ENVIRONMENT}-${CLUSTER_VERSION} | |
echo "apiVersion: kustomize.config.k8s.io/v1beta1 | |
kind: Kustomization | |
resources: | |
- ../../base | |
patches: | |
- target: | |
kind: Application | |
name: ${SERVICE_NAME} | |
path: application.patch.yaml" > ${CURRENT}/argo-applications/clusters/${ENVIRONMENT}-${CLUSTER_VERSION}/kustomization.yaml | |
echo "- op: replace | |
path: /spec/source/path | |
value: deployments/${SERVICE_NAME}/clusters/${ENVIRONMENT}-${CLUSTER_VERSION}"> ${CURRENT}/argo-applications/clusters/${ENVIRONMENT}-${CLUSTER_VERSION}/application.patch.yaml | |
# git add . && git commit -m "feat(argo-app): register $ENVIRONMENT-$CLUSTER_VERSION argo app" --no-verify | |
} | |
for i in com xyz; do | |
migrate $i | |
done | |
rm -rf ${CURRENT}/.fotingorc | |
# git add . && git commit -m "chore(script): remove .fotingorc" | |
echo "DONEEEEEEE" |
export SERVICE_NAME=trip-deposit
export CLUSTER_VERSION=v2
bash <(curl -sL https://gist.githubusercontent.com/amazingandyyy/682c0ed12e0006118fb5287146247844/raw/b0aff4ae7cbe9fbdf7cc9db416a050cf7992722c/migrate.sh) $SERVICE_NAME $CLUSTER_VERSION .
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage