View adopt_helm_deployment_pod_resources.sh
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
# Can use https://gist.github.com/magickatt/e7885f748c2ecd5bb88dd64828b30fbf | |
# to adopt the Deployment resources themselves | |
NAME=test | |
NAMESPACE=default | |
kubectl get -n $NAMESPACE deployment -o name \ | |
| xargs -I % kubectl patch -n $NAMESPACE % -p \ | |
'{"spec": {"template":{"metadata":{"annotations":{"meta.helm.sh/release-name": "$NAME"}}}}}' |
View adopt_helm_resources.sh
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
#!/bin/bash | |
NAME=test | |
NAMESPACE=default | |
RESOURCES=service,role.rolebinding # Comma-delimited | |
kubectl get -n $NAMESPACE $RESOURCES -o name \ | |
| xargs -I % kubectl label -n $NAMESPACE % app.kubernetes.io/managed-by=Helm | |
kubectl get -n $NAMESPACE $RESOURCES -o name \ | |
| xargs -I % kubectl annotate -n $NAMESPACE % meta.helm.sh/release-name=$NAME |
View gmp_version.py
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
# https://stackoverflow.com/a/22981757 | |
import ctypes | |
so_name='/usr/lib64/libgmp.so.10' # or /usr/lib/libgmp.so, etc | |
var_name='__gmp_version' | |
L=ctypes.cdll.LoadLibrary(so_name) | |
v=ctypes.c_char_p.in_dll(L,var_name) | |
print(v.value) |
View gke_iam.yaml
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
apiVersion: v1 | |
kind: ServiceAccount | |
metadata: | |
# Create a GKE Service Account that binds to a GCP Service Account | |
name: my_service_gke_serviceaccount | |
namespace: default | |
annotations: | |
iam.gke.io/gcp-service-account: my-project-gcp-serviceaccount@project-123456.iam.gserviceaccount.com | |
--- | |
apiVersion: v1 |
View gcp_iam.tf
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
locals { | |
gcp_project_id = "project-123456" | |
gke_namespace = "default" | |
gke_service_account_name = "my-service-gke-serviceaccount" | |
} | |
# GCP Service Account (not to be confused with the GKE Service Account) | |
resource "google_service_account" "my_service" { | |
account_id = "my_service_gcp_serviceaccount" | |
display_name = "my_service" |
View helm_chart_validate_matrix.yml
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
name: Validate Helm charts | |
on: | |
push: | |
branches: [ main, master ] | |
pull_request: | |
jobs: | |
validate: | |
runs-on: ubuntu-latest |
View helm_chart_validate.yml
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
name: Validate Helm chart | |
on: | |
push: | |
branches: [ main, master ] | |
pull_request: | |
jobs: | |
validate: | |
runs-on: ubuntu-latest |
View check_container_status.sh
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
#!/bin/bash | |
IMAGE_NAME=test-1 | |
# 1-liner | |
until [ $(docker inspect -f "{{json .State.Status }}" $(docker ps -a -q --filter ancestor=$IMAGE_NAME --format="{{.ID}}" | head -n 1)) == '"running"' ]; do echo "Waiting for container to start..." && sleep 1; done | |
# More readable | |
CONTAINER_ID=$(docker ps --all --quiet --filter ancestor=$IMAGE_NAME --format="{{.ID}}" | head -n 1) | |
CONTAINER_STATUS=$(docker inspect --format "{{json .State.Status }}" $CONTAINER_ID) | |
until [ $CONTAINER_STATUS == '"running"' ] |
View silly_super.py
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
class Animal: | |
def what_am_i(self) -> str: | |
return "I am a " | |
class Fox(Animal): | |
def what_am_i(self) -> str: | |
return super().what_am_i() + "Fox" | |
View delete_namespace.sh
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
#!/bin/bash | |
NAMESPACE=test | |
kubectl proxy & | |
kubectl get namespace $NAMESPACE -o json |jq '.spec = {"finalizers":[]}' >temp.json | |
curl -k -H "Content-Type: application/json" -X PUT --data-binary @temp.json 127.0.0.1:8001/api/v1/namespaces/$NAMESPACE/finalize | |
killall kubectl |
NewerOlder