Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Paste
P85080
(An Untitled Masterwork)
Active
Public
Actions
Authored by
taavi
on Nov 7 2025, 11:58 AM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Project Tags
None
Referenced Files
F69998276: raw-paste-data.txt
Nov 7 2025, 11:58 AM
2025-11-07 11:58:24 (UTC+0)
Subscribers
None
#!/usr/bin/env python3
import
yaml
import
subprocess
def
cmd_run
(
cmd
:
str
):
r
=
subprocess
.
run
(
cmd
,
capture_output
=
True
,
shell
=
True
)
return
r
.
returncode
,
r
.
stdout
.
decode
(
"utf-8"
),
r
.
stderr
.
decode
(
"utf-8"
)
def
ingress_has_nginx_annotations
(
ingress
:
dict
):
for
annotation
,
value
in
ingress
.
get
(
"metadata"
)
.
get
(
"annotations"
,
{})
.
items
():
if
(
annotation
.
startswith
(
"nginx.ingress.kubernetes.io/"
)
and
"$"
in
value
and
annotation
!=
"nginx.ingress.kubernetes.io/rewrite-target"
):
return
True
return
False
def
print_ingress_info
(
ingress
:
dict
):
ns
=
ingress
.
get
(
"metadata"
)
.
get
(
"namespace"
)
name
=
ingress
.
get
(
"metadata"
)
.
get
(
"name"
)
annotations
=
ingress
.
get
(
"metadata"
)
.
get
(
"annotations"
)
annotations
.
pop
(
"kubectl.kubernetes.io/last-applied-configuration"
,
None
)
print
(
f
"
\n
* {ns}/{name}:
\n
"
)
print
(
"```lang=yaml"
)
for
name
,
value
in
annotations
.
items
():
if
name
.
startswith
(
"nginx.ingress.kubernetes.io/"
):
print
(
f
"{name}: {value}"
)
print
(
"```"
)
def
main
():
ret
,
dump
,
err
=
cmd_run
(
"kubectl get ingress --all-namespaces -o yaml"
)
if
ret
!=
0
:
print
(
f
"ERROR: something went wrong
\n
{err}"
)
list
=
yaml
.
safe_load
(
dump
)
for
ingress
in
list
.
get
(
"items"
):
if
ingress_has_nginx_annotations
(
ingress
):
print_ingress_info
(
ingress
)
if
__name__
==
"__main__"
:
main
()
Event Timeline
taavi
created this paste.
Nov 7 2025, 11:58 AM
2025-11-07 11:58:24 (UTC+0)
taavi
mentioned this in
T409474: Reduce tool breakage over new ingress-nginx annotation validation rules
.
Log In to Comment