kubectl port-forward allows using resource name, such as a pod name, to select a matching pod to port forward to.
別解は確かに適当なpodを立ち上げてからのcurl
kubectl run test-pod --image nginx -- /bin/sh -c 'curl <target_pod's_ip_address>'
role的にはget list createがpods/portforwardに必要らしい
--- kind: Role apiVersion: rbac.authorization.k8s.io/v1 metadata: namespace: my-namespace name: allow-port-forward rules: - apiGroups: [""] resources: ["pods", "pods/portforward"] verbs: ["get", "list", "create"]