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 |
View jq_dashes.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
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" |
View check_if_safe_to_release.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 | |
# Project in the form vcs-type/organisation-name/repository-name | |
PROJECT=github/magickatt/example | |
# First, get all the Pipeline IDs for this workflow (triggered by a Git tag from a new release) | |
PIPELINE_IDS=(`curl --silent GET https://circleci.com/api/v2/project/$PROJECT/pipeline \ | |
--header "Circle-Token: $CIRCLE_API_TOKEN" \ | |
| jq --raw-output '.items | map(select(.vcs.tag != null)) | .[].id'`) |
View Dockerfile
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
FROM python:3.9-buster | |
# Prevents issues with cloning private PIP packages from GitHub | |
RUN --mount=type=ssh mkdir -p ~/.ssh && ssh-keyscan -H github.com >> ~/.ssh/known_hosts | |
RUN pip install --upgrade pip | |
RUN pip install pipenv | |
COPY . . | |
# Use the forwarded SSH agent when installing pip packages |
NewerOlder