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 |
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) |
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 |
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" |
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 |
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 |
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"' ] |
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" | |
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 |
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
echo '{"my-field": "something"}' > example.json | |
cat example.json | jq '.my-field' # Incorrect | |
# jq: error: key/0 is not defined at <top-level>, line 1: .my-field | |
# jq: 1 compile error | |
cat example.json | jq '."my-field"' # Correct | |
# "something" |