Skip to content

Instantly share code, notes, and snippets.

@luckylittle
Last active April 4, 2024 01:49
Show Gist options
  • Save luckylittle/b11595a568a736c67a318c5747e06491 to your computer and use it in GitHub Desktop.
Save luckylittle/b11595a568a736c67a318c5747e06491 to your computer and use it in GitHub Desktop.
Clean up unnecessary metadata from Openshift YAML files
# wget https://github.com/itaysk/kubectl-neat/releases/download/v2.0.3/kubectl-neat_linux_amd64.tar.gz
# tar xvzf kubectl-neat_linux_amd64.tar.gz
# sudo mv -v kubectl-neat /usr/local/bin/
cat << EOF | oc neat [2024-04-04 | 12:46:23]
apiVersion: v1
kind: Pod
metadata:
annotations:
openshift.io/scc: anyuid
creationTimestamp: 2016-10-20T18:28:55Z
labels:
name: hello-openshift
name: hello-openshift
namespace: default
resourceVersion: "413"
selfLink: /api/v1/namespaces/default/pods/hello-openshift
uid: 0ed4ee24-96f3-11e6-ad77-54ee752009cb
spec:
containers:
- image: openshift/hello-openshift
imagePullPolicy: IfNotPresent
name: hello-openshift
ports:
- containerPort: 8080
protocol: TCP
resources: {}
securityContext:
capabilities:
drop:
- MKNOD
- SYS_CHROOT
privileged: false
seLinuxOptions:
level: s0:c5,c0
terminationMessagePath: /dev/termination-log
volumeMounts:
- mountPath: /tmp
name: tmp
- mountPath: /var/run/secrets/kubernetes.io/serviceaccount
name: default-token-1hvg5
readOnly: true
dnsPolicy: ClusterFirst
imagePullSecrets:
- name: default-dockercfg-cctwt
nodeName: localhost.localdomain
restartPolicy: Always
securityContext:
seLinuxOptions:
level: s0:c5,c0
serviceAccount: default
serviceAccountName: default
terminationGracePeriodSeconds: 30
volumes:
- emptyDir: {}
name: tmp
- name: default-token-1hvg5
secret:
defaultMode: 420
secretName: default-token-1hvg5
status:
conditions:
- lastProbeTime: null
lastTransitionTime: 2016-10-20T18:28:55Z
status: "True"
type: Initialized
- lastProbeTime: null
lastTransitionTime: 2016-10-20T18:28:57Z
status: "True"
type: Ready
- lastProbeTime: null
lastTransitionTime: 2016-10-20T18:28:55Z
status: "True"
type: PodScheduled
containerStatuses:
- containerID: docker://4fd3a99dd6ed5b4a6df19e6fbb86e4725729e1db4078883eb264ad4858014342
image: openshift/hello-openshift
imageID: docker://sha256:35e913b1a7107b1ccec2ddd5cb04e52de04f14b86384e4665aa4f0dc40cfee2f
lastState: {}
name: hello-openshift
ready: true
restartCount: 0
state:
running:
startedAt: 2016-10-20T18:28:56Z
hostIP: 192.168.1.104
phase: Running
podIP: 172.17.0.2
startTime: 2016-10-20T18:28:55Z
EOF
# It cleans it up to look like:
# apiVersion: v1
# kind: Pod
# metadata:
# labels:
# name: myapp
# name: myapp
# namespace: default
# spec:
# containers:
# - image: nginx
# name: myapp
# ports:
# - containerPort: 1234
# priority: 0
# serviceAccountName: default
# tolerations:
# - effect: NoExecute
# key: node.kubernetes.io/not-ready
# operator: Exists
# tolerationSeconds: 300
# - effect: NoExecute
# key: node.kubernetes.io/unreachable
# operator: Exists
# tolerationSeconds: 300
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment