kubernetes - 在 Kubernetes 上部署和公开应用程序
问题描述
在 Ubuntu 上,我使用 minikube 在 kubernetes 上部署和公开应用程序。我遇到了如何使用和查看应用程序的问题。
我使用此链接来解决此问题。
minikube service --url $SERVICE
我希望输出显示我在 kubernetes 上部署的应用程序。
当我点击 ubuntu 终端中的链接时,谷歌浏览器的实际输出是:
This site can’t be reached
192.168.99.108 refused to connect.
Try:
Checking the connection
Checking the proxy and the firewall
ERR_CONNECTION_REFUSED
这是 pod 定义:
priority: 0
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
serviceAccount: default
serviceAccountName: default
terminationGracePeriodSeconds: 30
tolerations:
- effect: NoExecute
key: node.kubernetes.io/not-ready
operator: Exists
tolerationSeconds: 300
- effect: NoExecute
key: node.kubernetes.io/unreachable
operator: Exists
tolerationSeconds: 300
volumes:
- name: default-token-6sw9l
secret:
defaultMode: 420
secretName: default-token-6sw9l
status:
conditions:
- lastProbeTime: null
lastTransitionTime: "2019-09-21T22:50:02Z"
status: "True"
type: Initialized
- lastProbeTime: null
lastTransitionTime: "2019-09-23T22:05:36Z"
status: "True"
type: Ready
- lastProbeTime: null
lastTransitionTime: "2019-09-23T22:05:36Z"
status: "True"
type: ContainersReady
- lastProbeTime: null
lastTransitionTime: "2019-09-21T22:50:02Z"
status: "True"
type: PodScheduled
containerStatuses:
- containerID:
docker://57c0d2fccc9698ace22600f3d3197416324ed3bf570f929562d4669bd018d77f
image: .../test:latest
imageID: docker-pullable://.../test@sha256:fc6e42ba94b04cafa64c77b76961243695e03441ce0a54d21f22db99c8fdf7d7
lastState:
terminated:
containerID: docker://e5ed21b41e7075681d6be8b46954e8bb5b2e6be2ef63942951b41176d583f03e
exitCode: 0
finishedAt: "2019-09-23T21:44:21Z"
reason: Completed
startedAt: "2019-09-23T21:43:40Z"
name: test
ready: true
restartCount: 3
state:
running:
startedAt: "2019-09-23T22:05:28Z"
hostIP: 10.0.2.15
phase: Running
podIP: 172.17.0.9
qosClass: BestEffort
startTime: "2019-09-21T22:50:02Z"
这是服务定义:
apiVersion: v1
kind: Service
metadata:
creationTimestamp: "2019-09-21T22:50:13Z"
labels:
app: tesb-node
name: tesb-node
namespace: default
resourceVersion: "51502"
selfLink: /api/v1/namespaces/default/services/tesb-node
uid: d0182ca7-cbd0-4c56-a2b7-a9e6f1c64621
spec:
clusterIP: 10.99.98.201
externalTrafficPolicy: Cluster
ports:
- nodePort: 30178
port: 84
protocol: TCP
targetPort: 84
selector:
app: tesb-node
sessionAffinity: None
type: LoadBalancer
status:
loadBalancer: {}
解决方案
您需要使用 ip 传递 NodePort 编号才能接收响应。可以试试
kubectl get service $SERVICE --output='jsonpath="{.spec.ports[0].nodePort}"'
获取端口号?
推荐阅读
- javascript - 如何阅读和理解角度模板解析器错误
- jquery - 为什么这个 jQuery 脚本不起作用?
- python - 根据字典值将字典列表转换为单独的列表
- docker - Portainer docker容器反向代理问题
- html - css/html 适用于本地文件,而不适用于 jsfiddle 或 codepen
- xcode - 使用 prepareForSegue 在表视图之间传递索引不起作用
- properties - 为什么 hive-site.xml 中的属性没有在 hive 中获取?
- javascript - 引导弹出框内的 onclick 事件
- python - 尝试通过用户输入标记图形中的点
- postgresql - 在 OpenShift 中使用 postgresql-persistent 模板创建 postgresql 部署