Skip to content

Instantly share code, notes, and snippets.

@jovemfelix
Last active September 21, 2022 12:24
Show Gist options
  • Save jovemfelix/664fe1c603d7d3277277cdd75425ee46 to your computer and use it in GitHub Desktop.
Save jovemfelix/664fe1c603d7d3277277cdd75425ee46 to your computer and use it in GitHub Desktop.
Usefull for debugging

Running Pod with utilities

cat <<EOF | oc apply -f -
---
apiVersion: v1
kind: Pod
metadata:
  name: curl-pod
  labels:
    app: support
spec:
  containers:
    - name: curl-pod
      image: 'registry.redhat.io/rhel8/support-tools'
      command:
        - "/usr/bin/bash"
        - "-c"
        - "while true; do sleep 3600; done"
EOF

Using the curl-pod

here it's using local jq utility

$ oc exec curl-pod -n my-curl-pod-namespace \
  -- curl -s \
 "http://svc-name.namespace-name.svc.cluster.local/api/v2/books" | jq

Tip to get Service Full Qualified Name Resolutions

Every Pod is assigned a DNS name: pod-ip.namespace-name.pod.cluster.local Every Service is assigned a DNS name: svc-name.namespace-name.svc.cluster.local

$ oc rsh pod-xxx
$ cat /etc/resolv.conf

Example of sosreport help

here it's an example of using an internal commmand with more parameters

$ oc exec curl-pod -n my-curl-pod-namespace \
  -- bash -c 'sosreport -h'

Reference

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment