Skip to content

Instantly share code, notes, and snippets.

View arsham's full-sized avatar

Arsham Shirvani arsham

View GitHub Profile
@arsham
arsham / suspend_cronjob.sh
Last active January 12, 2022 15:33
Suspend #kubernetes cronjobs
kubectl patch cronjobs <job-name> -p '{"spec" : {"suspend" : true }}'
# Change the default browser to brave.
xdg-settings set default-web-browser brave-browser.desktop
@arsham
arsham / ssh_github_travis.sh
Created September 16, 2021 08:50
Generate #ssh key that both #github and #travis agree on
ssh-keygen -t rsa -b 4096 -m PEM -f <keyname>
@arsham
arsham / show_ssh_fingerprint.sh
Created July 27, 2020 15:43
Show #ssh fingerprint
ssh-keygen -E md5 -lf ~/.ssh/id_rsa.pub
@arsham
arsham / clear_terminating_namespaces.md
Created January 25, 2019 15:20
Clear terminating namespaces (runaway) on #kubernetes
kubectl proxy
kubectl get ns | grep Terminating | awk '{print $1}' | xargs  -n1 -- bash -c 'kubectl get ns "$0" -o json | jq "del(.spec.finalizers[0])" > "$0.json"; curl -k -H "Content-Type: application/json" -X PUT --data-binary @"$0.json" "http://127.0.0.1:8001/api/v1/namespaces/$0/finalize" '
@arsham
arsham / kubernetes_docker_login.sh
Created January 24, 2019 13:29
Login to #docker hub in #kubernetes
docker login
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Secret
metadata:
name: registrypullsecret
data:
.dockerconfigjson: "$(cat ~/.docker/config.json | base64 | tr -d '\n')"
type: kubernetes.io/dockerconfigjson
@arsham
arsham / kubernetes_access_remote.sh
Last active January 17, 2019 17:18
Access remote #kubernetes cluster
##################
### BETTER WAY ###
##################
cat <<EOF | kubectl apply -f -
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: admin-role
rules:
@arsham
arsham / kubernetes_new_token.sh
Created January 16, 2019 16:13
Create a new join token for #kubernetes
kubeadm token create --print-join-command
@arsham
arsham / setup_kubernetes.md
Last active January 17, 2019 17:12
Setup a #kubernetes cluster.

This setup will make weave behave correctly (the pod-network-cidr). The HOST_IP should be the IP the nodes can access.

kubeadm init --apiserver-advertise-address=HOST_IP --pod-network-cidr=10.4.0.0/16 --apiserver-cert-extra-sans=EXTERA_IPS
mkdir -p /home/arsham/.kube
cp -i /etc/kubernetes/admin.conf /home/arsham/.kube/config
chown arsham:arsham /home/arsham/.kube/config
@arsham
arsham / kubernetes_weave.md
Created January 16, 2019 16:09
Install #weave #scope in #kubernetes

Install

kubectl apply -f "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '\n')&env.IPALLOC_RANGE=10.4.0.0/16"
kubectl apply -f "https://cloud.weave.works/k8s/scope.yaml?k8s-service-type=NodePort&k8s-version=$(kubectl version | base64 | tr -d '\n')"

Access

kubectl port-forward -n weave "$(kubectl get -n weave pod --selector=weave-scope-component=app -o jsonpath='{.items..metadata.name}')" 4040