之前安装好了minikube,下面使用一些关于minikube的相关命令:
- 获取有关运行节点的信息
[zhoujing@zhouj Code]$ kubectl get pod
No resources found.
[zhoujing@zhouj Code]$ kubectl get node
NAME STATUS AGE VERSION
minikube Ready 1d v1.7.0
#创建名为hello-minikube的pod
[zhoujing@zhouj Code]$ kubectl run hello-minikube --image=gcr.io/google_containers/echoserver:1.4 --port=8080
deployment "hello-minikube" created
[zhoujing@zhouj Code]$ kubectl get pod
NAME READY STATUS RESTARTS AGE
hello-minikube-180744149-r908g 0/1 ContainerCreating 0 1m
[zhoujing@zhouj Code]$ kubectl get pod
NAME READY STATUS RESTARTS AGE
hello-minikube-180744149-r908g 1/1 Running 0 6m
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 描述运行节点的所有信息
[zhoujing@zhouj Code]$ kubectl describe pod hello-minikube-180744149-r908g
Name: hello-minikube-180744149-r908g
Namespace: default
Node: minikube/192.168.99.100
Start Time: Wed, 02 Aug 2017 15:11:10 +0800
Labels: pod-template-hash=180744149
run=hello-minikube
Annotations: kubernetes.io/created-by={"kind":"SerializedReference","apiVersion":"v1","reference":{"kind":"ReplicaSet","namespace":"default","name":"hello-minikube-180744149","uid":"c2e163c6-7751-11e7-8ad5-080027d...
Status: Running
IP: 172.17.0.4
Created By: ReplicaSet/hello-minikube-180744149
Controlled By: ReplicaSet/hello-minikube-180744149
Containers:
hello-minikube:
Container ID: docker://864dfca373db0d1e32579adaec2341673bc3508eb047150597c5ffc6cef6ab19
Image: gcr.io/google_containers/echoserver:1.4
Image ID: docker-pullable://gcr.io/google_containers/echoserver@sha256:5d99aa1120524c801bc8c1a7077e8f5ec122ba16b6dda1a5d3826057f67b9bcb
Port: 8080/TCP
State: Running
Started: Wed, 02 Aug 2017 15:11:36 +0800
Ready: True
Restart Count: 0
Environment: <none>
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from default-token-23mkf (ro)
Conditions:
Type Status
Initialized True
Ready True
PodScheduled True
Volumes:
default-token-23mkf:
Type: Secret (a volume populated by a Secret)
SecretName: default-token-23mkf
Optional: false
QoS Class: BestEffort
Node-Selectors: <none>
Tolerations: <none>
Events:
FirstSeen LastSeen Count From SubObjectPath Type Reason Message
--------- -------- ----- ---- ------------- -------- ------ -------
6m 6m 1 default-scheduler Normal Scheduled Successfully assigned hello-minikube-180744149-r908g to minikube
6m 6m 1 kubelet, minikube Normal SuccessfulMountVolume MountVolume.SetUp succeeded for volume "default-token-23mkf"
6m 6m 1 kubelet, minikube spec.containers{hello-minikube} Normal Pulling pulling image "gcr.io/google_containers/echoserver:1.4"
6m 6m 1 kubelet, minikube spec.containers{hello-minikube} Normal Pulled Successfully pulled image "gcr.io/google_containers/echoserver:1.4"
6m 6m 1 kubelet, minikube spec.containers{hello-minikube} Normal Created Created container
6m 6m 1 kubelet, minikube spec.containers{hello-minikube} Normal Started Started container
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 暴露pod的端口;显示访问地址
[zhoujing@zhouj Code]$ kubectl expose deployment hello-minikube --type=NodePort
service "hello-minikube" exposed
[zhoujing@zhouj Code]$ minikube service hello-minikube --url
http://192.168.99.100:30299
- 1
- 2
- 3
- 4
- 5
浏览网页,显示内容如下:
- 1
CLIENT VALUES:
client_address=172.17.0.1
command=GET
real path=
query=nil
request_version=1.1
request_uri=http://192.168.99.100:8080/demo
SERVER VALUES:
server_version=nginx: 1.10.0 - lua: 10001
HEADERS RECEIVED:
accept=text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8
accept-encoding=gzip, deflate
accept-language=en-US,en;q=0.5
connection=keep-alive
host=192.168.99.100:30299
upgrade-insecure-requests=1
user-agent=Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:54.0) Gecko/20100101 Firefox/54.0
BODY:
-no body in request-
- 停止minikube
[zhoujing@zhouj Code]$ minikube stop
Stopping local Kubernetes cluster...
Machine stopped.