k8s使用curl访问api资源

正常访问api需要token

curl `kubectl config view  --minify |grep server |cut -f2- -d":" |tr -d " "`/api/v1 --header "Authorization: Bearer `kubectl describe secrets $(kubectl get secrets |grep ^default |cut -f1 -d" ") |grep -E '^token'|cut -d":" -f2 |tr -d " "`"  --insecure

使用kubectl proxy后,不用token

kubectl proxy --port=8080
kubectl proxy --address='0.0.0.0'  --accept-hosts='^*$' --port=8080
curl http://localhost:8080/api
curl -X GET -L http://k8s-master:8080/

创建service资源

kubectl create deploy nginx --image=nginx:latest --port=80 --replicas=3
kubectl expose deploy nginx --name=svc-nginx1 --type=ClusterIP --port=80 --target-port=80
curl http://k8s-master:8080/api/v1/namespaces/default/services/svc-nginx1
posted @   小糊涂90  阅读(158)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
历史上的今天:
2021-10-16 网卡绑定bond0的实现
点击右上角即可分享
微信分享提示