Skip to content

Instantly share code, notes, and snippets.

Avatar

Andrew Kirkpatrick magickatt

View GitHub Profile
@magickatt
magickatt / github_clone_using_token.sh
Created Sep 6, 2019
Clone a GitHub repository using a Personal Access Token
View github_clone_using_token.sh
export GITHUB_USER=magickatt
export GITHUB_TOKEN=secret
export GITHUB_REPOSITORY=magickatt/ContainerisingLegacyApplicationsTalk
git clone https://${GITHUB_USER}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}
@magickatt
magickatt / restart_namespace.sh
Created Jan 31, 2021
Restart all deployments in a k8s namespace
View restart_namespace.sh
#!/bin/bash
if [ "$#" -ne 1 ]
then
echo "Usage: restart_namespace \$NAMESPACE"
exit 1
fi
NAMESPACE=$1
echo "Restarting all deployments in $NAMESPACE..."
@magickatt
magickatt / check_ssl_validity.sh
Created Jan 4, 2021
Check at specified intervals whether an SSL certificate is valid
View check_ssl_validity.sh
#!/bin/bash
URI=https://www.yahoo.com
INTERVAL_IN_SECONDS=0.5
RESULTS_PER_LINE=50
echo "Checking $URI at ${INTERVAL_IN_SECONDS}s intervals..."
check_uri () {
@magickatt
magickatt / filebeat.yaml
Created Nov 23, 2020
Filebeat configuration to ignore Consul Connect container logs
View filebeat.yaml
filebeat.autodiscover:
providers:
- type: kubernetes
hints.enabled: true
hints.default_config.enabled: false
add_resource_metadata:
namespace:
enabled: true
processors:
- add_kubernetes_metadata:
View function_countdown.sh
#!/bin/bash
# Random number between 1 and 10
WAIT=`shuf -i 1-10 -n 1`
# Subtract 1 from the random number, check if it is now 0
is_random_number_zero () {
let WAIT=WAIT-1
return $([[ "$WAIT" -eq "0" ]])
}
@magickatt
magickatt / cloud_iap_firewall_rule.tf
Last active Oct 22, 2020
Cloud IAP Terraform firewall rule for GKE
View cloud_iap_firewall_rule.tf
resource "google_compute_firewall" "allow_nodes_from_cloud_iap" {
name = "allow-gke-nodes-ssh-from-cloud-iap"
description = "Allow Cloud IAP to communicate with the the GKE nodes."
network = var.network
allow {
protocol = "tcp"
ports = ["22"]
}
@magickatt
magickatt / example_uid.yaml
Created Aug 6, 2020
Expose Kubernetes Pod UID as an environment variable to a container
View example_uid.yaml
apiVersion: v1
kind: Pod
metadata:
name: example-uid
spec:
containers:
- name: test
image: busybox
command: ["/bin/sh", "echo", "$EXAMPLE_UID"]
env:
View helm_dots_to_dashes.yaml
apiVersion: networking.gke.io/v1beta2
kind: ManagedCertificate
metadata:
name: {{ .Values.domain | replace "." "-" }}
namespace: kise
spec:
domains:
- {{ .Values.domain }}
View access_gcr_images_from_other_projects.tf
locals {
project_ids = [123456789012, 234567890123, 345678901234]
bucket_region = "us"
bucket_project = "something-123456"
bucket_name = "${local.bucket_region}.artifacts.${local.bucket_project}.appspot.com"
}
# Allow Cloud Build in every other project access to GCR images hosted in the central project
resource "google_storage_bucket_iam_member" "container_registry" {
for_each = var.project_ids
View access_vm_images_from_other_projects.tf
locals {
project_ids = [123456789012, 234567890123, 345678901234]
}
# Allow every other project access to GCE VM images in a central project
resource "google_project_iam_member" "image_user" {
for_each = local.project_ids
project = "tools-275721"
role = "roles/compute.imageUser"