Minikube部署单节点Kubernetes

1.1 Minikube部署单节点K8s

  • Minikube是由Kubernetes社区维护的单机版的Kubernetes集群,支持macOS, Linux, andWindows等多种操作系统平台,使用最新的官方stable版本,并支持Kubernetes的大部分功能,从基础的容器编排管理,到高级特性如负载均衡、Ingress,权限控制等。非常适合作为Kubernetes入门,或开发测试环境使用。Minikube实际是跑在本地的虚拟机中的,所以,需要先安装一套Hypervisor。

  • 官方地址:minikube start | minikube

1.1.1 安装部署Docker-ce

复制代码
[root@minikube ~]# wget -O /etc/yum.repos.d/docker-ce.repo https://mirrors.huaweicloud.com/docker-ce/linux/centos/docker-ce.repo
[root@minikube ~]# sed -i 's+download.docker.com+mirrors.huaweicloud.com/docker-ce+' /etc/yum.repos.d/docker-ce.repo
[root@minikube ~]# sed -i 's/$releasever/7Server/g' /etc/yum.repos.d/docker-ce.repo
[root@minikube ~]# yum install docker-ce -y
[root@minikube ~]# tee /etc/docker/daemon.json <<-'EOF'
{
"exec-opts": ["native.cgroupdriver=systemd"],
"registry-mirrors": [
"https://dbckerproxy.com",
"https://hub-mirror.c.163.com",
"https://mirror.baidubce.com",
"https://ccr.ccs.tencentyun.com"
]
}
EOF
​
[root@minikube ~]# systemctl daemon-reload
[root@minikube ~]# systemctl enable --now docker.service
[root@minikube ~]# docker --version
Docker version 20.10.21, build baeda1f

1.1.2 安装Minikube

复制代码
[root@minikube ~]# wget -c https://storage.googleapis.com/minikube/releases/latest/minikube-latest.x86_64.rpm
[root@minikube ~]# yum install minikube-latest.x86_64.rpm -y
[root@minikube ~]# minikube version
minikube version: v1.33.1
commit: 5883c09216182566a63dff4c326a6fc9ed2982ff
[root@minikube ~]# curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
[root@minikube ~]# install minikube-linux-amd64 /usr/local/bin/minikube

1.1.3 禁用swap分区

复制代码
[root@minikube ~]# sed -i 's/.*swap.*/# &/' /etc/fstab
[root@minikube ~]# swapoff -a

1.1.4 安装kubectl

复制代码
[root@minikube ~]# curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl
[root@minikube ~]# chmod +x ./kubectl
[root@minikube ~]# mv kubectl /usr/local/bin/
[root@minikube ~]# kubectl version --client
Client Version: v1.30.1
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3

1.1.5 升级内核并配置参数

复制代码
[root@minikube ~]# cat > /etc/sysctl.d/kubernetes.conf <<EOF
net.bridge.bridge-nf-call-iptables=1
net.bridge.bridge-nf-call-ip6tables=1
net.ipv4.ip_forward=1
net.ipv4.tcp_tw_recycle=0
vm.swappiness=0
vm.overcommit_memory=1
vm.panic_on_oom=0
fs.inotify.max_user_instances=8192
fs.inotify.max_user_watches=1048576
fs.file-max=52706963
fs.nr_open=52706963
net.ipv6.conf.all.disable_ipv6=1
net.netfilter.nf_conntrack_max=2310720
EOF
​
[root@minikube ~]# sysctl -p /etc/sysctl.d/kubernetes.conf

1.1.6 安装cri-docker

复制代码
[root@minikube ~]# wget -c https://github.com/Mirantis/cri-dockerd/releases/download/v0.3.13/cri-dockerd-0.3.13-3.el7.x86_64.rpm
[root@minikube ~]# yum install cri-dockerd-0.3.13-3.el7.x86_64.rpm -y
[root@minikube ~]# sed -i 's#^ExecStart=.*#ExecStart=/usr/bin/cri-dockerd --network-plugin=cni --pod-infra-container-image=registry.aliyuncs.com/google_containers/pause:3.9#' /usr/lib/systemd/system/cri-docker.service
[root@minikube ~]# systemctl daemon-reload
[root@minikube ~]# systemctl restart docker
[root@minikube ~]# systemctl enable --now cri-docker.service

