Skip to content

Instantly share code, notes, and snippets.

View hajowieland's full-sized avatar

Hans-Jörg Wieland hajowieland

View GitHub Profile
---
# eventing-core.yaml
# Copyright 2018 The Knative Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
@hajowieland
hajowieland / kubectl-delete-blocking-crd.sh
Created May 2, 2020 11:43
kubectl delete crd hanging / blocked on deletion (finalizers)
#!/bin/bash
CRD=$1
kubectl patch crd/$CRD -p '{"metadata":{"finalizers":[]}}' --type=merge
kubectl delete crd/$CRD
export AWS_ACCOUNT_ID=your-account-id
export AWS_ROLE=role-in-target-account
creds=$(aws --output text sts assume-role --role-arn $AWS_ROLE --role-session-name "my-session-name" | grep CREDENTIALS | cut -f2,4,5)
export AWS_ACCESS_KEY_ID=$(echo $creds | cut -f1)
export AWS_SECRET_ACCESS_KEY=$(echo $creds | cut -f2)
export AWS_SESSION_TOKEN=$(echo $creds | cut -f3)
@hajowieland
hajowieland / journald-cloudwatch-logs.sh
Last active April 8, 2020 13:38
Install and configure journald-cloudwatch-logs on EC2
# https://github.com/saymedia/journald-cloudwatch-logs
function install_journald_cloudwatch_logs() {
cd /tmp/ || return
wget https://github.com/saymedia/journald-cloudwatch-logs/releases/download/v0.0.1/journald-cloudwatch-logs-linux.zip
unzip journald-cloudwatch-logs-linux.zip
mv journald-cloudwatch-logs/journald-cloudwatch-logs /usr/local/bin/journald-cloudwatch-logs
mkdir -p /var/lib/journald-cloudwatch-logs
touch /var/lib/journald-cloudwatch-logs/state
chown ec2-user:ec2-user /var/lib/journald-cloudwatch-logs/state
}
apt-get install certbot python3-pip
pip3 install certbot-dns-route53
# Request Cert
/usr/local/openvpn_as/scripts/sacli ConfigQuery | grep -qe 'cs.cert'
LESTATUS=$?
if [ $LESTATUS -ne 0 ]
then
certbot certonly --non-interactive \
--dns-route53 \
curl -s https://ipvigilante.com/$(curl -s https://ipinfo.io/ip) | jq '.data.latitude, .data.longitude, .data.city_name, .data.country_name'
find ./ -type f -name "somefile.txt" -exec sed -i -e 's/foo/bar/g' {} \;
# Local:
git fetch --all --prune
# alternative: git branch -d $( git branch -vv | grep '\[[^:]\+: gone\]' | awk '{print $1}' | xargs )
# Remote:
git branch --remotes --merged | grep -v master | sed 's@ origin/@:@' | xargs git push origin
# 1. it find your public ip via ifconfig.io
# 2. than use this IP to request your timezone via worldtimeapi.org
# 3. and send it to the command timedatectl set-timezone
# By: https://www.commandlinefu.com/commands/view/24463/programmatic-way-to-find-and-set-your-timezone
sudo timedatectl set-timezone $(curl worldtimeapi.org/api/ip/$(curl ifconfig.io/ip)|cut -d\" -f16
# Without systemd:
echo 'Etc/UTC' | tee /etc/timezone; dpkg-reconfigure --frontend noninteractive tzdata
#!/usr/bin/env bash
# Depending on the environment you want to deploy there could be different custom values you want set
# This loop checks which stages are present and then lints them together with the helm chart
for chart in helm-charts/* ; do
if [ `ls $chart | grep 'prd'` ]; then
helm lint $chart -f $chart/prd_values.yaml
elif [ `ls $chart | grep 'dev'` ]; then
helm lint $chart -f $chart/dev_values.yaml