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
相关推荐
敲上瘾12 小时前
【探索实战】:Kurator分布式统一应用分发平台的全面解析与实践指南
分布式·容器·kubernetes·serverless
Connie14511 天前
记一次K8s故障告警排查(Grafna告警排查)
云原生·容器·kubernetes·grafana
谷隐凡二1 天前
Kubernetes主从架构简单解析:基于Python的模拟实现
python·架构·kubernetes
陈陈CHENCHEN1 天前
SuperMap iManager for K8s 离线环境镜像仓库 Containerd 部署
kubernetes
会飞的小蛮猪1 天前
Ubuntu24.04 基于Containerd部署K8s1.34(私服部署)
docker·云原生·kubernetes
间彧2 天前
Kubernetes滚动发布详解
kubernetes
间彧2 天前
在实际生产环境中,Kubernetes声明式API如何实现蓝绿部署、金丝雀发布等高级部署策略?
kubernetes
间彧2 天前
Kubernetes声明式API相比传统命令式API在故障恢复场景下的具体优势有哪些?
kubernetes·github
间彧2 天前
为什么说Kubernetes的API设计是其成功的关键因素之一?
kubernetes
间彧2 天前
Kubernetes Deployment 配置简化实战:从复杂到高效
kubernetes