Skip to content

Instantly share code, notes, and snippets.

View stewartshea's full-sized avatar

Shea Stewart stewartshea

View GitHub Profile
@stewartshea
stewartshea / cancel-pulp-tasks.sh
Created August 14, 2017 14:21 — forked from snobear/cancel-pulp-tasks.sh
script to cancel all pulp tasks
#!/bin/bash
#
# Cancel all pulp tasks that are just in a specifiedstate
tmpfile=/tmp/tasks
read -p "Enter task state to kill, e.g. Waiting: " ans
echo ""
if [ "${#ans}" -gt 0 ]
then
@stewartshea
stewartshea / gist:0178c1f473ef1a205c6d2f3ccbaf5888
Created August 31, 2017 19:55
OpenShift oneliner to update all image streams
for x in $(oc get is -n openshift | awk 'NR>1 {print $1}'); do oc import-image $x; done
{"id":"59d1342e4a44ebbcc872e7e0","name":"Test Sheets Import","desc":"","descData":null,"closed":false,"idOrganization":"56a6de8804bc53cf596edb52","invited":false,"limits":{"boards":{"totalMembersPerBoard":{"status":"ok","disableAt":1520,"warnAt":1440}},"cards":{"openPerBoard":{"status":"ok","disableAt":4750,"warnAt":4500},"totalPerBoard":{"status":"ok","disableAt":1900000,"warnAt":1800000}},"checklists":{"perBoard":{"status":"ok","disableAt":15200,"warnAt":14400}},"labels":{"perBoard":{"status":"ok","disableAt":950,"warnAt":900}},"lists":{"openPerBoard":{"status":"ok","disableAt":475,"warnAt":450},"totalPerBoard":{"status":"ok","disableAt":2850,"warnAt":2700}}},"pinned":false,"starred":false,"url":"https://trello.com/b/WYOGQ9Bp/test-sheets-import","prefs":{"permissionLevel":"org","voting":"disabled","comments":"members","invitations":"members","selfJoin":true,"cardCovers":true,"cardAging":"regular","calendarFeedEnabled":false,"background":"59ce9baf279fa0f192701637","backgroundImage":"https://trello-background
@stewartshea
stewartshea / microservicepolicies.txt
Last active October 12, 2019 15:10
aporeto-microservice-policies
$ cat restrict-microservices-all.yml
APIVersion: 0
data:
networkaccesspolicies:
- action: Reject
logsEnabled: true
fallback: true
name: reject-microservice-fallback
object:
- - $namespace=/aporeto/gigaom/mct/gcp/*
$ cat isolate-default-k8s-ns.yml
APIVersion: 0
data:
networkaccesspolicies:
- action: Reject
logsEnabled: true
fallback: true
name: isolate-default-namespace
object:
- - "@app:k8s:namespace=default"
@stewartshea
stewartshea / troubleshooting_pending_pods_in_namespace.txt
Last active July 14, 2023 18:38
Troubleshoot Pending Pods in Namespace
kubectl get pods --context=${CONTEXT} -n ${NAMESPACE} --field-selector=status.phase=Pending --no-headers -o json | jq -r '.items[] | "---\npod_name: \(.metadata.name)\nstatus: \(.status.phase // "N/A")\nmessage: \(.status.conditions[].message // "N/A")\nreason: \(.status.conditions[].reason // "N/A")\ncontainerStatus: \((.status.containerStatuses // [{}])[].state // "N/A")\ncontainerMessage: \((.status.containerStatuses // [{}])[].state?.waiting?.message // "N/A")\ncontainerReason: \((.status.containerStatuses // [{}])[].state?.waiting?.reason // "N/A")\n---\n"'
@stewartshea
stewartshea / troubleshoot_unready_kustomizations_with_fluxcd.txt
Last active July 18, 2023 11:54
Troubleshoot Unready Kustomizations with FluxCD
kubectl get Kustomization.kustomize.toolkit.fluxcd.io -n ${NAMESPACE} --context ${CONTEXT} -o json | jq -r '.items[] | select (.status.conditions[] | select(.type == "Ready" and .status == "False")) | "---\nKustomization Name: \(.metadata.name)\n\nReady Status: \(.status.conditions[] | select(.type == "Ready") | "\n ready: \(.status)\n message: \(.message)\n reason: \(.reason)\n last_transition_time: \(.lastTransitionTime)")\n\nReconcile Status:\(.status.conditions[] | select(.type == "Reconciling") |"\n reconciling: \(.status)\n message: \(.message)")\n---\n"'
@stewartshea
stewartshea / find_failed_certificate_requests_and_identify_issues.txt
Last active July 6, 2023 20:16
Find Failed Certificate Requests and Identify Issues
kubectl get certificaterequests.cert-manager.io --context=${CONTEXT} -n ${NAMESPACE} -o json | jq -r '.items[] | select(.status.conditions[] | select(.type == "Ready" and .status != "True")) | {certRequest: .metadata.name, certificate: (.metadata.ownerReferences[].name), issuer: .spec.issuerRef.name, readyStatus: (.status.conditions[] | select(.type == "Ready")).status, readyMessage: (.status.conditions[] | select(.type == "Ready")).message, approvedStatus: (.status.conditions[] | select(.type == "Approved")).status, approvedMessage: (.status.conditions[] | select(.type == "Approved")).message} | "---\nCertificateRequest: \(.certRequest)", "Certificate: \(.certificate)", "Issuer: \(.issuer)", "Ready Status: \(.readyStatus)", "Ready Message: \(.readyMessage)", "Approved Status: \(.approvedStatus)", "Approved Message: \(.approvedMessage)"'
@stewartshea
stewartshea / fetch_ingress_object_health_in_namespace.txt
Created July 6, 2023 20:19
Fetch Ingress Object Health in Namespace
namespace="${NAMESPACE}"; context="${CONTEXT}"; for ingress in $(kubectl get ingress -n "$namespace" --context "$context" -ojsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}'); do echo "Ingress: $ingress"; health_status="NA"; services=(); backend_services=$(kubectl get ingress "$ingress" -n "$namespace" --context "$context" -ojsonpath='{range .spec.rules[*].http.paths[*]}{.backend.service.name}{"|"}{.backend.service.port.number}{"\n"}{end}'); while IFS='|' read -r service port; do if [ -n "$service" ] && [ -n "$port" ]; then echo "Backend Service: $service, Port: $port"; service_exists=$(kubectl get service "$service" -n "$namespace" --context "$context" -ojsonpath='{.metadata.name}'); if [ -z "$service_exists" ]; then health_status="Unhealthy"; echo "Validation: Service $service does not exist"; else endpoint_pods=$(kubectl get endpoints "$service" -n "$namespace" --context "$context" -ojsonpath='{range .subsets[*].addresses[*]}- Pod Name: {.targetRef.name}\n Pod IP: {.ip}\n{end}'); if [ -z "$endpoint_p
@stewartshea
stewartshea / list_images_and_tags_for_every_container_in_running_pods.txt
Last active July 7, 2023 19:38
List Images and Tags for Every Container in Running Pods
kubectl get pods --context=${CONTEXT} -n ${NAMESPACE} --field-selector=status.phase==Running -o=json | jq -r '.items[] | "---", "pod_name: " + .metadata.name, "Status: " + .status.phase, "containers:", (.spec.containers[] | "- container_name: " + .name, " image_path: " + (.image | split(":")[0]), " image_tag: " + (.image | split(":")[1])), "---"'