Skip to content

Instantly share code, notes, and snippets.

View georgegoh's full-sized avatar

George Goh georgegoh

  • OCBC Group
  • Singapore
View GitHub Profile
@georgegoh
georgegoh / snapshot_es_cluster.sh
Created November 14, 2017 03:50
Snapshot all open and started indices in the ES cluster
oc rsh `oc get po -l component=es --show-labels -o name|head -n 1` \
curl --cacert /etc/elasticsearch/secret/admin-ca \
--cert /etc/elasticsearch/secret/admin-cert \
--key /etc/elasticsearch/secret/admin-key \
-XPUT 'https://logging-es:9200/_snapshot/log_backup/snapshot_20171114_1?wait_for_completion=true'
@georgegoh
georgegoh / extract_admin_certs.sh
Last active October 2, 2018 06:33
Extract the admin certs from an ES pod.
#!/bin/sh
for secret in admin-ca admin-cert admin-key
do
oc rsh `oc get po -l component=es -o jsonpath='{.items[0].metadata.name}'` \
cat /etc/elasticsearch/secret/$secret > $secret
done
@georgegoh
georgegoh / setup_es_snapshot.yaml
Last active November 22, 2017 02:40
Playbook to set up snapshot hostpath for ES
---
- hosts: 127.0.0.1
connection: local
tasks:
- name: get Elasticsearch DCs
command: oc get dc -l component=es -o name
register: es_components
- name: pause rollout while patching DC
@georgegoh
georgegoh / es_snapshot.sh
Last active October 2, 2018 06:32
Snapshot the entire ES cluster
#!/bin/sh
oc rsh `oc get po -l component=es -o jsonpath='{.items[0].metadata.name}'` \
curl -s -XPUT 'http://logging-es:9200/_snapshot/log_backup?pretty' -H 'Content-Type: application/json' -d'
{
"type": "fs",
"settings": {
"location": "/elasticsearch/snapshots",
"compress": true
}
@georgegoh
georgegoh / hosts.yaml
Created January 2, 2018 09:18
Lab setup
OSEv3:
children:
masters:
hosts:
ocp-master.int.spodon.com
etcd:
hosts:
ocp-master.int.spodon.com
nodes:
hosts:
@georgegoh
georgegoh / gist:7ea05811e8cd2a7f4c3069071da16be6
Created March 29, 2018 02:09
Reuse router wildcard cert when deploying kubernetes dashboard
 oc get secret router-certs -o json -n default | jq '.metadata={name:"kubernetes-dashboard-certs", namespace:"kube-system"}' | oc create -f -
apiVersion: v1
kind: Template
metadata:
name: hello-openshift-template
annotations:
openshift.io/display-name: "Hello OpenShift Demo Template"
description: "This is an example template used to demonstrate templating."
author: "George Goh <george.goh@redhat.com>"
tags: ""
iconClass: "icon-apache"
@georgegoh
georgegoh / gist:5dccdde60a09fc5500b6f18f50b6d4d8
Created May 26, 2018 23:40
Just see subject and x509v3 extensions
openssl x509 -noout -text -certopt ca_default,no_sigdump,no_serial,no_validity -in <name>
@georgegoh
georgegoh / get_efk_pv.sh
Last active October 2, 2018 05:46
Print the details of the PVCs attached to the Elasticsearch pods in OpenShift's EFK stack.
#!/bin/sh
ES_VOLS=`oc get pvc -l logging-infra=support -n openshift-logging -o jsonpath='{range .items[*]}{.spec.volumeName}{"\n"}'`
for pv in $ES_VOLS
do
oc get pv $pv -o jsonpath='{.spec.claimRef.name}{"\t"}{.spec.iscsi.portals}{"\t"}{.spec.iscsi.iqn}{"\n"}'
done
@georgegoh
georgegoh / show_glusterblock_devs.sh
Created October 2, 2018 05:45
Print all the gluster-block devices in OpenShift's OCS storage subsystem
#!/bin/sh
GLUSTER_PODS=`oc get po -l glusterfs=storage-pod -n app-storage -o name`
for pod in $GLUSTER_PODS
do
echo $pod
oc -n app-storage rsh $pod targetcli ls iscsi 1
done