Dan*_*Dan 1 proxy kubernetes kubernetes-service
我正在尝试访问 clusterip 服务(通过 docker-for-mac 在我的笔记本电脑上运行 kubernetes)。
kubectl run curl --image=radial/busyboxplus:curl -i --tty
curl -v http://10.106.1.204:8000/api/v0.1/predictions -d '{"foo": "bar"}' -H "Content-Type: application/json"
Run Code Online (Sandbox Code Playgroud)
但我无法使用服务名称而不是 ip 使其工作。然后我尝试按照此处所述使用 kubectl 代理,但无法使其正常工作:
kubectl proxy --port=8080 &
curl -v http://127.0.0.1:8080/api/v1/proxy/namespaces/deploy-test/services/10.106.1.204:8000/api/v0.1/predictions
Run Code Online (Sandbox Code Playgroud)
这给了我 404 错误以及以下所有内容:
curl -v http://127.0.0.1:8080/api/v1/proxy/namespaces/deploy-test/services/10.106.1.204:8000
curl -v http://127.0.0.1:8080/api/v1/proxy/namespaces/deploy-test/services/10.106.1.204:8000/predictions
curl -v http://127.0.0.1:8080/api/v1/proxy/namespaces/deploy-test/services/10.106.1.204:8000/api/v0.1/predictions
Run Code Online (Sandbox Code Playgroud)
以及替换的所有组合8000用http在所有的上述和/或与服务名称的IP。
我可以确认代理正在正常http://127.0.0.1:8080/api/v1/namespaces/deploy-test/pods工作。
这是服务的描述。请注意,我特别尝试通过 clusterip 访问它,而不是使用 Ambassador。
kubectl describe svc -n deploy-test template-product-app-seldon-prediction-service
Name: template-product-app-seldon-prediction-service
Namespace: deploy-test
Labels: seldon-app=template-product-app-seldon-prediction-service
seldon-deployment-id=template-product-app-seldon-prediction-service
Annotations: getambassador.io/config:
---
apiVersion: ambassador/v1
kind: Mapping
name: seldon_deploy-test_seldon-prediction-service_rest_mapping
prefix: /seldon/deploy-test/seldon-prediction-service/
service: template-product-app-seldon-prediction-service.deploy-test:8000
timeout_ms: 3000
---
apiVersion: ambassador/v1
kind: Mapping
name: seldon_deploy-test_seldon-prediction-service_grpc_mapping
grpc: true
prefix: /seldon.protos.Seldon/
rewrite: /seldon.protos.Seldon/
service: template-product-app-seldon-prediction-service.deploy-test:5001
timeout_ms: 3000
headers:
namespace: deploy-test
seldon: seldon-prediction-service
retry_policy:
retry_on: connect-failure
num_retries: 3
Selector: seldon-app=template-product-app-seldon-prediction-service
Type: ClusterIP
IP: 10.106.1.204
Port: http 8000/TCP
TargetPort: 8000/TCP
Endpoints: 10.1.1.4:8000
Port: grpc 5001/TCP
TargetPort: 5001/TCP
Endpoints: 10.1.1.4:5001
Session Affinity: None
Events: <none>
Run Code Online (Sandbox Code Playgroud)
关于如何通过kubectl proxy而不是旋转 pod来做到这一点的任何建议radial/busyboxplus:curl?
通过kubectl代理访问http服务的一般格式如下:
http://api.host/api/v1/namespaces/NAMESPACE/services/SERVICE_NAME:SERVICE_PORT/proxy/
Run Code Online (Sandbox Code Playgroud)
在您的情况下,您添加了不必要的集群 ip。尝试:
http://127.0.0.1:8080/api/v1/namespaces/deploy-test/services/template-product-app-seldon-prediction-service:8000/proxy/api/v0.1/predictions
Run Code Online (Sandbox Code Playgroud)
http://127.0.0.1:43029/api/v1/namespaces/kube-system/services/http:kubernetes-dashboard
请注意,这可能不适用于 grpc,仅适用于 http。(在这种情况下,请改用 NodePort 或 LoadBalancer)
| 归档时间: |
|
| 查看次数: |
895 次 |
| 最近记录: |