K8s的初次安装与一些注意点
教程网址:https://hazx.hmacg.cn/server/k8s-install.htmlkubeadm join 192.168.8.130:6443 --token abcdef.0123456789abcdef \--discovery-token-ca-cert-hash sha256:81d509f4e70e8723c3958834f75e0a0c92612de019120ea
教程网址:
https://hazx.hmacg.cn/server/k8s-install.html
kubeadm join 192.168.8.130:6443 --token abcdef.0123456789abcdef \
--discovery-token-ca-cert-hash sha256:81d509f4e70e8723c3958834f75e0a0c92612de019120ea963fcda8cc8728e6f
[root@k8s-master ~]# mkdir -p $HOME/.kube
# 控制节点(主节点)
firewall-cmd --add-service k8s-master --permanent
# 计算节点(工作节点)
firewall-cmd --add-service k8s-worker --permanent
上面两步骤需要重启后才可以执行
apiVersion: kubeadm.k8s.io/v1beta2
bootstrapTokens:
- groups:
- system:bootstrappers:kubeadm:default-node-token
token: abcdef.0123456789abcdef
ttl: 24h0m0s
usages:
- signing
- authentication
kind: InitConfiguration
localAPIEndpoint:
advertiseAddress: 【控制节点IP】
bindPort: 6443
nodeRegistration:
criSocket: /var/run/dockershim.sock
name: 【控制节点主机名】
taints:
- effect: NoSchedule
key: node-role.kubernetes.io/master
---
apiServer:
timeoutForControlPlane: 4m0s
apiVersion: kubeadm.k8s.io/v1beta2
certificatesDir: /etc/kubernetes/pki
clusterName: kubernetes
controllerManager: {}
dns:
type: CoreDNS
etcd:
local:
dataDir: /var/lib/etcd
imageRepository: k8s.gcr.io#--------------------------------------------------------------------------------------------地址需要改为阿里的registry.aliyuncs.com/google_containers
kind: ClusterConfiguration
kubernetesVersion: v1.15.5 #要安装的K8s版本,默认不是最新,可在Kubernetes官网查看版本号
networking:
dnsDomain: cluster.local
podSubnet: 10.244.0.0/16 #容器网段,可不修改----------------------------------------------------------------------------默认是没有的,需要手动添加
serviceSubnet: 10.96.0.0/12 #集群网段,可不修改
scheduler: {}
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml ----------------flannel会报错,需要在github下载对应版本后,在用docker load< xx.docker 才可以:yml文件里边有 image: quay.io/coreos/flannel:v0.13.1-rc1
docker pull registry.aliyuncs.com/google_containers/kubernetes-dashboard-amd64:v1.10.1
dashboard 端口号:31780
登录token:
eyJhbGciOiJSUzI1NiIsImtpZCI6IjcycFlnbEtfbGlOcEgxSE8ybTNwV2MzdXhacWl1bjk5dDdySWRzM09XekUifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJkZWZhdWx0LXRva2VuLTJ2cmNqIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQubmFtZSI6ImRlZmF1bHQiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC51aWQiOiJiODMzOTcyYy0xNjRhLTQ3ZmItYmFlOC1kNWM3NDU1ODBhM2EiLCJzdWIiOiJzeXN0ZW06c2VydmljZWFjY291bnQ6a3ViZS1zeXN0ZW06ZGVmYXVsdCJ9.cQI2YiyAyz917HYdV34RKu99hpQYdl55bggcpgF6oxtVbbAdqhIJrrow6U9CKa8YzVP6PaAlv5iRcgSBTVYw5-U7IFNQsHsXtYX4pa6nJTb3XPZhdo-C2-4EZ6KjsOQs9lQXn5nXdRoOV-fZ9Kzvw0ZiHUdDBTmZ5jvH0E9-MAcNDCPPZACkmqnuBa48vMZc9v_US2fQRwD9De7nMNWmagil7SKju5stZzop4Q3wvLoZzbawDwAtXSxXlVa1oEnGj0DuEAlenFWTXz7EWUhckGClewcYf3I63gwZQiWyHY7o2Mp9RSCj3W3GyQcO6fVrAxrdU3PgyZ_tN5_U-rMR0A
加入集群的token
iz6lkp.ynq0p2qjppl6inmb
加入集群的hash
81d509f4e70e8723c3958834f75e0a0c92612de019120ea963fcda8cc8728e6f
生成注册命令
kubeadm token create --print-join-command
工作节点NotReady的解决方法
https://www.cnblogs.com/liuyi778/p/12771259.html
主要原因是flannel 和 proxy的容器没下载 ,下载后重启master的docker服务即可,systemctl restart kubelet docker
k8s 如果dashboard版本低于k8s版本时,会有界面404的问题,通过卸载dashboard kubectl delete -f xxx.yaml的方式卸载原来的dashboard。
然后从dashboard官网上找到对应版本的dashboard的yaml进行安装 官网地址:https://github.com/kubernetes/dashboard/releases 里边有各种版本的dashboard适配的k8s版本 目前用的是1.20 所以是用1.21版本的dashboard
下载安装出现了dashboard报CrashLoopBackOff 错可以通过启用master节点并将dashboard节点写死的方式规避掉内部网络互通问题。
将kubernetes-dashboard.yaml下载下来,注释掉下面的行
# Comment the following tolerations if Dashboard must not be deployed on master
# tolerations:
- key: node-role.kubernetes.io/master
effect: NoSchedule
然后添加nodeName(你的Master节点)
spec:
nodeName: k8s-master
containers:
- name: kubernetes-dashboard
image: k8s.gcr.io/kubernetes-dashboard-amd64:v1.10.1
ports:
- containerPort: 8443
protocol: TCP
具体解决地址:https://blog.csdn.net/0210/article/details/102523957
可以通过改yaml,设定dashboard的端口号以及使用nodePort访问
kind: Service
apiVersion: v1
metadata:
labels:
k8s-app: kubernetes-dashboard
name: kubernetes-dashboard
namespace: kube-system
spec:
type: NodePort
ports:
- port: 443
targetPort: 8443
selector:
k8s-app: kubernetes-dashboard
谷歌访问地址无效,可以通过在快捷方式后跟参数的方式解决,
C:\Users\zjh\AppData\Local\Google\Chrome\Application\chrome.exe --test-type --ignore-certificate-errors
安装最新版的dashboard ,它的namespace是kubernetes-dashboard 而不是旧版的kube-system 如果需要看状态和启动日志需要带上新的命名空间
后面具体研究下k8s的使用。
更多推荐
所有评论(0)