Я установил следующее:
docker версия 19.03.8, minikube версия 1.8.2, kubectl версия 1.15.5.
И создал файл развертывания YAML, который выглядит как this:
---
kind: Service
apiVersion: v1
metadata:
name: hellowworldservice
spec:
selector:
app: hello-world
ports:
- protocol: "TCP"
# Port accessible inside cluster
port: 8081
# Port to forward to inside the pod
targetPort: 8080
# Port accessible outside cluster
nodePort: 30005
type: LoadBalancer
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: hello-world
labels:
app: hello-world
spec:
replicas: 5
selector:
matchLabels:
app: hello-world
template:
metadata:
labels:
app: hello-world
spec:
containers:
- name: hello-world
image: tutum/hello-world
ports:
- containerPort: 8080
Блоки и развертывания запускаются успешно:
PS C:\kubernetes> kubectl create -f deployment.yaml
service/hellowworldservice created
deployment.apps/hello-world created
PS C:\kubernetes> kubectl get pods
NAME READY STATUS RESTARTS AGE
hello-world-889b5c84c-98vvx 1/1 Running 0 25s
hello-world-889b5c84c-bs48d 1/1 Running 0 25s
hello-world-889b5c84c-hm6j2 1/1 Running 0 25s
hello-world-889b5c84c-hzqcc 1/1 Running 0 25s
hello-world-889b5c84c-xg5nl 1/1 Running 0 25s
PS C:\kubernetes> kubectl get deployments
NAME READY UP-TO-DATE AVAILABLE AGE
hello-world 5/5 5 5 40s
Я могу получить доступ к IP-адресу, пропинговав его, но не через порт, где находится веб-страница Hello World должно быть. Почему это?
PS C:\kubernetes> minikube ip
172.17.45.76
PS C:\kubernetes> ping 172.17.45.76
Pinging 172.17.45.76 with 32 bytes of data:
Reply from 172.17.45.76: bytes=32 time<1ms TTL=64
Reply from 172.17.45.76: bytes=32 time<1ms TTL=64
Reply from 172.17.45.76: bytes=32 time<1ms TTL=64
Reply from 172.17.45.76: bytes=32 time=1ms TTL=64
Ping statistics for 172.17.45.76:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 1ms, Average = 0ms
PS C:\kubernetes> curl http://172.17.45.76:30005
curl : Unable to connect to the remote server
At line:1 char:1
+ curl http://172.17.45.76:30005
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand