Skip to content

Instantly share code, notes, and snippets.

@jeesmon
jeesmon / copy-kube-secret
Created October 28, 2021 18:26
Copy and apply kubernetes Secret from one namespace to another
kubectl get secret <name> -n <namespace> -o json \
| jq '.metadata.name="<new_name>"|.metadata.namespace="<new_namespace>"' \
| kubectl apply -f -
@jeesmon
jeesmon / find-ownerreferences.sh
Created September 30, 2021 19:41
Find ownerReferences of pods in OpenShift cluster
oc get po -A -o wide | grep {filter} | while read a b c;
do
r=$(echo -n $a $b; oc get po -n $a $b -o jsonpath='{range .metadata.ownerReferences[*]} {.kind} {.name}{"\n"}{end}');
echo $r;
if [[ $r == *"ReplicaSet"* ]];
then echo $r | while read a b c d;
do
oc get rs -n $a $d -o jsonpath='{range .metadata.ownerReferences[*]} {.kind} {.name}{"\n"}{end}';
done;
fi;
@jeesmon
jeesmon / openshift-sm-additional-ingress-gateway.md
Last active September 11, 2021 13:20
OpenShift ServiceMesh Additional Ingress Gateway

Steps

  • Edit ServiceMesh Controlplane (SMCP) default
spec:
....
  gateways:
    additionalIngress:
      istio-internal-ingressgateway:
@jeesmon
jeesmon / pod-exec
Created May 27, 2021 18:15
Kubernetes Pod Exec using curl
curl -k \
--http1.1 \
-H "Sec-WebSocket-Key: SGVsbG8sIHdvcmxkIQ==" \
-H "Sec-WebSocket-Version: 13" \
-i \
-N \
-H "Connection: Upgrade" \
-H "Upgrade: websocket" \
-H 'Authorization: Bearer <TOKEN>' \
"<API_SERVER>/api/v1/namespaces/<namespace>/pods/<pod_name>/exec?command=ls&command=-l&stdin=true&stdout=true&stderr=true"