Skip to content

Instantly share code, notes, and snippets.

Avatar
🇹🇼
o p e n

Phil Huang pichuang

🇹🇼
o p e n
View GitHub Profile
View completion.sh
#!/bin/bash
helm completion bash > /etc/bash_completion.d/helm
kubectl completion bash > /etc/bash_completion.d/kubectl
octant completion bash > /etc/bash_completion.d/octant
tanzu completion bash > /etc/bash_completion.d/tanzu
k9s completion bash > /etc/bash_completion.d/k9s
@pichuang
pichuang / seccomp.json
Last active Jun 16, 2021
20210616 OCP4.6 CoreOS: cat /etc/crio/seccomp.json
View seccomp.json
{
"defaultAction":"SCMP_ACT_ERRNO",
"archMap":[
{
"architecture":"SCMP_ARCH_X86_64",
"subArchitectures":[
"SCMP_ARCH_X86",
"SCMP_ARCH_X32"
]
},
View shared-memory.yaml
---
apiVersion: v1
id: hello-openshift
kind: Pod
metadata:
name: hello-openshift
labels:
name: hello-openshift
spec:
volumes:
View Dockerfile-with-dnf
FROM registry.access.redhat.com/ubi8/ubi:8.3
RUN dnf -y install nginx && \
dnf -y clean all
View string.yml
PLAY [localhost] ***************************************************************
TASK [Test Case 1] *************************************************************
changed: [localhost]
TASK [debug] *******************************************************************
ok: [localhost] => {
"msg": "who is handsome man? smallplane"
}
View node-loadtesting.yml
---
apiVersion: batch/v1
kind: Job
metadata:
generateName: work-queue-
spec:
template:
spec:
containers:
- name: work
@pichuang
pichuang / restore_etcd.sh
Created Feb 19, 2021
OCP 4.6.8 ETCD Restore
View restore_etcd.sh
#!/bin/bash
BACKUP_DIR="~/etcd_backup/backup/backup.epq0825v"
master_nodes=(master0.dmz.ocp4.local master1.dmz.ocp4.local master2.dmz.ocp4.local)
cd $BACKUP
for node in "${master_nodes[@]}"
do
scp -i ~/.ssh/dmz-ocp4-rsa $BACKUP_DIR/* core@$node:~/
ssh -i ~/.ssh/dmz-ocp4-rsa core@$node sudo /usr/local/bin/cluster-restore.sh /home/core/
@pichuang
pichuang / graceful_shutdown_ocp.sh
Last active Feb 19, 2021
Shutdown OCP4.6 Gracefully
View graceful_shutdown_ocp.sh
#!/bin/bash
# Ref: https://docs.openshift.com/container-platform/4.6/backup_and_restore/graceful-cluster-shutdown.html
# !!!IMPORTANT!!!
# DO THE ETCD BACKUP FISRT
# https://gist.github.com/pichuang/53aef7091245c55a91a5f0bd56fa3256
non_master_nodes=$(oc get nodes --selector='!node-role.kubernetes.io/master' -o jsonpath='{.items[*].metadata.name}')
for node in ${non_master_nodes[@]}
View defrag_etcd.sh
#!/bin/bash
etcd_node=`oc get pods -n openshift-etcd -l app=etcd -o=jsonpath='{.items[0].spec.nodeName}'`
ssh -i ~/.ssh/dmz-ocp4-rsa core@$etcd_node
id=$(sudo crictl ps --name etcdctl | awk 'FNR==2{ print $1}') && sudo crictl exec -it $id /bin/bash
ETCDCTL_ENDPOINTS=$(etcdctl member list | awk -F', ' '{printf "%s%s",sep,$5; sep=","}')
rev=$(etcdctl endpoint status --write-out="json" | egrep -o '"revision":[0-9]*' | egrep -o '[0-9]*' -m1)
etcdctl compact $rev
unset ETCDCTL_ENDPOINTS
etcdctl --command-timeout=30s --endpoints=https://localhost:2379 defrag
@pichuang
pichuang / check_etcd.sh
Last active Feb 22, 2021
Check etcd status on OCP 4.6.1
View check_etcd.sh
#!/bin/bash
# Ref: https://docs.openshift.com/container-platform/4.6/backup_and_restore/backing-up-etcd.html
etcd_node=`oc get pods -n openshift-etcd -l app=etcd -o=jsonpath='{.items[0].spec.nodeName}'`
ssh -i ~/.ssh/dmz-ocp4-rsa core@$etcd_node
id=$(sudo crictl ps --name etcdctl | awk 'FNR==2{ print $1}') && sudo crictl exec -it $id /bin/bash
etcdctl member list -w table
etcdctl endpoint health --cluster