网站上线 流程,制作网站建设入门,大人小孩做网站,宁波网站建设-中国互联一、接9.11
19、部署calico的pod
4. 查看容器和节点状态
异常处理#xff1a; 出现Init:0/3#xff0c;查看node节点 /var/log/messages是否有除网络异常之外的报错信息 三台机器执行#xff1a;#xff08;更新版本#xff09; yum list kernel yum update kernel reb…一、接9.11
19、部署calico的pod
4. 查看容器和节点状态
异常处理 出现Init:0/3查看node节点 /var/log/messages是否有除网络异常之外的报错信息 三台机器执行更新版本 yum list kernel yum update kernel reboot 三台机器该目录下要有以下文件 reboot kubectl get po -A 查看没有pending状态就等待 [rootk8s-master ~]# kubectl get node NAME STATUS ROLES AGE VERSION
k8s-master Ready control-plane 18h v1.28.2
k8s-node1 Ready none 18h v1.28.2
k8s-node2 Ready none 18h v1.28.2 [rootk8s-master ~]# kubectl run nginx --imagenginx:latest //添加一个新的pod pod/nginx created [rootk8s-master ~]# kubectl run nginx0 --imagenginx [rootk8s-master ~]# kubectl get po -Aowide | grep nginx default nginx 1/1 Running 0 47m 172.16.169.130 k8s-node2 none none
default nginx1 1/1 Running 0 38m 172.16.169.129 k8s-node2 none none[rootk8s-master ~]# kubectl logs nginx //查看日志 [rootk8s-master ~]# curl 172.16.169.130 [rootk8s-master ~]# kubectl delete pod nginx [rootk8s-master ~]# kubectl delete pod nginx1 20、 资源监控Metrics 部署
1. 复制证书到所有节点 [rootk8s-master ~]# scp /etc/kubernetes/pki/front-proxy-ca.crt k8s-node1:/etc/kubernetes/pki/front-proxy-ca.crt [rootk8s-master ~]# scp /etc/kubernetes/pki/front-proxy-ca.crt k8s-node2:/etc/kubernetes/pki/front-proxy-ca.crt 2. 上传components.yaml文件 [rootk8s-master ~]# mkdir pods [rootk8s-master ~]# mv components.yaml pods/ [rootk8s-master ~]# cd pods/ [rootk8s-master pods]# ls components.yaml 3. 根据yaml文件创建pod [rootk8s-master pods]# kubectl create -f components.yaml 4. 查看pod列表状态 [rootk8s-master pods]# kubectl get pods -Aowide | grep metrics kube-system metrics-server-79776b6d54-rlw2j 1/1 Running 0 5m30s 172.16.36.65 k8s-node1 none none 5. 查看节点资源监控 [rootk8s-master pods]# kubectl top nodes NAME CPU(cores) CPU% MEMORY(bytes) MEMORY%
k8s-master 143m 7% 1103Mi 64%
k8s-node1 41m 2% 819Mi 47%
k8s-node2 45m 2% 858Mi 49% [rootk8s-master pods]# kubectl top pods -n kube-system //查看kube-system命名空间的所有节点 NAME CPU(cores) MEMORY(bytes)
calico-kube-controllers-6d48795585-dnwc4 2m 31Mi
calico-node-4dfpr 22m 124Mi
calico-node-64rzl 24m 103Mi
calico-node-t8l7f 22m 92Mi
coredns-6554b8b87f-4xzkp 1m 16Mi
coredns-6554b8b87f-ws7pj 1m 28Mi
etcd-k8s-master 17m 65Mi
kube-apiserver-k8s-master 51m 315Mi
kube-controller-manager-k8s-master 14m 86Mi
kube-proxy-hgn9q 1m 33Mi
kube-proxy-tshb8 1m 26Mi
kube-proxy-ww7k4 1m 36Mi
kube-scheduler-k8s-master 3m 43Mi
metrics-server-79776b6d54-rlw2j 3m 17Mi 21、Dashboard部署
1. 建⽴dashboard的pod资源 [rootk8s-master ~]# cd k8s-ha-install/ [rootk8s-master k8s-ha-install]# ls [rootk8s-master k8s-ha-install]# cd dashboard/ [rootk8s-master dashboard]# ls dashboard-user.yaml dashboard.yaml [rootk8s-master dashboard]# kubectl create -f . //使用当前目录 [rootk8s-master dashboard]# kubectl get po -A| grep dashboard 2. 设置svc模式 [rootk8s-master dashboard]# kubectl edit svc kubernetes-dashboard -n kubernetes-dashboard [rootk8s-master dashboard]# kubectl get svc kubernetes-dashboard -n kubernetes-dashboard //获取端口 NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes-dashboard NodePort 10.96.22.191 none 443:31282/TCP 8m48s 3. 获得token [rootk8s-master dashboard]# kubectl create token admin-user -n kube-system eyJhbGciOiJSUzI1NiIsImtpZCI6IlhPdHNYNThidExFTHNMNmR4QkRuMGd1TWhqd3VYaW9rc2lHN3o1Y2RMdDQifQ.eyJhdWQiOlsiaHR0cHM6Ly9rdWJlcm5ldGVzLmRlZmF1bHQuc3ZjLmNsdXN0ZXIubG9jYWwiXSwiZXhwIjoxNzI2MTE1NTA4LCJpYXQiOjE3MjYxMTE5MDgsImlzcyI6Imh0dHBzOi8va3ViZXJuZXRlcy5kZWZhdWx0LnN2Yy5jbHVzdGVyLmxvY2FsIiwia3ViZXJuZXRlcy5pbyI6eyJuYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsInNlcnZpY2VhY2NvdW50Ijp7Im5hbWUiOiJhZG1pbi11c2VyIiwidWlkIjoiYjRkZDAzZDMtNTk3Yy00YTEwLTg5MTUtMGJmYzJiOTBiODA1In19LCJuYmYiOjE3MjYxMTE5MDgsInN1YiI6InN5c3RlbTpzZXJ2aWNlYWNjb3VudDprdWJlLXN5c3RlbTphZG1pbi11c2VyIn0.cvypVYVBNb8CkvXZv1lZ8CXY7lIbzsvyFXK7ovke5uWpiBm8_3xNBwcxFUEA9nk2MuA36Ru2U9z6Qs2TJb06mPK308wu5GQIXAai3i5ABw5i5nkhDuKIoJpcyvnCALKPDDIg6oIp_BjnGzo8aTDiH6g53lGUKZHDBwfFehkVNucR2BvRny1yeBXWXpiyM4SHvyvCa0INtlDCSv4jkk8-ag_G8VRtxEE1LqO1I39dV8HUhBmC7_gKItrMaVmsGa3btkTuynGOqxHSP_DtHjVnQH8GiSyszqDceBVIqeWsULTZFUjBoR51Ef76Uxv2JqnYvgYOatbGU0bvu9k_BV0vvQ22、设置proxy的模式为ipvs
1. 编辑pod [rootk8s-master ~]# kubectl edit cm kube-proxy -n kube-system 2. 更新 Kube-Proxy 的 Pod [rootk8s-master ~]# kubectl patch daemonset kube-proxy -p {\spec\:{\template\:{\metadata\: {\annotations\:{\date\:\date %s\}}}}} -n kube-system daemonset.apps/kube-proxy patched 3. 访问测试 [rootk8s-master ~]# curl 127.0.0.1:10249/proxyMode ipvs 23、查看service pod 宿主机的网段 [rootk8s-master ~]# kubectl get svc NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE kubernetes ClusterIP 10.96.0.1 none 443/TCP 23h [rootk8s-master ~]# kubectl get pods -Aowide 24、验证是否可正常创建参数 [rootk8s-master ~]# kubectl create deploy cluster-test1 --imageregistry.cn-beijing.aliyuncs.com/dotbalo/debug-tools -- sleep 3600 [rootk8s-master ~]# kubectl get po [rootk8s-master ~]# kubectl get po -owidew 25、Pod 必须能够解析 Service
1. nslookup kubernetes [rootk8s-master ~]# kubectl exec -it cluster-test1-54575cf56c-65tv4 -- bash (07:39 cluster-test1-54575cf56c-65tv4:/) nslookup kubernetes Server: 10.96.0.10 Address: 10.96.0.10#53 Name: kubernetes.default.svc.cluster.local Address: 10.96.0.1 2. nslookup kube-dns.kube-system (07:39 cluster-test1-54575cf56c-65tv4:/) nslookup kube-dns.kube-system Server: 10.96.0.10 Address: 10.96.0.10#53 Name: kube-dns.kube-system.svc.cluster.local Address: 10.96.0.10 可以解析到server的第⼗个ip说明可以解析到kube-dns说 明跨namespace也可解析 26、 确认各 Pod 之间是否可正常通信 [rootk8s-master ~]# kubectl exec -it cluster-test1-54575cf56c-65tv4 -- bash (07:46 cluster-test1-54575cf56c-65tv4:/) ping 172.16.235.200 -c 3 PING 172.16.235.200 (172.16.235.200) 56(84) bytes of data. 64 bytes from 172.16.235.200: icmp_seq1 ttl62 time0.553 ms 64 bytes from 172.16.235.200: icmp_seq2 ttl62 time0.675 ms 64 bytes from 172.16.235.200: icmp_seq3 ttl62 time0.631 ms --- 172.16.235.200 ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2002ms rtt min/avg/max/mdev 0.553/0.619/0.675/0.058 ms 二、 kubernetes常用命令
1、kubernetes自动补齐 [rootk8s-master ~]# yum -y install bash-completion [rootk8s-master ~]# source (kubectl completion bash) //临时开启自动补齐功能 [rootk8s-master ~]# echo source (kubectl completion bash) ~/.bashrc //永久开启 2、基础命令
1. 创建 [rootk8s-master ~]# kubectl create namespace pes namespace/pes created [rootk8s-master ~]# kubectl get namespace NAME STATUS AGE
default Active 24h
kube-node-lease Active 24h
kube-public Active 24h
kube-system Active 24h
kubernetes-dashboard Active 4h41m
pes Active 38s 2. 删除 NAMESPACE NAME READY STATUS RESTARTS AGE
default cluster-test1-54575cf56c-65tv4 1/1 Running 0 24m
default clustertest-58dbff6c48-xbpvj 0/1 ErrImagePull 0 38m[rootk8s-master ~]# kubectl delete deployment clustertest //删除 3、编写yaml文件 [rootk8s-master ~]# vim pods/abc.yaml apiVersion: v1
kind: Pod
metadata:name: busybox-sleep
spec:containers:- name: busyboximage: busybox:1.28args:- sleep- 10004. kubectl create [rootk8s-master pods]# kubectl create -f abc.yaml [rootk8s-master pods]# kubectl get po -A | grep bus default busybox-sleep 0/1 ImagePullBackOff 0 11m [rootk8s-master pods]# kubectl delete pod busybox-sleep pod busybox-sleep deleted [rootk8s-master pods]# kubectl get po -A | grep bus