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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
| [root@localhost ~]# which minikube
[root@localhost ~]# which kubectl
[root@localhost ~]# minikube status
[root@localhost ~]# docker version
[root@localhost ~]# docker container list
[root@localhost ~]# docker ps
[root@localhost ~]# docker pull googlecontainer/echoserver:1.8
[root@localhost ~]# kubectl get deployments
[root@localhost ~]# kubectl get pods
[root@localhost ~]# kubectl delete deployment sa-frontend
[root@localhost ~]# kubectl run hello-minikube --image=googlecontainer/echoserver:1.8 --port=8080
[root@localhost ~]# kubectl expose deployment hello-minikube --type=NodePort
[root@localhost ~]# minikube service hello-minikube --url
http://127.0.0.1:30520
[root@localhost ~]# kubectl get pods --watch
[root@localhost ~]# kubectl get svc
[root@localhost ~]# kubectl delete svc sa-web-app-lb
# HELLO-MINIKUBE
[root@localhost ~]# docker pull googlecontainer/echoserver:1.8
[root@localhost ~]# kubectl run hello-minikube --image=googlecontainer/echoserver:1.8 --port=8080
[root@localhost ~]# kubectl expose deployment hello-minikube --type=NodePort
[root@localhost ~]# minikube service hello-minikube --url
http://127.0.0.1:30520
# DOCKER CONTAINERS
[root@localhost docker-demo]# docker build .
[root@localhost docker-demo]# docker image list
[root@localhost docker-demo]# docker run -p 3000:3000 -it db12bf098771
# FROM DOCKER IMAGE TO DOCKER HUB
[root@localhost ~]# docker image ls
[root@localhost ~]# docker tag db12bf098771 baoguoding/docker-demo
[root@localhost ~]# docker tag db12bf098771 baoguoding/docker-demo:v1.0.0
[root@localhost ~]# docker rmi -f baoguoding/docker-demo:v1.0.0
[root@localhost ~]# docker push baoguoding/docker-demo
# CREATE POD
[root@localhost ~]# minikube stop
[root@localhost ~]# service docker stop
[root@localhost ~]# rm -rf /var/lib/docker
[root@localhost ~]# rm -rf ~/.kube
[root@localhost ~]# kubeadm reset
[root@localhost ~]# service docker start
[root@localhost ~]# minikube start --vm-driver=none --bootstrapper=localkube
[root@localhost ~]# vim /etc/docker/daemon.json
{
"registry-mirrors": ["https://registry.docker-cn.com"]
}
[root@localhost ~]# vim /lib/systemd/system/docker.service
BEFORE:
ExecStart=/usr/bin/dockerd
AFTER:
ExecStart=/usr/bin/dockerd -g /home/baoguoding/docker
ExecStartPost=/sbin/iptables -I FORWARD -s 0.0.0.0/0 -j ACCEPT
iptables -P FORWARD ACCEPT //只是放这边,没有用
[root@localhost ~]# systemctl stop docker
[root@localhost ~]# systemctl start docker
[root@localhost ~]# docker system df
[root@localhost ~]# docker info
[root@localhost ~]# docker images ls
[root@localhost ~]# docker container ls
[root@localhost ~]# docker version
[root@localhost ~]# docker run hello-world
[root@localhost demo-pod]# kubectl create -f my-first-pod.yaml
[root@localhost demo-pod]# kubectl get pods --show-all
[root@localhost demo-pod]# kubectl describe pods my-pod
[root@localhost demo-pod]# kubectl port-forward my-pod 8000:3000
[root@localhost demo-pod]# kubectl expose pod my-pod --type=NodePort --name=my-pod-service
[root@localhost demo-pod]# kubectl get services
[root@localhost demo-pod]# minikube service my-pod-service --url
http://127.0.0.1:30374
[root@localhost demo-pod]# kubectl attach my-pod -i
[root@localhost demo-pod]# kubectl exec my-pod -- ls /app
[root@localhost demo-pod]# kubectl get pod --show-labels
[root@localhost demo-pod]# kubectl run -i --tty alpine --image=alpine --restart=Never -- sh
[root@localhost demo-pod]# journalctl -f -u kubelet
|