Skip to main content

Heroku vs GKE cheatsheet

Heroku commandsGKE CommandsUse caseDocumentation
heroku run rails c -a powr-stagingkubectl exec -it deployments/web -n staging -- rails crails console accessUse kubectl get all -n {namespace} to get {POD_NAME} and replace that with pod name (including brackets). Further read: https://powr.gitlab.io/docs/kube/test-code-inside-container-correct.md
heroku run rails c -a powr-staging --type=workerkubectl exec -it deployments/sidekiq -n staging -- rails crails console accessUse kubectl get all -n {namespace} to get {POD_NAME} and replace that with pod name (including brackets). Further read: https://powr.gitlab.io/docs/kube/test-code-inside-container-correct.md
heroku run bash -a powr-outletkubectl exec -it deployments/outlet -n staging -- bashrails console accessUse kubectl get all -n {namespace} to get {POD_NAME} and replace that with pod name (including brackets). Further read: https://powr.gitlab.io/docs/kube/test-code-inside-container-correct.md
heroku run bash -a powr-counterkubectl exec -it deployments/counter -n staging -- bashrails console accessUse kubectl get all -n {namespace} to get {POD_NAME} and replace that with pod name (including brackets). Further read: https://powr.gitlab.io/docs/kube/test-code-inside-container-correct.md
heroku run bash -a powr-review-app-149kubectl exec -it deployments/pr-149 -n pr-149 -- bashrails console accessCheckout pull request URL on github to get pr_number and replace pr-149 with pr-{pr_number} for your prapp
heroku run rails c -a powr-review-app-149kubectl exec -it deployments/pr-149 -n pr-149 -- rails crails console accessCheckout pull request URL on github to get pr_number and replace pr-149 with pr-{pr_number} for your prapp
heroku config:set DATABASE_URL=something -a powr-stagingkubectl -n staging set env $DATABASE_URL=something {POD_NAME}change env variableUse kubectl get all -n {namespace} to get {POD_NAME} and replace that with pod name (including brackets). Further read: https://powr.gitlab.io/docs/kube/test-code-inside-container-correct.mdImportant Notes:1. Changes to env variable trigger redeploy of that particular pod2. Setting env is not permanent, they will be defaulted after nearest redeploy to that cluster3. to preserve new value of environment variable also change that on GH Secrets by going to: https://github.com/powrful/powr/settings/secrets/actions and edit DATABASE_URL, so changes will remain applied after new deploy
hard rollback WEB to previous deploykubectl -n {branch_name} set image deployment/web \web=ghcr.io/powrful/alpha/web:$(curl sha.api.powr-staging.io/api/v1/powrful/{branch_name}/web\?get=1)hard rollback to previous docker image tagImportant Notes:1. Manual update will only live until next deploy2. To make changes permanent revert the last merge on the corresponding branch
hard rollback COUNTER to previous deploykubectl -n {branch_name} set image deployment/counter \web=ghcr.io/powrful/alpha/web:$(curl sha.api.powr-staging.io/api/v1/powrful/{branch_name}/web\?get=1)hard rollback to previous docker image tagImportant Notes:0. replace {branch_name} with branch name, e.g. alpha, staging or main1. Manual update will only live until next deploy2. To make changes permanent revert the last merge on the corresponding branch3. Hard rollback feature isn't available for pr-apps
hard rollback OUTLET to previous deploykubectl -n {branch_name} set image deployment/outlet \web=ghcr.io/powrful/alpha/web:$(curl sha.api.powr-staging.io/api/v1/powrful/{branch_name}/web\?get=1)hard rollback to previous docker image tagImportant Notes:0. replace {branch_name} with branch name, e.g. alpha, staging or main1. Manual update will only live until next deploy2. To make changes permanent revert the last merge on the corresponding branch3. Hard rollback feature isn't available for pr-apps
heroku logs -t -a powr-stagingkubectl logs deployments/web -n stagingtail rails, sidekiq, nginx logsFurther read: https://powr.gitlab.io/docs/kube/test-code-inside-container-correct.md Other option is to use web interface, just go to https://console.cloud.google.com/logs/query;cursorTimestamp=2022-04-26T16:37:35.517368Z?authuser=0&project=powr-staging to see logs of all pods of powr-staging or powr-prod projects. You could also use filter logs with queries: https://cloud.google.com/logging/docs/view/query-library
heroku logs -t -a powr-prodkubectl logs deployments/web -n maintail rails, sidekiq, nginx logsFurther read: https://powr.gitlab.io/docs/kube/test-code-inside-container-correct.md Other option is to use web interface, just go to https://console.cloud.google.com/logs/query;cursorTimestamp=2022-04-26T16:37:35.517368Z?authuser=0&project=powr-staging to see logs of all pods of powr-staging or powr-prod projects. You could also use filter logs with queries: https://cloud.google.com/logging/docs/view/query-library
heroku run rake some_taskkubectl exec -n staging -it deployments/sidekiq -- bundle exec rake some_taskrun rake tasksReplace {NAMESPACE} with a proper namespace that are named according to source branch on a github repo: main and staging for production and staging respectively. To get full pod name use kubectl get all -n {NAMESPACE}. Further read: https://powr.gitlab.io/docs/kube/test-code-inside-container-correct.md
heroku ps:restart web -a powrkubectl -n staging rollout restart deployment webrestart dynosFor our installation {SHORT_POD_NAME} is either web, sidekiq, outlet, counter or ingress. This command is kubectl context dependent, so please check if your instance isn't looking on production. Further read: https://powr.gitlab.io/docs/kube/run-kubectl-on-your-machine
heroku ps:restart web -a powr --type=workerkubectl -n staging rollout restart deployment sidekiqrestart dynosFor our installation {SHORT_POD_NAME} is either web, sidekiq, outlet, counter or ingress. This command is kubectl context dependent, so please check if your instance isn't looking on production. Further read: https://powr.gitlab.io/docs/kube/run-kubectl-on-your-machine

Cheatsheet