Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
mask() {
local n=8 # number of chars to leave
local a="${1:0:${#1}-n}" # take all but the last n chars
local b="${1:${#1}-n}" # take the final n chars
printf "%s%s\n" "${a//?/*}" "$b" # substitute a with asterisks
}
#!/bin/bash
#
# use this script to force the certiifcate renew for the default ingress certificate of a hcp.
#
function convert() {
echo $(date -d "$1" "+%s")
}
function dlog() {
echo $(date -u +"%Y-%m-%d-%I:%M:%S") $1
}
#!/bin/bash
node=${1}
list=$(oc get hc -A --sort-by=.metadata.creationTimestamp -ojson \
| jq -r '.items[] | select(.metadata.name | contains("sdq")) | .metadata.name,.metadata.creationTimestamp,.metadata.namespace')
ma=($list)
for ((i=0;i<${#ma[@]};i+=3))
do
#!/bin/bash
oc patch mch multiclusterhub -n multicluster-hub --type=merge \
-p "{\"spec\":{\"overrides\":{\"components\":[{\"name\":\"cluster-backup\",\"enabled\":true}]}}}"
oc patch mce multiclusterengine -n multicluster-engine --type=merge \
-p "{\"spec\":{\"overrides\":{\"components\":[{\"name\":\"managedserviceaccount-preview\",\"enabled\":true}]}}}"
BACKUP_NS=openshift-velero
SECRET_NAME=velero-iam-credentials
@cdoan1
cdoan1 / rotate-certificate.sh
Created March 16, 2023 15:09
Roate Certificate
#!/bin/bash
function convert() {
echo $(date -d "$1" "+%s")
}
function dlog() {
echo $(date -u +"%Y-%m-%d-%I:%M:%S") $1
}
for certificate in $(oc get certificate -n default -o name)
+-----------------------+                  +-------------------+            +-------------------+       +--------------------+
|                       |                  |                   |            |                   |       |                    |
|                       |                  |                   |            |                   |       |                    |
|                       |                  |                   |            |                   |       |                    |
|                       |                  |                   |            |                   |       |                    |
|      Managed Cluster  --------------------      BIG IP       --------------       API         --------|         HUB        |
|                       |                  |      WAF          |            |       Gateway     |       |                    |
|                       |                  |                   |            |                   |       |                    |
# get CRD sorted
oc get crd -A --sort-by=.metadata.creationTimestamp
# inline template
oc get route keycloak --template "http://{{.spec.host}} "
# Enable DEX
@cdoan1
cdoan1 / monitor.sh
Created July 8, 2021 01:10
Monitor Proxy Settings
#!/bin/bash
oc get deployment \
| grep -v "NAME" \
| awk '{print $1}' \
| xargs -I % sh -c 'echo %; oc get deployment % -o yaml | grep "sre-registry"'
oc get deployment \
| grep -v "NAME" \
| awk '{print $1}' \
@cdoan1
cdoan1 / snippet1.yaml
Last active June 25, 2021 19:01
ClusterPools
imageContentSources:
- mirrors:
- quay.io:443/acm-d
source: registry.redhat.io/rhacm2
- mirrors:
- registry.redhat.io/openshift4/ose-oauth-proxy
source: registry.access.redhat.com/openshift4/ose-oauth-proxy
@cdoan1
cdoan1 / example-rate.py
Created June 21, 2021 20:30
rate calculation
def delta_sn(a, b):
d1 = datetime.strptime(a, '%Y-%m-%dT%H:%M:%SZ')
d2 = datetime.strptime(b, '%Y-%m-%dT%H:%M:%SZ')
diff = (d2 - d1).total_seconds() / 60
return round(diff, 1)
def calculate_rate(attribute_name):
a0 = ds8[(ds8[attribute_name] > 0)]
a0_max = ds8[(ds8[attribute_name] == ds8[attribute_name].max())]