Skip to content

Instantly share code, notes, and snippets.

View swamibluedata's full-sized avatar

Swami Viswanathan swamibluedata

View GitHub Profile
# Run the following from API Master node
APISERVER=https://$(kubectl -n default get endpoints kubernetes --no-headers | awk '{ print $2 }')
SERVICE_ACCOUNT=hpecp-bootstrap
SECRET=$(kubectl -n hpecp-bootstrap get serviceaccount ${SERVICE_ACCOUNT} -o jsonpath='{.secrets[].name}')
TOKEN=$(kubectl -n hpecp-bootstrap get secret ${SECRET} -o jsonpath={.data.token} | base64 -d)
kubectl -n hpecp-bootstrap get secret ${SECRET} -o jsonpath='{.data.ca\.crt}' | base64 -d > /tmp/ca.crt
STS_NAMES=$(curl -s $APISERVER/apis/apps/v1/namespaces/hpecp/statefulsets?limit=1000 --header "Authorization: Bearer $TOKEN" --cacert /tmp/ca.crt | jq -rM '.items[].metadata.name')
for name in $STS_NAMES
apiVersion: settings.k8s.io/v1alpha1
kind: PodPreset
metadata:
name: tz-mount
namespace: hpecp
spec:
selector:
matchExpressions:
- key: kubedirector.hpe.com/role
operator: In
# Local Storage PV
cat <<EOF | kubectl apply -f -
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: local-storage
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: WaitForFirstConsumer
EOF
# Make sure macvlan cni driver is installed on all hosts under /opt/cni/bin
# ls -l /opt/cni/bin/macvlan. Follow these steps to install macvlan driver if not present already
# On each k8s master/worker nodes, do the following
cd /tmp
mkdir -p cni-plugins
cd cni-plugins
curl -LO https://github.com/containernetworking/plugins/releases/download/v0.8.6/cni-plugins-linux-amd64-v0.8.6.tgz
tar xvfz cni-plugins-linux-amd64-v0.8.6.tgz
cp macvlan /opt/cni/bin
#!/bin/bash
ALL_BUCKETS=$(aws s3 ls s3:// | awk '{print $3}')
for bucket in $ALL_BUCKETS
do
echo "BUCKET: $bucket"
aws s3 ls s3://$bucket --recursive --human-readable --summarize | tail -2
echo
done
yum install cryptsetup -y
DEVICE_NAME="/dev/xvdb"
PASSWORD="dummy password"
# Create a secret key file
mkdir -p /etc/luks-keys
echo "$PASSWORD" > /etc/luks-keys/secret
cat /etc/luks-keys/secret
@swamibluedata
swamibluedata / docker-routable-ip.sh
Last active July 31, 2020 23:03
Routable ips for docker
#! /bin/bash
# This document assumes following information is available for configuring routable ips
# for containers
# Primary interface to use
# Primary Subnet
# External Gateway ip
# Two static ipaddresses for the containers to use
# Ensure that primary nic is enabled with promiscuous mode.
# For ESX based vms, this has to be done from the vSwitch. For baremetal
NOT_RUNNING=$(kubectl get pods --no-headers -A | grep -v Running | awk '{printf "%s:%s\n", $1, $2}')
for not_running in $NOT_RUNNING
do
NS=$(echo $not_running | cut -d':' -f1)
POD=$(echo $not_running | cut -d':' -f2)
echo "deleting pod $NS:$POD"
kubectl -n $NS delete pod $POD
done
IMAGES=$(docker search bluedata --limit=100 | grep bluedata | awk '{print $1}')
echo "FOLLOWING IMAGES FOUND $IMAGES"
for image in $IMAGES; do
echo "fetching all tags for image $image"
TAGS=$(curl -s "https://registry.hub.docker.com/v2/repositories/$image/tags/" | jq -r '."results"[]["name"]')
for tag in $TAGS; do
echo "IMAGE TO PULL $image:$tag"
done
done
#! /bin/bash
DEPLOYMENT_NAME="$1"
OP="$2"
if [ "$OP" == "stop" ]
then
EC2_OP="aws ec2 stop-instances --instance-ids"
else
EC2_OP="aws ec2 start-instances --instance-ids"
fi