k8s生产趟坑中

本文详细介绍使用Vagrant和VirtualBox搭建Kubernetes集群的过程,包括节点的加入、配置、监控,以及常见问题的解决方法。深入探讨了如何指定IP和hostname,如何处理节点状态异常,以及如何使用metrics-server进行资源监控。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

虚拟机 virutalbox, vagrant

vagrant

https://www.vagrantup.com/
find boxes
如何制定ip?hostname?

加入子节点

sudo kubeadm token create --print-join-command

kubeadm join --token <token> <master-ip>:<master-port> --discovery-token-ca-cert-hash sha256:<hash>

token在master节点获取

kubeadm token list
kubeadm token create  过期后

hash值在 master 节点获取

openssl x509 -pubkey -in /etc/kubernetes/pki/ca.crt | openssl rsa -pubin -outform der 2>/dev/null | \
   openssl dgst -sha256 -hex | sed 's/^.* //'

如何找到master节点的ip和端口呢?

kubectl get node(s)

master节点notready,重启master节点https://blog.youkuaiyun.com/weixin_35494719/article/details/79890164

kubectl get pods -n kube-system -owide 在干吗

关闭swap

swapoff -a
https://github.com/kubernetes/kubeadm/issues/610

永久: 改/etc/fstab

遇到了该问题,但不懂怎么解决的

https://github.com/kubernetes/kubernetes/issues/65863
直接按这边这个执行的
https://blog.youkuaiyun.com/qq_21816375/article/details/81273201

journalctl -f -u kubelet

子节点notready

https://blog.youkuaiyun.com/qq_21816375/article/details/80222689

gc文档

https://kubernetes.io/docs/concepts/
中文 https://kubernetes.io/zh/docs/concepts/

journalctl -xefu kubelet

k8s Terminating 状态说明

Terminating的pod也会收到部分请求。

k8s集群-node节点设置不可调度或者删除node节点

1, 不可调度
kubectl cordon k8s-node-1
kubectl uncordon k8s-node-1 #取消

2,驱逐已经运行的业务容器

kubectl drain --ignore-daemonsets k8s-node-1

3,如果想删除node 节点,则进行这个步骤

kubectl delete node k8s-node-1

docker.io、gcr.io、quay.io镜像加速

Docker Hub 镜像加速器 registry-mirrors

将Dockerfile放在github, 让dockerhub自动构建, 在利用国内镜像pull.

保存及导入本地docker image镜像的方法 docker save/load

node/pod cpu/men监控(metrics-server)

https://blog.youkuaiyun.com/oyym_mv/article/details/87166639
https://github.com/kubernetes-sigs/metrics-server

After working at Red Hat for a few years, in late 2014 I was assigned to a newlyestablished team called Cloud Enablement. Our task was to bring the company’s range of middleware products to the OpenShift Container Platform, which was then being developed on top of Kubernetes. At that time, Kubernetes was still in its infancy—version 1.0 hadn’t even been released yet. Our team had to get to know the ins and outs of Kubernetes quickly to set a proper direction for our software and take advantage of everything Kubernetes had to offer. When faced with a problem, it was hard for us to tell if we were doing things wrong or merely hitting one of the early Kubernetes bugs. Both Kubernetes and my understanding of it have come a long way since then. When I first started using it, most people hadn’t even heard of Kubernetes. Now, virtually every software engineer knows about it, and it has become one of the fastestgrowing and most-widely-adopted ways of running applications in both the cloud and on-premises datacenters. In my first month of dealing with Kubernetes, I wrote a two-part blog post about how to run a JBoss WildFly application server cluster in OpenShift/Kubernetes. At the time, I never could have imagined that a simple blog post would ultimately lead the people at Manning to contact me about whether I would like to write a book about Kubernetes. Of course, I couldn’t say no to such an offer, even though I was sure they’d approached other people as well and would ultimately pick someone else. And yet, here we are. After more than a year and a half of writing and researching, the book is done. It’s been an awesome journey. Writing a book about a technology is absolutely the best way to get to know it in much greater detail than you’d learn as just a user. As my knowledge of Kubernetes has expanded during the process and Kubernetes itself has evolved, I’ve constantly gone back to previous chapters I’ve written and added additional information. I’m a perfectionist, so I’ll never really be absolutely satisfied with the book, but I’m happy to hear that a lot of readers of the Manning Early Access Program (MEAP) have found it to be a great guide to Kubernetes. My aim is to get the reader to understand the technology itself and teach them how to use the tooling to effectively and efficiently develop and deploy apps to Kubernetes clusters. In the book, I don’t put much emphasis on how to actually set up and maintain a proper highly available Kubernetes cluster, but the last part should give readers a very solid understanding of what such a cluster consists of and should allow them to easily comprehend additional resources that deal with this subject. I hope you’ll enjoy reading it, and that it teaches you how to get the most out of the awesome system that is Kubernetes.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值