systemctl start etcd
systemctl start docker
systemctl start kube-apiserver
systemctl start kube-controller-manager
systemctl start kube-scheduler
systemctl start kubelet
systemctl start kube-proxy
验证
[root@localhost .kube]# kubectl version
Client Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.3", GitCommit:"2bba0127d85d5a46ab4b778548be28623b32d0b0", GitTreeState:"clean", BuildDate:"2018-05-21T09:17:39Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"5", GitVersion:"v1.5.2", GitCommit:"269f928217957e7126dc87e6adfa82242bfe5b1e", GitTreeState:"clean", BuildDate:"2017-07-03T15:31:10Z", GoVersion:"go1.7.4", Compiler:"gc", Platform:"linux/amd64"}
[root@localhost .kube]# kubectl get componentstatus
NAME STATUS MESSAGE ERROR
etcd-0 Healthy {"health":"true"}
scheduler Healthy ok
controller-manager Healthy ok
[root@localhost .kube]# ps -ef|grep kube
root 14558 16233 0 15:17 pts/0 00:00:00 kubectl proxy --port=8443
kube 22748 1 1 15:28 ? 00:00:10 /usr/bin/kube-apiserver --logtostderr=true --v=0 --etcd-servers=http://127.0.0.1:2379 --insecure-bind-address=127.0.0.1 --allow-privileged=false --service-cluster-ip-range=10.254.0.0/16 --admission-control=NamespaceLifecycle,NamespaceExists,LimitRanger,SecurityContextDeny,ResourceQuota
kube 22885 1 2 15:29 ? 00:00:20 /usr/bin/kube-controller-manager --logtostderr=true --v=0 --master=http://127.0.0.1:8080
kube 22983 1 0 15:29 ? 00:00:02 /usr/bin/kube-scheduler --logtostderr=true --v=0 --master=http://127.0.0.1:8080
root 23856 1 1 15:37 ? 00:00:05 /usr/bin/kube-proxy --logtostderr=true --v=0 --master=http://127.0.0.1:8080
root 38641 1 2 10:26 ? 00:01:10 /usr/bin/kubelet --logtostderr=true --v=0 --api-servers=http://127.0.0.1:8080 --address=127.0.0.1 --hostname-override=127.0.0.1 --allow-privileged=false --pod-infra-container-image=registry.access.RedHat.com/rhel7/pod-infrastructure:latest
root 29656 16233 0 15:46 pts/0 00:00:00 grep --color=auto kube
[root@localhost shell]# kubectl cluster-info
Kubernetes master is running at :8080
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
[root@localhost software]# kubectl get nodes
NAME STATUS AGE
127.0.0.1 Ready 1h
[root@localhost software]#
5.入门实验
先拉取纯净centos镜像 docker pull centos慢问题的解决方案
dockerfile制作自己的镜像 docker利用Dockerfile来制作镜像
部署自己的镜像
[root@localhost software]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
base_tomcat tomcat-centos 0bed71f53b94 52 minutes ago 612 MB
docker.io/centos latest 9f38484d220f 2 weeks ago 202 MB
[root@localhost software]# kubectl run myk8s-pod --image=base_tomcat --replicas=2 --port=80
deployment "myk8s-pod" created
[root@localhost software]# kubectl get pods
NAME READY STATUS RESTARTS AGE
myk8s-pod-1394982580-11h8h 0/1 ContainerCreating 0 30s
myk8s-pod-1394982580-37wlc 0/1 ContainerCreating 0 30s
[root@localhost software]# kubectl run myk8s-pod-2 --image=base_tomcat --replicas=5 --port=8070
deployment "myk8s-pod-2" created
[root@localhost software]# kubectl get pods
NAME READY STATUS RESTARTS AGE
myk8s-pod-1394982580-11h8h 0/1 ContainerCreating 0 2m
myk8s-pod-1394982580-37wlc 0/1 ContainerCreating 0 2m
myk8s-pod-2-2707079129-1305m 0/1 ContainerCreating 0 5s
myk8s-pod-2-2707079129-2nvff 0/1 ContainerCreating 0 5s
myk8s-pod-2-2707079129-dk9m5 0/1 ContainerCreating 0 5s
myk8s-pod-2-2707079129-mwn3g 0/1 ContainerCreating 0 5s
myk8s-pod-2-2707079129-r282t 0/1 ContainerCreating 0 5s
[root@localhost software]# kubectl get deployments
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
myk8s-pod 2 2 2 0 13m
myk8s-pod-2 5 5 5 0 11m