【发布时间】:2020-07-06 05:58:31
【问题描述】:
我在 Windows 上使用 Docker 和 Minikube 来学习 k8s,但我未能部署我的第一个应用程序。
我运行了以下命令:
kubectl run testapp --image=saphyra/testapp:latest --port=8080-
kubectl expose deployment testapp --type=NodePort minikube service testapp
使用命令minikube dashboard 可以看到 pod 已创建并正在运行,我可以看到日志,它说 Tomcat 按预期在端口 8080 上启动。
看来一切正常。
但是如何调用我启动的服务的端点(从浏览器)? 我关注的tutorial(以及许多其他 YouTube 教程)说现在我必须能够调用应用程序的端点。
我错过了什么?如何访问我的应用?
编辑:
描述结果
kubectl describe svc testapp >
Name: testapp
Namespace: default
Labels: run=testapp
Annotations: <none>
Selector: run=testapp
Type: NodePort
IP: 10.110.10.61
Port: <unset> 8080/TCP
TargetPort: 8080/TCP
NodePort: <unset> 31612/TCP
Endpoints: 172.18.0.4:8080
Session Affinity: None
External Traffic Policy: Cluster
Events: <none>
kube 代理日志:
server_others.go:323] Unknown proxy mode "", assuming iptables proxy
node.go:135] Successfully retrieved node IP: 172.17.0.2
server_others.go:145] Using iptables Proxier.
server.go:571] Version: v1.17.3
conntrack.go:100] Set sysctl 'net/netfilter/nf_conntrack_max' to 524288
conntrack.go:52] Setting nf_conntrack_max to 524288
conntrack.go:127] sysfs is not writable: {Device:sysfs Path:/sys Type:sysfs Opts:[ro nosuid nodev noexec relatime] Freq:0 Pass:0} (mount options are [ro nosuid nodev noexec relatime])
conntrack.go:100] Set sysctl 'net/netfilter/nf_conntrack_tcp_timeout_established' to 86400
conntrack.go:100] Set sysctl 'net/netfilter/nf_conntrack_tcp_timeout_close_wait' to 3600
config.go:313] Starting service config controller
shared_informer.go:197] Waiting for caches to sync for service config
config.go:131] Starting endpoints config controller
shared_informer.go:197] Waiting for caches to sync for endpoints config
shared_informer.go:204] Caches are synced for service config
shared_informer.go:204] Caches are synced for endpoints config
编辑 2
kubectl get svc testapp -o yaml >
apiVersion: v1
kind: Service
metadata:
creationTimestamp: "2020-03-25T17:03:57Z"
labels:
run: testapp
name: testapp
namespace: default
resourceVersion: "3454"
selfLink: /api/v1/namespaces/default/services/testapp
uid: 048d05df-eaad-4d4b-845f-d98b222fe101
spec:
clusterIP: 10.110.10.61
externalTrafficPolicy: Cluster
ports:
- nodePort: 31612
port: 8080
protocol: TCP
targetPort: 8080
selector:
run: testapp
sessionAffinity: None
type: NodePort
status:
loadBalancer: {}
kubectl get pod testapp-c565bfccc-xht6j -o yaml >
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: "2020-03-25T17:03:52Z"
generateName: testapp-c565bfccc-
labels:
pod-template-hash: c565bfccc
run: testapp
name: testapp-c565bfccc-xht6j
namespace: default
ownerReferences:
- apiVersion: apps/v1
blockOwnerDeletion: true
controller: true
kind: ReplicaSet
name: testapp-c565bfccc
uid: 21e2c9ab-3771-482f-8849-71754aaf5ff6
resourceVersion: "3491"
selfLink: /api/v1/namespaces/default/pods/testapp-c565bfccc-xht6j
uid: c4dfdcb6-d050-4c44-99d1-6881bc39f805
spec:
containers:
- image: saphyra/testapp:latest
imagePullPolicy: Always
name: testapp
ports:
- containerPort: 8080
protocol: TCP
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /var/run/secrets/kubernetes.io/serviceaccount
name: default-token-689j9
readOnly: true
dnsPolicy: ClusterFirst
enableServiceLinks: true
nodeName: m01
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-689j9
secret:
defaultMode: 420
secretName: default-token-689j9
status:
conditions:
- lastProbeTime: null
lastTransitionTime: "2020-03-25T17:03:52Z"
status: "True"
type: Initialized
- lastProbeTime: null
lastTransitionTime: "2020-03-25T17:04:12Z"
status: "True"
type: Ready
- lastProbeTime: null
lastTransitionTime: "2020-03-25T17:04:12Z"
status: "True"
type: ContainersReady
- lastProbeTime: null
lastTransitionTime: "2020-03-25T17:03:52Z"
status: "True"
type: PodScheduled
containerStatuses:
- containerID: docker://9a3ddc83df779bb4dc4b88718d82f7065d2dc647360fa200b4815ecc260a7ed4
image: saphyra/testapp:latest
imageID: docker-pullable://saphyra/testapp@sha256:b328a874297521f35c84a37cde160e23a39d6a12c7184dbe3c88ff0250b05df6
lastState: {}
name: testapp
ready: true
restartCount: 0
started: true
state:
running:
startedAt: "2020-03-25T17:04:11Z"
hostIP: 172.17.0.2
phase: Running
podIP: 172.18.0.4
podIPs:
- ip: 172.18.0.4
qosClass: BestEffort
startTime: "2020-03-25T17:03:52Z"
【问题讨论】:
-
minikube service testapp 没有启动浏览器?
-
它在浏览器中启动了一个选项卡,但是 ERR_CONNECTION_REFUSED
-
添加 kubectl describe svc testapp 的输出和 kube-system 命名空间中 kube 代理 pod 的日志
-
请求的数据已添加@ArghyaSadhu
标签: spring-boot kubernetes minikube docker-desktop