您好,登錄后才能下訂單哦!
一.k8s部署
1.各節點安裝kubectl,kubelet,kubeadm,需要通過yum安裝,所以還是先配置yum源。
cat /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=0
repo_gpgcheck=0
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
2.安裝k8s要注意版本匹配,不然會在初始化的時候提示你kubeadm版本和kubernets版本不對,或高或低,所以安裝完成后查看下版本,最好yum安裝時帶版本號安裝
kubeadm version
kubectl version
輸出如下:
[root@localhost kubernetes]# kubeadm version
kubeadm version: &version.Info{Major:"1", Minor:"13", GitVersion:"v1.13.1", GitCommit:"eec55b9ba98609a46fee712359c7b5b365bdd920", GitTreeState:"clean", BuildDate:"2018-12-13T10:36:44Z", GoVersion:"go1.11.2", Compiler:"gc", Platform:"linux/amd64"}
開機啟動,初始化要保證開啟systemctl enable kubelet.service
開始安裝,鏡像下載網上有很多不多說,現在完成后改名為如下:
k8s.gcr.io/kube-proxy v1.13.1 fdb321fd30a0 7 months ago 80.2MB
k8s.gcr.io/kube-scheduler v1.13.1 ab81d7360408 7 months ago 79.6MB
k8s.gcr.io/kube-apiserver v1.13.1 40a63db91ef8 7 months ago 181MB
k8s.gcr.io/kube-controller-manager v1.13.1 26e6f1db2a52 7 months ago 146MB
k8s.gcr.io/coredns 1.2.6 f59dcacceff4 9 months ago 40MB
k8s.gcr.io/etcd 3.2.24 3cab8e1b9802 10 months ago 220MB
k8s.gcr.io/pause 3.1 da86e6ba6ca1 19 months ago 742kB
然后master節點執行初始化kubeadm init --kubernetes-version=v1.15.0 --pod-network-cidr=10.244.0.0/16
注意版本要匹配自己的版本,后面pod網段要匹配fannel插件安裝時候的yaml.
初始化完成會顯示以下內容:這里的東西很重要,顏色表明的要按自己的去復制
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 172.16.32.10:6443 --token x8gdiq.sbcj8g4fmoocd5tl \
--discovery-token-ca-cert-hash sha256:0b48e70fa8a268f8b88cd69b02cf87d8a2bf2efe519bb88dfa558de20d4a9993
安裝網絡插件fannelkubectl apply -f https://raw.githubusercontent.com/coreos/flannel/a70459be0084506e4ec919aa1c114638878db11b/Documentation/kube-flannel.yml
*也是要注意版本問題,kube-fannel.yaml里面是有鏡像版本配置的,同時注意修改里面的網段和初始化一致。全部running狀態。
[root@localhost kubernetes]# kubectl get pods -n kube-system
NAME READY STATUS RESTARTS AGE
coredns-86c58d9df4-jt4pd 1/1 Running 0 25h
coredns-86c58d9df4-m6bzt 1/1 Running 0 25h
etcd-localhost.localdomain 1/1 Running 0 25h
kube-apiserver-localhost.localdomain 1/1 Running 0 25h
kube-controller-manager-localhost.localdomain 1/1 Running 0 25h
kube-flannel-ds-amd64-qfqr4 1/1 Running 20 24h
kube-flannel-ds-amd64-xjk6v 1/1 Running 0 25h
kube-proxy-p226l 1/1 Running 0 24h
kube-proxy-qq4j4 1/1 Running 0 25h
kube-scheduler-localhost.localdomain 1/1 Running 0 25h
kubernetes-dashboard-7d77666777-2l68j 1/1 Running 0 5h38m
從節點加入:
從節點需要安裝kube-proxy pause
使用master初始化時候結果的kubeadm join來加入主節點kubeadm join 172.16.32.10:6443 --token x8gdiq.sbcj8g4fmoocd5tl \
--discovery-token-ca-cert-hash sha256:0b48e70fa8a268f8b88cd69b02cf87d8a2bf2efe519bb88dfa558de20d4a9993
從節點加完后記得從主節點拷貝admin.yaml
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。