Skip to content

Instantly share code, notes, and snippets.

@nurlanf
nurlanf / kubernetes_add_service_account_kubeconfig.sh
Last active Sep 14, 2020 — forked from innovia/kubernetes_add_service_account_kubeconfig.sh
Create a service account and generate a kubeconfig file for it - this will also set the default namespace for the user
View kubernetes_add_service_account_kubeconfig.sh
#!/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
View Copy k8s secret to different namespace
oldns=default
newns=somenamespace
secret=mysecret
kubectl get secret $secret --namespace=$oldns --export -o yaml | kubectl apply --namespace=$newns -f -
View extract_emails.sh
#!/bin/bash
display_usage() {
echo "Usage: $0 <filename>"
}
if [ $# -eq 0 ]
then
display_usage
exit 1
fi
grep -o '[[:alnum:]+\.\_\-]*@[[:alnum:]+\.\_\-]*' $1 | sort | uniq -i
@nurlanf
nurlanf / gist:7cee28ed3a28253a27129b4a7be7bc3c
Created Mar 5, 2019 — forked from rkuzsma/gist:b9a0e342c56479f5e58d654b1341f01e
Example Kubernetes yaml to pull a private DockerHub image
View gist:7cee28ed3a28253a27129b4a7be7bc3c
Step by step how to pull a private DockerHub hosted image in a Kubernetes YML.
export DOCKER_REGISTRY_SERVER=https://index.docker.io/v1/
export DOCKER_USER=Type your dockerhub username, same as when you `docker login`
export DOCKER_EMAIL=Type your dockerhub email, same as when you `docker login`
export DOCKER_PASSWORD=Type your dockerhub pw, same as when you `docker login`
kubectl create secret docker-registry myregistrykey \
--docker-server=$DOCKER_REGISTRY_SERVER \
--docker-username=$DOCKER_USER \
@nurlanf
nurlanf / get_lat_lon_exif_pil.py
Last active Feb 21, 2019 — forked from erans/get_lat_lon_exif_pil.py
Get Latitude and Longitude from EXIF using PIL
View get_lat_lon_exif_pil.py
from PIL import Image
from PIL.ExifTags import TAGS, GPSTAGS
def get_exif_data(image):
"""Returns a dictionary from the exif data of an PIL Image item. Also converts the GPS Tags"""
exif_data = {}
info = image._getexif()
if info:
for tag, value in info.items():
decoded = TAGS.get(tag, tag)