Last active
February 7, 2024 23:58
-
-
Save corkupine/b795b2e6a21d473e39b4b74f1e270fc2 to your computer and use it in GitHub Desktop.
This file contains 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
Port-forward a k8s service | |
k port-forward svc/argo-cd-argocd-server 12345:443 -n argocd | |
Get shell on a pod | |
k -n [namespace] exec -i -t [argocd server pod name] -- /bin/bash | |
add --container param for specific container | |
List all non-running pods | |
k get pods --field-selector status.phase!=Running -A | |
Count pods | |
k get pods --all-namespaces --no-headers=true | wc -l | |
Get all available packages | |
apt list -a kubectl | |
apt-cache madison kubectl | |
Edit manifests directly in-cluster | |
export KUBE_EDITOR="nano" | |
k edit deployment watchman-api -n 15five-dev | |
Install previous versions of packages | |
npm install [email protected] --save-dev | |
sudo apt-get install kubectl=2.21.3-00 | |
scoop install [email protected] AND scoop reset [email protected] | |
update kubecfg | |
aws eks update-kubeconfig --name utility-green --region us-west-2 --profile sandbox | |
tell OS where to find kubeconfig | |
KUBE_CONFIG_PATH=/path/to/.kube/config | |
copy local file to a pod | |
k -n argocd cp argocd-backup-1.8.7.yaml argo-cd-argocd-server-c6b76c4db-ggztb:argocdbackup.yaml | |
fix ubuntu DNS issues - often causes terraform init problems | |
sudo nano /etc/resolv.conf | |
replace nameserver with cloudflare servers: | |
nameserver 1.1.1.1 | |
nameserver 1.0.0.1 | |
import argocd stuff on to pod - requires copying file to pod first | |
argocd admin import - < argocdbackup.yaml | |
ArgoCD < 2.0 | |
argocd-util export | |
get logs | |
kubektl logs | |
kubectl get pod -o yaml | |
kubectl get events | |
kubectl describe | |
use a specific aws profile by default | |
set AWS_PROFILE env var | |
Read helm state from secrets | |
kubectl get secrets sh.helm.release.v1.wordpress.v1 -o json | jq .data.release | tr -d '"' | base64 -d | base64 -d | gzip -d | |
Powershell Base64-encode | |
[Convert]::ToBase64String([System.Text.Encoding]::Unicode.GetBytes("stuuuuufff")) | |
Get all pod images | |
kubectl get pods --all-namespaces -o jsonpath="{.items[*].spec.containers[*].image}" | tr -s '[[:space:]]' '\n' | sort | uniq -c | |
Delete completed jobs - will delete corresponding pods | |
kubectl delete jobs --all-namespaces --field-selector status.successful=1 | |
Docker build, tag, push | |
docker build -t nzp-msg-processor -f ./src/NZP.SingleMessageProcessor/Dockerfile . | |
docker image tag nzp-msg-processor:latest 256348465055.dkr.ecr.us-east-2.amazonaws.com/nzp-msg-processor:latest | |
aws ecr get-login-password --region us-east-2 | docker login --username AWS --password-stdin 256348465055.dkr.ecr.us-east-2.amazonaws.com | |
docker image push 256348465055.dkr.ecr.us-east-2.amazonaws.com/nzp-msg-processor:latest | |
Get a shell on an ephemeral pod | |
kubectl run -i --tty temp-pod --image=busybox --restart=Never --rm --namespace my-namespace | |
ctrl+d to bail | |
Log into Argo CD from CLI | |
argocd login --insecure --port-forward --port-forward-namespace=argocd --plaintext | |
Generate helm templates locally - from root chart directory | |
helm dependency build | |
helm template test ./ -f values.yaml -f dev.values.yaml -f beta-dev.values.yaml > rendered.yaml | |
List all Argo CD applications and their creation date using kubectl | |
kubectl get applications.argoproj.io -A -o custom-columns=CREATED:.metadata.creationTimestamp,NAME:.metadata.name | awk 'NR>1' | sort -k1 | |
Patch finalizer to allow deletion of a pod (a finalizer can prevent a pod from being deleted) | |
Add `--type merge` if there are merge errors | |
kubectl patch service svc-name -n namespace -p "{\"metadata\":{\"finalizers\":null}}" | |
k patch eventsource aws-sqs -n namespace --type merge -p "{\"metadata\":{\"finalizers\":null}}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment