Skip to content

Instantly share code, notes, and snippets.

View 4nn0's full-sized avatar
:octocat:

Andreas Nowak 4nn0

:octocat:
  • Red Hat
  • Rhyfälde AG
View GitHub Profile
@4nn0
4nn0 / kubernetes-openshift.md
Last active November 23, 2021 15:10
Openshift / Kubernetes

Description

Some example commands for openshift/kubernetes, replace the oc with kubectl or otherwise

get all pods from all namespaces comma separated with namespace, pod name, container name, container image, pod status

oc get pods --all-namespaces -o go-template='{{range .items}}{{$status := .status.phase}}{{$namespace := .metadata.namespace}}{{$podname := .metadata.name}}{{range .spec.containers}}{{$namespace}}{{","}}{{$podname}}{{","}}{{.name}}{{","}}{{.image}}{{","}}{{$status}}{{"\n"}}{{end}}{{end}}'

get all pods from all namespaces comma separated with namespace, pod name, scc

oc get pods --all-namespaces -o go-template='{{range .items}}{{.metadata.namespace}},{{.metadata.name}},{{range $key, $element := .metadata.annotations}}{{if eq $key "openshift.io/scc"}}{{$element}}{{end}}{{end}}{{"\n"}}{{end}}'

get all sccs with attrubite .allowPrivilegedContainer true