Created
August 29, 2025 22:07
-
-
Save chadmcrowell/bdab50783c95601945526dfffb1b78c1 to your computer and use it in GitHub Desktop.
ingress to target one pod
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 1) Add a unique label to the target pod | |
kubectl -n "$NS" label pod "$POD" singled=true --overwrite | |
# 2) Service that selects only that pod | |
cat <<'YAML' | envsubst | kubectl apply -f - | |
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: web-single | |
namespace: ${NS} | |
spec: | |
selector: | |
app: web | |
singled: "true" | |
ports: | |
- port: 80 | |
targetPort: 8080 | |
YAML | |
# 3) Ingress host that points to that one-pod Service | |
cat <<'YAML' | envsubst | kubectl apply -f - | |
apiVersion: networking.k8s.io/v1 | |
kind: Ingress | |
metadata: | |
name: web-single | |
namespace: ${NS} | |
spec: | |
ingressClassName: nginx | |
rules: | |
- host: ${POD}.${NS}.app.${LB_IP}.sslip.io | |
http: | |
paths: | |
- path: / | |
pathType: Prefix | |
backend: | |
service: | |
name: web-single | |
port: | |
number: 80 | |
YAML | |
# 4) Call that specific pod via Ingress | |
curl -sS "http://${POD}.${NS}.app.${LB_IP}.sslip.io/hostname" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment