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
相关推荐
wuxingge8 小时前
k8s1.30.0高可用集群部署
云原生·容器·kubernetes
志凌海纳SmartX9 小时前
趋势洞察|AI 能否带动裸金属 K8s 强势崛起?
云原生·容器·kubernetes
锅总9 小时前
nacos与k8s service健康检查详解
云原生·容器·kubernetes
BUG弄潮儿9 小时前
k8s 集群安装
云原生·容器·kubernetes
颜淡慕潇11 小时前
【K8S系列】kubectl describe pod显示ImagePullBackOff,如何进一步排查?
后端·云原生·容器·kubernetes
Linux运维日记11 小时前
k8s1.31版本最新版本集群使用容器镜像仓库Harbor
linux·docker·云原生·容器·kubernetes
AI_小站13 小时前
RAG 示例:使用 langchain、Redis、llama.cpp 构建一个 kubernetes 知识库问答
人工智能·程序人生·langchain·kubernetes·llama·知识库·rag
长囧鹿16 小时前
云原生之k8s服务管理
云原生·容器·kubernetes
怡雪~17 小时前
centos7.9搭建k8s集群
云原生·容器·kubernetes
我要用代码向我喜欢的女孩表白21 小时前
k8s入门(不教部署,部署跟着文档来就行了)
云原生·容器·kubernetes