Useful Commands - bcgov/common-service-showcase GitHub Wiki
This page will list useful commands that are not frequently used.
git fetch --all;git remote prune $(git remote)
git add .
git stash
git rebase bcgov/master
# follow rebase instructions in case of conflicts
git stash pop
If your current "working" branch is only on local machine, you're done and can proceed. If your fork already has some WIP changes and previous commits, you need to force push.
git push <yourforkremotename> <yourbranchname> --force
Double check this is exactly what you want to do before you force anything!!
If you rebased correctly, you can run the following command to see the commit topology:
git log --pretty=oneline --graph --date=short
You should ideally see bcgov/master
and then a string of your own branch contents in a line above that point.
oc exec -ti -n <namespace id eg: abcdef-dev> <pod name> <container_name> -- sh
ref: stackoverflow
oc cp <namespace_name>/<pod_name>:<remote_file_path> <local_file_path> -c <container_name>
oc cp <local_file_path> <namespace_name>/<pod_name>:<remote_file_path> -c <container_name>
oc projects -q | xargs -I {} sh -c 'echo -e "\n{}:" && oc get -n {} pod -o wide 2>/dev/null | grep Running' | awk '{print $1","$7}' | column -t -s ,
export $NAMESPACE=<NAMESPACE>
oc get imagestreamtag -n $NAMESPACE -o name | grep ':pr-' | sort | sed 's|imagestreamtag.image.openshift.io/||' | xargs oc tag -n $NAMESPACE -d
export NAMESPACE=<YOURNAMESPACE>
# Create and bind roles to service account
oc create -n $NAMESPACE sa github-actions
oc policy -n $NAMESPACE add-role-to-user admin -z github-actions
oc policy -n $NAMESPACE add-role-to-user edit -z github-actions
# Get secret token (put this into OPENSHIFT_TOKEN environment secret)
oc get -n $NAMESPACE secret $(oc get -n $NAMESPACE sa github-actions -o json | jq '.secrets[].name | select(test(.|"token"))' -r) -o json | jq '.data.token' -r | base64 -di
oc create -n $NAMESPACE secret docker-registry dockerhub-registry --docker-server=docker.io --docker-username=bcgovcommonservices --docker-password=REDACTED [email protected]
oc -n $NAMESPACE secrets link default dockerhub-registry --for=pull
oc -n $NAMESPACE secrets link builder dockerhub-registry
oc create -n $NAMESPACE secret docker-registry artifactory-registry --docker-server=artifacts.developer.gov.bc.ca --docker-username=default-abc123-xyz456 --docker-password=REDACTED --docker-email=default-abc123-xyz456@$NAMESPACE.local
oc -n $NAMESPACE secrets link default artifactory-registry --for=pull
oc -n $NAMESPACE secrets link builder artifactory-registry
oc exec -n $NAMESPACE -it ches-app-master-61-9fkv8 -c app -- /bin/sh -c "kill 1"
For each namespace, creates empty file .yaml, writes all the secrets in there and outputs to current local directory.
oc projects -q | xargs -i sh -c 'type NUL > {}.yaml; oc get -n {} secrets -o yaml > {}.yaml'
For each namespace, give user a role (where is 'admin','edit' or 'view' and user is azure email address.
oc projects -q | xargs -i sh -c 'echo -e "\n{}:" && oc adm policy add-role-to-user <role> <user> -n {}'
oc projects -q | xargs -i sh -c 'echo -e "\n{}:" && oc adm policy remove-role-from-user <role> <user> -n {}'
For more details see: https://docs.developer.gov.bc.ca/grant-user-access-openshift/
patronictl reinit
du -ah /home/postgres/pgdata/ | grep -v "/$" | sort -rh
cat /home/postgres/pgdata/pgroot/data/pg_hba.conf
from inside a patroni pod:
cat /home/postgres/pgdata/pgroot/data/pg_hba.conf
- Add the Patroni chart repository:
helm repo add <repo name> <repo url>
- search versions in repo:
helm search repo <repo name> -l
- update repo with new versions
helm repo update <repo name>
- Install a chart:
helm install -n abcdef-dev <release name> <repo name>/<chart name> --version 0.0.1
- lists all of the releases
helm list --all
- Uninstall a release
helm uninstall -n abcdef-dev <release name>
tar -xvzf .\a.tgz -C .