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 / gist:1db3130cb78ca61937a244e5a7d30876
Created March 5, 2020 17:21
Alias for etcdctl API v3 with certs all bundled in
alias ec='ETCDCTL_API=3 etcdctl --cacert=/etc/kubernetes/pki/etcd/ca.crt --cert=/etc/kubernetes/pki/etcd/peer.crt --key=/etc/kubernetes/pki/etcd/peer.key'
@georgegoh
georgegoh / snmp-for-alertmanager.sh
Created December 20, 2019 08:23
One-liner for spinning up snmp-notifer in kube for alertmanager
kubectl run snmp-notifier --image=docker.io/maxwo/snmp-notifier \
--port=9464 --expose \
--env="SNMP_DESTINATION=127.0.0.1:162" \
--env="SNMP_DESCRIPTION_TEMPLATE=/etc/snmp_notifier/description-template.tpl" \
-- '--snmp.trap-description-template=$(SNMP_DESCRIPTION_TEMPLATE)' \
'--snmp.destination=$(SNMP_DESTINATION)'
@georgegoh
georgegoh / get_running_images.sh
Created December 3, 2019 04:40
Get a list of all images currently running as pods
oc get pods -o=go-template --template='{{range .items}}{{if eq .status.phase "Running"}}{{range .status.containerStatuses}}{{.imageID}}{{printf "\n"}}{{end}}{{end}}{{end}}'
@georgegoh
georgegoh / reset_imagestreams.sh
Created September 25, 2019 04:25
Reset OpenShift image streams
export USERNAME=
export TOKEN=
oc get is -o yaml -n openshift > original-is.yaml
oc create secret -n openshift docker-registry rh-registry \
--docker-username=${USERNAME} \
--docker-password=${TOKEN} \
--docker-server=registry.redhat.io
oc create -f /usr/share/ansible/openshift-ansible/roles/openshift_examples/files/examples/x86_64/image-streams/image-streams-rhel7.json -n openshift
oc create -f /usr/share/ansible/openshift-ansible/roles/openshift_examples/files/examples/x86_64/image-streams/dotnet_imagestreams.json -n openshift
oc create -f /usr/share/ansible/openshift-ansible/roles/openshift_examples/files/examples/x86_64/xpaas-streams -n openshift
#!/bin/sh
######## MODIFY THE FOLLOWING TO SUIT YOUR TESTS ####################
export MAX_SVC=3
export POD_PORT=9376
export IMAGE=gcr.io/google_containers/serve_hostname:1.3
################# NO MODIFICATION AFTER THIS LINE ###################
# TO DELETE RESOURCES CREATED BY THIS SCRIPT, RUN:
apiVersion: v1
kind: Service
metadata:
name: hostnames
spec:
type: NodePort
ports:
- port: 9376
protocol: TCP
nodePort: 31111
@georgegoh
georgegoh / gist:890d14baea7c5bd376d819ef6d3fb4a7
Created September 5, 2019 16:31
Check validity dates of the SSL connection
echo | openssl s_client -connect <HOST>:<PORT> 2>/dev/null | openssl x509 -noout -dates
@georgegoh
georgegoh / images.311
Last active September 4, 2019 07:29
Images used for disconnected installation of OpenShift 3.11. This list is used as input to https://gist.github.com/georgegoh/98097f1f7ee1f528fc435fbd209299c6
openshift3/apb-base
openshift3/apb-tools
openshift3/automation-broker-apb
openshift3/csi-attacher
openshift3/csi-driver-registrar
openshift3/csi-livenessprobe
openshift3/csi-provisioner
openshift3/grafana
openshift3/local-storage-provisioner
openshift3/manila-provisioner
@georgegoh
georgegoh / satellite_sync_openshift_images.sh
Last active September 4, 2019 07:29
Create a product in Satellite called "Red Hat OpenShift Containers" to use for disconnected installs of OpenShift 3.x. Sample input file at https://gist.github.com/georgegoh/9337263245aa9ab413aa7ba6378fe736
#!/bin/bash
#
# script usage: satellite_sync_openshift_images.sh <-o ORGANIZATION> <-u RH_REGISTRY_USERNAME> <-p RH_REGISTRY_PASSWORD> <IMAGEFILE>
#
# Instructions to get credentials can be found here: https://access.redhat.com/articles/3399531
#
# Example:
# ./satellite_sync_openshift_images.sh -o rhconsulting -u 'abcdefg|id' -p 'dcsdj....jsndcsod' images.311
#
ldapsearch -x -H "ldap://<ldaphost>" -b "cn=groups,cn=accounts,dc=xxx,dc=internal - basedn" -D "uid=ocp.app,cn=users,cn=accounts,dc=xxx,dc=internal -w password -s sub "(objectclass=posixgroup)"