Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

support lookups for pod names #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
erikdw merged 1 commit into main from erikdw/support-looking-up-pod-names
Sep 24, 2025
Merged

Conversation

@erikdw
Copy link
Contributor

@erikdw erikdw commented Sep 24, 2025
edited
Loading

Description

Allows invocations like:

kubectl curl http://deployment/<deployment-name>

Instead of requiring

kubectl curl http://<pod-name>

With the latter format, you have to manually look up the pod name first.

Supported workload resources:

  • deployment (abbreviation: deploy)
  • statefulset (abbreviation: sts)
  • daemonset (abbreviation: ds)

Logic Wildness Note

I used ChatGPT to craft the logic -- having it deal with the non-standard URL format where we have a / in the middle of the "hostname" is what makes it hairy. But I feel this is cleaner and easier to remember than if we took an extra CLI argument to distinguish which type of resource controller we are interrogating. (e.g., --resource deployment).

Note

I think we can adapt the logic to also aggressively search for resource names under each resource controller.

e.g., for curl http://foobar we could first see if foobar is a pod, and if not we see if it's one of the supported resource controllers in this preference (preferring common app-level resource controller of deployment, then less commonly statefulset, and very rarely daemonset).

  1. deployment
  2. statefulset
  3. daemonset

Won't implement that in this PR though.

Usage examples

Previous requirement:

% kubectl curl -i -n ctlstore http://ctlstore-executive-shadow-568cd76f89-ggc2f:3000/status
HTTP/1.1 200 OK
Date: 2025年9月24日 20:16:09 GMT
Content-Length: 0
% kubectl curl -i -n ctlstore ctlstore-executive-shadow-568cd76f89-ggc2f:3000/status
HTTP/1.1 200 OK
Date: 2025年9月24日 20:16:09 GMT
Content-Length: 0

Newly supported variations:

% kubectl curl -i -n ctlstore http://deploy/ctlstore-executive-shadow:3000/status
HTTP/1.1 200 OK
Date: 2025年9月24日 20:56:40 GMT
Content-Length: 0
% kubectl curl -i -n ctlstore deploy/ctlstore-executive-shadow:3000/status
HTTP/1.1 200 OK
Date: 2025年9月24日 20:16:35 GMT
Content-Length: 0

Testing

Firstly, added unit tests.
Tested locally, see above examples. Also tested with daemonset and statefulset:

% kubectl curl -n ctlstore ds/ctlstore-reflector-v2:9090
404 page not found
% kubectl curl -n ctlstore http://ds/ctlstore-reflector-v2:9090
404 page not found
% kubectl curl -n argus sts/api-events-mirror:3000
404 page not found
% kubectl curl -n argus http://sts/api-events-mirror:3000
404 page not found

mattcockrell reacted with thumbs up emoji
## Description
Allows invocations like:
`kubectl curl http://deployment/<deployment-name>`
Instead of requiring
`kubectl curl http://<pod-name>`
With the latter format, you have to manually look up the pod name first.
Supported workload resources:
* `deployment` (abbreviation: `deploy`)
* `statefulset` (abbreviation: `sts`)
* `daemonset` (abbreviation: `ds`)
### Usage examples
Previous requirement:
```
% kubectl curl -i -n ctlstore http://ctlstore-executive-shadow-568cd76f89-ggc2f:3000/status
HTTP/1.1 200 OK
Date: 2025年9月24日 20:16:09 GMT
Content-Length: 0
% kubectl curl -i -n ctlstore ctlstore-executive-shadow-568cd76f89-ggc2f:3000/status
HTTP/1.1 200 OK
Date: 2025年9月24日 20:16:09 GMT
Content-Length: 0
```
Newly supported variations:
```
% kubectl curl -i -n ctlstore http://deploy/ctlstore-executive-shadow:3000/status
HTTP/1.1 200 OK
Date: 2025年9月24日 20:56:40 GMT
Content-Length: 0
% kubectl curl -i -n ctlstore deploy/ctlstore-executive-shadow:3000/status
HTTP/1.1 200 OK
Date: 2025年9月24日 20:16:35 GMT
Content-Length: 0
```
@erikdw erikdw merged commit c438fa7 into main Sep 24, 2025
3 checks passed
@erikdw erikdw deleted the erikdw/support-looking-up-pod-names branch September 24, 2025 21:51
erikdw added a commit that referenced this pull request Sep 24, 2025
Clarify URL host part options for kubectl curl command.
Follow-up to #16 which
failed to update the docs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@zhou-hongyu zhou-hongyu zhou-hongyu approved these changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /