GopherInk / Doc

http://gopher.ink
1 stars 0 forks source link

Kubernetes安装手记 #4

Open Sakurasan opened 5 years ago

Sakurasan commented 5 years ago

Docker官网安装教程 K8S官网安装教程

从零开始搭建Kubernetes集群 (简书)

10分钟搭建Kubernetes容器集群平台(kubeadm)

【从零开始/亲测国内外均可】基于阿里云Ubuntu的kubernetes(k8s)主从节点分布式集群搭建

配置代理

安装k8s 纯命令记录帖(ubuntu18.0) (51CTO)

从零开始搭建K8S集群(二)-- 搭建K8S集群

树莓派安装k8s

[Mac 历史版本]https://docs.docker.com/docker-for-mac/edge-release-notes/


curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
备用 curl -s http://cloud.emmmmmm.org/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

[1] 替换k8s官方源 查看版本https://dl.k8s.io/release/stable-1.11.txt curl -L https://github.com/GopherInk/Doc/raw/master/docker_pull_k8s.sh |sh

apt-get update

apt-get install -y kubernetes-cni=0.6.0-00 kubectl=1.11.3-00 kubelet=1.11.3-00 kubeadm=1.11.3-00
apt-get install -y kubeadm kubelet kubectl

apt-mark hold kubelet kubeadm kubectl

## 安装并配置k8s的主节点
## 在主节点使用 kubeadm init 命令
kubeadm init --apiserver-advertise-address=10.0.2.15 --pod-network-cidr=10.244.0.0/16
(kubeadm init --apiserver-advertise-address=10.0.2.4 --pod-network-cidr=192.168.16.0/20)weave-net

Your Kubernetes control-plane has initialized successfully!

To start using your cluster, you need to run the following as a regular user:

mkdir -p $HOME/.kube sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config sudo chown $(id -u):$(id -g) $HOME/.kube/config

You should now deploy a pod network to the cluster. Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at: https://kubernetes.io/docs/concepts/cluster-administration/addons/

Then you can join any number of worker nodes by running the following on each as root:

kubeadm join 10.0.2.15:6443 --token fonmj5.ra36i6jdh0qmydc5 \ --discovery-token-ca-cert-hash sha256:3c6019a097485aca394c58fd8d68ddccd9d74b10d39e8079a9b45e637d020c81

kubeadm token create --print-join-command

安装网络插件

export KUBECONFIG=/etc/kubernetes/admin.conf kubectl get pods -n kube-system -o wide

kubectl apply -f "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '\n')"

curL -L "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d'\n')" > weave.yaml env: -name:HOSTNAME valueFrom: fieldRef: apiVersion:v1 fieldPath:spec.nodeName -name:IPALLOC_RANGE value:192.168.16.0/20 kubectl apply -f weave.yaml

kubectl get pods -n kube-system -o wide

Step4 使用kubectl get nodes命令

kubectl get nodes

Step5 配置net-pod

kubectl apply -f https://docs.projectcalico.org/v3.1/getting-started/kubernetes/installation/hosted/canal/rbac.yaml

kubectl apply -f https://docs.projectcalico.org/v3.1/getting-started/kubernetes/installation/hosted/canal/canal.yaml

安装dashboard

kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v1.10.1/src/deploy/recommended/kubernetes-dashboard.yaml

kubectl get pods -n kube-system |grep dashboard

kubectl get svc -n kube-syste

清空节点

姿势如下

$> sudo su
#> kubeadm reset
#> rm -rf $HOME/.kube /etc/kubernetes

Docker pull k8s list

REPOSITORY TAG IMAGE ID CREATED SIZE
k8s.gcr.io/kube-proxy v1.14.1 20a2d7035165 11 days ago 82.1 MB
k8s.gcr.io/kube-apiserver v1.14.1 cfaa4ad74c37 11 days ago 210 MB
k8s.gcr.io/kube-scheduler v1.14.1 8931473d5bdb 11 days ago 81.6 MB
k8s.gcr.io/kube-controller-manager v1.14.1 efb3887b411d 11 days ago 158 MB
quay.io/calico/node v3.1.6 3030acce0214 5 weeks ago 241 MB
quay.io/calico/cni v3.1.6 91d623a7690c 5 weeks ago 69.4 MB
quay.io/calico/kube-controllers v3.1.6 4c9f97e99cd6 5 weeks ago 55.6 MB
k8s.gcr.io/coredns 1.3.1 eb516548c180 3 months ago 40.3 MB
k8s.gcr.io/kubernetes-dashboard-amd64 v1.10.1 f9aed6605b81 4 months ago 122 MB
k8s.gcr.io/etcd 3.3.10 2c4adeb21b4f 4 months ago 258 MB
k8s.gcr.io/pause 3.1 da86e6ba6ca1 16 months ago 742 kB
quay.io/coreos/flannel v0.9.1 2b736d06ca4c 17 months ago 51.3 MB
quay.io/coreos/etcd v3.1.10 47bb9dd99916 21 months ago 34.6 MB

registry.cn-hangzhou.aliyuncs.com/google_containers/

Sakurasan commented 5 years ago

https://help.github.com/en/articles/duplicating-a-repository

Sakurasan commented 5 years ago

http://www.php.cn/manual/view/35323.html

Sakurasan commented 4 years ago

Dockerhub镜像加速源配置

华为

https://mirrors.huaweicloud.com/

加速器地址: https://059621dc8800256f0f54c008fe50f420.mirror.swr.myhuaweicloud.com

sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<- 'EOF'
{
    "registry-mirrors": ["https://059621dc8800256f0f54c008fe50f420.mirror.swr.myhuaweicloud.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker