我可以创建容器:
$ kubectl run hello-minikube --image=gcr.io/google_containers/echoserver:1.4 --port=
deployment "hello-minikube" created
我现在正在尝试暴露一个服务:
$ kubectl expose deployment hello-minikube --type=NodePort
error: couldn't find port via --port flag or introspection
即使我删除它,它仍会自动回来:
$ kubectl delete pod hello-minikube-2138963058-2szl7
pod "hello-minikube-2138963058-2szl7" deleted
[stephane@stephane-ThinkPad-X201 ~]
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
hello-minikube-2138963058-nhh1q 1/1 Running 0 3m
这是Pod:
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
hello-minikube-2138963058-2szl7 1/1 Running 0 16m
并且它的描述:
$ kubectl describe pod hello-minikube-2138963058-2szl7
Name: hello-minikube-2138963058-2szl7
Namespace: default
Node: minikube/192.168.42.196
Start Time: Thu, 14 Sep 2017 23:20:03 +0200
Labels: pod-template-hash=2138963058
run=hello-minikube
Annotations: kubernetes.io/created-by={"kind":"SerializedReference","apiVersion":"v1","reference":{"kind":"ReplicaSet","namespace":"default","name":"hello-minikube-2138963058","uid":"2b37ca13-9968-11e7-a720-525400...
Status: Running
IP: 172.17.0.3
Created By: ReplicaSet/hello-minikube-2138963058
Controlled By: ReplicaSet/hello-minikube-2138963058
Containers:
hello-minikube:
Container ID: docker://5e4ba407d8869e6e843ec3d7876e953147cc01104e980c7febfea218808ab379
Image: gcr.io/google_containers/echoserver:1.4
Image ID: docker-pullable://gcr.io/google_containers/echoserver@sha256:5d99aa1120524c801bc8c1a7077e8f5ec122ba16b6dda1a5d3826057f67b9bcb
Port: <none>
State: Running
Started: Thu, 14 Sep 2017 23:20:05 +0200
Ready: True
Restart Count: 0
Environment: <none>
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from default-token-t8qx7 (ro)
Conditions:
Type Status
Initialized True
Ready True
PodScheduled True
Volumes:
default-token-t8qx7:
Type: Secret (a volume populated by a Secret)
SecretName: default-token-t8qx7
Optional: false
QoS Class: BestEffort
Node-Selectors: <none>
Tolerations: <none>
Events:
FirstSeen LastSeen Count From SubObjectPath Type Reason Message
--------- -------- ----- ---- ------------- -------- ------ -------
17m 17m 1 default-scheduler Normal Scheduled Successfully assigned hello-minikube-2138963058-2szl7 to minikube
17m 17m 1 kubelet, minikube Normal SuccessfulMountVolume MountVolume.SetUp succeeded for volume "default-token-t8qx7"
17m 17m 1 kubelet, minikube spec.containers{hello-minikube} Normal Pulled Container image "gcr.io/google_containers/echoserver:1.4" already present on machine
17m 17m 1 kubelet, minikube spec.containers{hello-minikube} Normal Created Created container
17m 17m 1 kubelet, minikube spec.containers{hello-minikube} Normal Started Started container
在Linux上运行minikube主机上的所有内容。
kubectl run hello-minikube --image=gcr.io/google_containers/echoserver:1.4 --port=82
和kubectl expose deployment hello-minikube --type=NodePort
,它显示了服务$ kubectl get services NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE hello-minikube 10.0.0.81 <nodes> 82:32515/TCP 4h
,但尝试连接失败$ curl $(minikube service hello-minikube --url) curl: (7) Failed to connect to 192.168.42.196 port 32515: Connection refused
- Stephane