Skip to content

Instantly share code, notes, and snippets.

View caffeinetiger's full-sized avatar

Tony Benavides caffeinetiger

  • Chromatic Ai Swarm
  • Earth
View GitHub Profile
select AURORA_VERSION();
select @@aurora_version;
show variables like '%version';

Updated: Dec 21, 2020

I’ve personally used these commands to debug in production. I also used GUI methods like k9s and lenses.io.

0. Impersonate a user and group

kubectl get pods --as-group="somecompany:somecompany-teamname" --as="test"
#!/bin/bash
kubectl autoscale deployment <name-of-deployment> --cpu-percent=75 --min=2 --max=10
#!/bin/bash
# List installed JDK versions
/usr/libexec/java_home -V
# Export in current session
export JAVA_HOME=`/usr/libexec/java_home -v <version>`
# Create a function in .bashrc, .zshrc, .zshenv, etc
function switch_openjdk_version() {
@caffeinetiger
caffeinetiger / docker_multi_platform_building.sh
Last active April 18, 2022 18:17
To use this snippet you will enable the Docker buildx feature which is currently “experimental”. To do so, open up Docker Desktop then navigate to Preferences. Once you’re there, select “Experimental Features” and toggle the slider to on. Click on “A
#!/bin/bash
# List available platforms for building
docker buildx ls
# Create multiple builder instances to build multi-platform with build command
docker buildx create --use
docker buildx build --platform linux/amd64,linux/arm64 --push -t membermatters/membermatters .
# Build for single platform
#!/bin/bash
kubectl scale --replicas=0 deployment/<your-deployment>
#!/bin/bash
# Prune all unused images
docker image prune --all
# The filtering flag (--filter) format is of “key=value”. If there is more than one filter, then pass multiple flags
docker image prune --filter "foo=bar"
# For more details on the filter flag option see official documentation mentioned in the description
# Prune all unused images with no confirmation
@caffeinetiger
caffeinetiger / retagging_ecr_image.sh
Last active April 18, 2022 18:16
There is no user friendly way to retag an image in the AWS ECR Web Console. You need to use AWS CLI commands to accomplish this. - [Official AWS Documentation](https://docs.aws.amazon.com/AmazonECR/latest/userguide/image-retag.html) - [Stackoverflow
#!/bin/bash
# Get image manifest by tag
MANIFEST=$(aws ecr batch-get-image --repository-name amazonlinux --image-ids imageTag=latest --output json | jq --raw-output '.images[0].imageManifest')
# Or
# Get image manifest by digest (this is found on the ECR repo page in the AWS Web Console)
MANIFEST=$(aws ecr batch-get-image --repository-name amazonlinux --image-ids imageDigest=sha256:8e080763aa56a2d509f9614613019ff0d9fe9cfd651b2efdb8961356c9ea6e26 --query 'images[].imageManifest' --output text)
# Update image with new tag
aws ecr put-image --repository-name amazonlinux --image-tag previous.2018 --image-manifest "$MANIFEST"