kubernetes
Posted alexhjl
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了kubernetes相关的知识,希望对你有一定的参考价值。
v1.14
所有机器:
swapoff -a
apt-get install docker.io
apt-get update && apt-get install -y apt-transport-https curl
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
deb https://apt.kubernetes.io/ kubernetes-xenial main
EOF
apt-get update
apt-get install -y kubelet kubeadm kubectl
apt-mark hold kubelet kubeadm kubectl
systemctl enable docker.service
master上执行:
kubeadm init --kubernetes-version=v1.14.0 --pod-network-cidr=10.244.0.0/16 --service-cidr=10.96.0.0/12 --apiserver-advertise-address=0.0.0.0
mkdir -p $HOME/.kube #这样执行kubectl get cs不会报错
cp -i /etc/kubernetes/admin.conf ~/.kube/config #这样执行kubectl get cs不会报错,get cs == get compontsstatuses 验证其各组件的运行是否正常。
验证:
kubectl get cs #get cs == get compontsstatuses 验证其各组件的运行是否正常。
NAME STATUS MESSAGE ERROR
scheduler Healthy ok
controller-manager Healthy ok
etcd-0 Healthy {"health":"true"}
安装flannel网络:
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/a70459be0084506e4ec919aa1c114638878db11b/Documentation/kube-flannel.yml
验证:
kubectl get nodes会变成Ready状态
kubectl get pods -n kube-system| grep flannel #也会显示Running
获取集群状态信息:
kubectl cluster-info
Kubernetes master is running at https://192.168.204.13:6443
KubeDNS is running at https://192.168.204.13:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
To further debug and diagnose cluster problems, use ‘kubectl cluster-info dump‘.
kubectl version
Client Version: version.Info{Major:"1", Minor:"14", GitVersion:"v1.14.0", GitCommit:"641856db18352033a0d96dbc99153fa3b27298e5", GitTreeState:"clean", BuildDate:"2019-03-25T15:53:57Z", GoVersion:"go1.12.1", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"14", GitVersion:"v1.14.0", GitCommit:"641856db18352033a0d96dbc99153fa3b27298e5", GitTreeState:"clean", BuildDate:"2019-03-25T15:45:25Z", GoVersion:"go1.12.1", Compiler:"gc", Platform:"linux/amd64"}
kubectl version --short=true
Client Version: v1.14.0
Server Version: v1.14.0
集群重置:
kubeadm reset
查看所有集群:
kubectl get nodes
从集群移除节点:
master上执行:
kubectl drain NODE_ID --delete-local-data --force --ignore-daemonsets
kubectl delete node NODE_ID
node上执行:
kubeadm reset
以上是关于kubernetes的主要内容,如果未能解决你的问题,请参考以下文章
nginx.conf 忽略了 nginx-ingress 配置映射片段
如何学习kubernetes,学习kubernetes需要代码基础吗?