1.1.7 安装crictl

复制代码
[root@minikube ~]# VERSION="v1.30.0"
[root@minikube ~]# wget https://github.com/kubernetes-sigs/cri-tools/releases/download/$VERSION/crictl-$VERSION-linux-amd64.tar.gz
[root@minikube ~]# tar zxf crictl-$VERSION-linux-amd64.tar.gz -C /usr/bin
[root@minikube ~]# rm -f crictl-$VERSION-linux-amd64.tar.gz

1.1.8 启动minikube

复制代码
[root@minikube ~]# yum install conntrack -y
[root@minikube ~]# minikube start --vm-driver=none --image-mirror-country=cn --registry-mirror='https://ckdhnbk9.mirror.aliyuncs.com' --image-repository='registry.cn-hangzhou.aliyuncs.com/google_containers' --driver=docker --force

1.1.9 检查服务是否正常

复制代码
[root@minikube ~]# mv /root/.kube /root/.minikube $HOME
[root@minikube ~]# chown -R $USER $HOME/.kube $HOME/.minikube
[root@minikube ~]# kubectl get cs
Warning: v1 ComponentStatus is deprecated in v1.19+
NAME                 STATUS    MESSAGE   ERROR
controller-manager   Healthy   ok        
scheduler            Healthy   ok        
etcd-0               Healthy   ok        
​
[root@minikube ~]# kubectl get node
NAME       STATUS   ROLES           AGE   VERSION
minikube   Ready    control-plane   22m   v1.30.0
[root@minikube ~]# minikube status
minikube
type: Control Plane
host: Running
kubelet: Running
apiserver: Running
kubeconfig: Configured
​
[root@minikube ~]# kubectl get pod -n kube-system
NAME                               READY   STATUS             RESTARTS        AGE
coredns-7db6d8ff4d-7ztfs           1/1     Running            1 (84s ago)    22m
etcd-minikube                      1/1     Running            1 (9m45s ago)   22m
kube-apiserver-minikube            1/1     Running            1 (3m20s ago)   22m
kube-controller-manager-minikube   1/1     Running            1 (9m45s ago)   22m
kube-proxy-dfqnf                   1/1     Running            1 (9m45s ago)   22m
kube-scheduler-minikube            1/1     Running            1 (9m45s ago)   22m
storage-provisioner                1/1     Running            3 (2m34s ago)   22m
相关推荐
景天科技苑9 小时前
【云原生开发】K8S多集群资源管理平台架构设计
云原生·容器·kubernetes·k8s·云原生开发·k8s管理系统
wclass-zhengge10 小时前
K8S篇(基本介绍)
云原生·容器·kubernetes
颜淡慕潇10 小时前
【K8S问题系列 |1 】Kubernetes 中 NodePort 类型的 Service 无法访问【已解决】
后端·云原生·容器·kubernetes·问题解决
昌sit!18 小时前
K8S node节点没有相应的pod镜像运行故障处理办法
云原生·容器·kubernetes
A ?Charis21 小时前
Gitlab-runner running on Kubernetes - hostAliases
容器·kubernetes·gitlab
北漂IT民工_程序员_ZG1 天前
k8s集群安装(minikube)
云原生·容器·kubernetes
2301_806131361 天前
Kubernetes的基本构建块和最小可调度单元pod-0
云原生·容器·kubernetes
SilentCodeY1 天前
containerd配置私有仓库registry
容器·kubernetes·containerd·镜像·crictl
binqian1 天前
【k8s】ClusterIP能http访问,但是不能ping 的原因
http·容器·kubernetes
探索云原生2 天前
GPU 环境搭建指南:如何在裸机、Docker、K8s 等环境中使用 GPU
ai·云原生·kubernetes·go·gpu