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
def retry(times, exceptions): | |
""" | |
Retry Decorator | |
Retries the wrapped function/method `times` times if the exceptions listed | |
in ``exceptions`` are thrown | |
:param times: The number of times to repeat the wrapped function/method | |
:type times: Int | |
:param Exceptions: Lists of exceptions that trigger a retry attempt |
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 -e | |
# Usage ./k8s-service-account-kubeconfig.sh ( namespace ) ( service account name ) | |
TEMPDIR=$( mktemp -d ) | |
trap "{ rm -rf $TEMPDIR ; exit 255; }" EXIT | |
SA_SECRET=$( kubectl get sa -n $1 $2 -o jsonpath='{.secrets[0].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
#!/bin/bash -e | |
# Usage ./k8s-service-account-kubeconfig.sh ( namespace ) ( service account name ) | |
TEMPDIR=$( mktemp -d ) | |
trap "{ rm -rf $TEMPDIR ; exit 255; }" EXIT | |
SA_SECRET=$( kubectl get sa -n $1 $2 -o jsonpath='{.secrets[0].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
relabel_configs: | |
- source_labels: [__meta_kubernetes_service_annotation_prometheus_io_scrape] | |
action: keep | |
regex: true | |
- target_label: __address__ | |
replacement: <api server address> | |
- source_labels: [__meta_kubernetes_service_annotation_prometheus_io_scheme] | |
regex: ^$ | |
replacement: http | |
target_label: __meta_kubernetes_service_annotation_prometheus_io_scheme |
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
# Inspired by: https://stackoverflow.com/questions/42170380/how-to-add-users-to-kubernetes-kubectl | |
# this script creates a service account (user1) on a Kubernetes cluster (tested with AWS EKS 1.9) | |
# prereqs: a kubectl ver 1.10 installed and proper configuration of the heptio authenticator | |
# this has been tested on Linux in a Cloud9 environment (for MacOS the syntax may be slightly different) | |
************************************************** | |
******* Create an account ******* | |
************************************************** | |
# Create service account for user user1 | |
kubectl create sa user1 |
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 | |
set -e | |
set -o pipefail | |
# Add user to k8s using service account, no RBAC (must create RBAC after this script) | |
if [[ -z "$1" ]] || [[ -z "$2" ]]; then | |
echo "usage: $0 <service_account_name> <namespace>" | |
exit 1 | |
fi |
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
#!/usr/bin/env bash | |
set -x | |
NS="ns1" | |
VETH="veth1" | |
VPEER="vpeer1" | |
VETH_ADDR="10.200.1.1" | |
VPEER_ADDR="10.200.1.2" |
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
#!/usr/bin/env bash | |
set -x | |
NS="ns1" | |
VETH="veth1" | |
VPEER="vpeer1" | |
VETH_ADDR="10.200.1.1" | |
VPEER_ADDR="10.200.1.2" |
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 -xe | |
EBS_DEVICE='/dev/sdh' | |
INSTANCE_ID=$1 | |
AKI=${2:-'aki-5f15f636'} | |
ARI=${3:-'ari-0915f660'} | |
ARCH=${4:-'i386'} | |
SIZE=${5:-10} | |
AZ=${6:-'us-east-1d'} | |
NAME=${7:-"ami-from-$INSTANCE_ID"} |