1
我正在關注PluralSight課程,課程作者將Docker圖像放到kubernetes上,然後通過他的瀏覽器訪問它。我試圖複製他所做的,但無法訪問該網站。我相信我可能會連接到錯誤的IP。Google容器連接到服務
我有一個ReplicationController
是正在運行10 pods
:
rc.yml
apiVersion: v1
kind: ReplicationController
metadata:
name: hello-rc
spec:
replicas: 10
selector:
app: hello-world
template:
metadata:
labels:
app: hello-world
spec:
containers:
- name: hello-pod
image: nigelpoulton/pluralsight-docker-ci:latest
ports:
- containerPort: 8080
然後我試圖揭露了RC:
kubectl expose rc hello-rc --name=hello-svc --target-port=8080 --type=NodePort
$ kubectl get services
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
hello-svc 10.27.254.160 <nodes> 8080:30488/TCP 30s
kubernetes 10.27.240.1 <none> 443/TCP 1h
我的谷歌容器端點是: 35.xxx.xx.xxx
和運行kubectl describe svc hello-svc
時,NodePort是30488
因此,我嘗試訪問應用程序35.xxx.xx.xxx:30488
,但無法聯繫到該網站。
Upvote from me,但爲了達到Pluralsight課程的目的,我更容易在防火牆上彈出一個洞。在現實世界中,我確信一個'LoadBalancer'就是要走的路。 – quickshiftin