Last active
April 16, 2020 09:44
-
-
Save memoryonrepeat/63a8a022d1fb733ec690cdca5f152f1f to your computer and use it in GitHub Desktop.
devops
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
| # /cpu/{sub(/requests/, "found!!!!", last)} NR>1{print last} {last=$0} END {print last} | |
| { | |
| # $0 is current line | |
| if ($0 ~ /cpu/ && previous ~ /requests/){ | |
| sub(/cpu: "0.1"/,"cpu: \"0.01\"",$0) | |
| print(previous) | |
| } | |
| else if ($0 ~ /cpu/ && previous ~ /limits/) { | |
| sub(/cpu: "0.1"/,"cpu: \"1\"",$0) | |
| print(previous) | |
| } | |
| else if ($0 ~ /memory/ && previous ~ /cpu: "0.01"/) { | |
| sub(/memory: 0.3Gi/,"memory: 0.1Gi",$0) | |
| print(previous) | |
| } | |
| else if ($0 ~ /memory/ && previous ~ /cpu: "1"/) { | |
| sub(/memory: 0.3Gi/,"memory: 0.5Gi",$0) | |
| print(previous) | |
| } | |
| else{ | |
| print(previous) | |
| #if (previous){ | |
| # print(previous) | |
| #} | |
| } | |
| previous=$0 | |
| } | |
| END { | |
| # print last line | |
| print($0) | |
| } |
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
| #!/bin/bash | |
| ## Root directory of service repositories | |
| HOME_DIRECTORY='~/fcg-workspace' | |
| UPDATED_FILE='~/updated.yml' | |
| ## declare an array variable | |
| declare -a types=( | |
| "app" | |
| "service" | |
| ) | |
| declare -a services=( | |
| "auth" | |
| "auction" | |
| "contact" | |
| "booking" | |
| "car" | |
| "cms" | |
| "document" | |
| "image2" | |
| "inspection" | |
| "integrity" | |
| "order" | |
| "salesManagement" | |
| "search" | |
| "trigger" | |
| ) | |
| declare -a apps=( | |
| "admin" | |
| "admin-v2" | |
| "customer" | |
| ) | |
| # loop through the services above | |
| for type in "${types[@]}" | |
| do | |
| if [ "$type" = "app" ]; then | |
| for app in "${apps[@]}" | |
| do | |
| eval "cd $HOME_DIRECTORY/$type/$app" | |
| eval "git reset HEAD" | |
| eval "git checkout ." | |
| eval "git clean -df" | |
| eval "git checkout master" | |
| eval "git branch -D update-cpu-limits Update-cpu-resources" | |
| eval "git push origin --delete update-cpu-limits Update-cpu-resources" | |
| eval "git checkout -b update-cpu-limits" | |
| eval "awk -f ~/awkscript $HOME_DIRECTORY/$type/$app/k8s/deployment.yml > temp.yml" | |
| eval "cat temp.yml > $HOME_DIRECTORY/$type/$app/k8s/deployment.yml" | |
| eval "rm temp.yml" | |
| eval "git add ." | |
| eval "git commit -m \"Update deployment.yml cpu limits\"" | |
| # eval "git push" | |
| done | |
| else | |
| for service in "${services[@]}" | |
| do | |
| eval "cd $HOME_DIRECTORY/$type/$service" | |
| eval "git reset HEAD" | |
| eval "git checkout ." | |
| eval "git clean -df" | |
| eval "git checkout master" | |
| eval "git branch -D update-cpu-limits Update-cpu-resources" | |
| eval "git push origin --delete update-cpu-limits Update-cpu-resources" | |
| eval "git checkout -b update-cpu-limits" | |
| eval "awk -f ~/awkscript $HOME_DIRECTORY/$type/$service/k8s/deployment.yml > temp.yml" | |
| eval "cat temp.yml > $HOME_DIRECTORY/$type/$service/k8s/deployment.yml" | |
| eval "rm temp.yml" | |
| eval "git add ." | |
| eval "git commit -m \"Update deployment.yml cpu limits\"" | |
| # eval "git push" | |
| done | |
| fi | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment