Centos7.6部署minikube

news/2024/9/24 3:29:00/

1、什么是minikube ?

Minikube是由Kubernetes社区维护的单机版的Kubernetes集群,支持macOS, Linux, and Windows等多种操作系统平台,使用最新的官方stable版本,并支持Kubernetes的大部分功能,从基础的容器编排管理,到高级特性如负载均衡、Ingress,权限控制等。非常适合作为Kubernetes入门,或开发测试环境使用。
安装k8s的麻烦就不用多说了,而且特别容易出错,烦的很,minikube部署简单可以用来测试学习用。

2、minikube安装

1、准备环境

一台装centos7.6的服务器
docker

安装最新 docker

yum install -y yum-utils  device-mapper-persistent-data lvm2
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum list docker-ce --showduplicates | sort -r
sudo yum -y install docker-ce docker-ce-cli containerd.io docker-compose-plugin
sudo systemctl start docker && systemctl enable docker

2 配置镜像源

cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
EOF

3、安装kubectl

curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
chmod +x ./kubectl
mv ./kubectl /usr/local/bin/kubectl

4、安装minukube

curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 
chmod +x minikube
mv minikube /usr/local/bin/

5、启动集群

新建一个普通用户,否则会提示The “docker” driver should not be used with root privileges.

useradd ops -G docker
echo "123456" | passwd --stdin ops
#Changing password for user ops.
su  ops

启动本地k8s集群

[ops@VM-0-8-centos ~]$ minikube start
* minikube v1.23.2 on Centos 7.6.1908 (amd64)
* Automatically selected the docker driver
* Starting control plane node minikube in cluster minikube
* Pulling base image ...
* Downloading Kubernetes v1.22.2 preload ...> preloaded-images-k8s-v13-v1...: 511.69 MiB / 511.69 MiB  100.00% 10.70 Mi> index.docker.io/kicbase/sta...: 355.39 MiB / 355.40 MiB  100.00% 5.06 MiB
! minikube was unable to download gcr.io/k8s-minikube/kicbase:v0.0.27, but successfully downloaded docker.io/kicbase/stable:v0.0.27 as a fallback image
* Creating docker container (CPUs=2, Memory=2200MB) ...
! This container is having trouble accessing https://k8s.gcr.io
* To pull new external images, you may need to configure a proxy: https://minikube.sigs.k8s.io/docs/reference/networking/proxy/
* Preparing Kubernetes v1.22.2 on Docker 20.10.8 ...- Generating certificates and keys ...- Booting up control plane ...- Configuring RBAC rules ...
* Verifying Kubernetes components...- Using image gcr.io/k8s-minikube/storage-provisioner:v5
* Enabled addons: default-storageclass, storage-provisioner
* Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default

6、查看minikube状态

[ops@VM-0-8-centos ~]$ minikube status
minikube
type: Control Plane
host: Running
kubelet: Running
apiserver: Running
kubeconfig: Configured

3、配置可视化面板

minikube dashboard --url
* Enabling dashboard ...
* Verifying dashboard health ...
* Launching proxy ...
* Verifying proxy health ...
http://127.0.0.1:33457/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/

开启kube-proxy端口映射,使其可以远程访问

kubectl proxy --port=30030 --address='0.0.0.0' --accept-hosts='^.*' &

http://127.0.0.1:30030/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/

启动minikube start的坑点

问题1:无法使用root启动

[root@VM-16-14-centos bin]# minikube start
* Centos 7.8.2003 上的 minikube v1.13.0
* Automatically selected the docker driver
* The "docker" driver should not be used with root privileges.
* If you are running minikube within a VM, consider using --driver=none:
*   https://minikube.sigs.k8s.io/docs/reference/drivers/none/X Exiting due to DRV_AS_ROOT: The "docker" driver should not be used with root privileges.

问题1:解决方法
因为我是用root账号登录操作的。所以提示不能用root账号启动,得用别的账号。所以要创建一个新的账号进行操作,创建一个test账号进行启动

adduser test
passwd test

问题2:minikube需要docker组启动

[test@VM-16-14-centos ~]$ minikube start --driver=docker
* Centos 7.8.2003 上的 minikube v1.13.0
* 根据用户配置使用 docker 驱动程序X Exiting due to PROVIDER_DOCKER_ERROR: "docker version --format -" exit status 1: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.40/version: dial unix /var/run/docker.sock: connect: permission denied
* 建议:Add your user to the 'docker' group: 'sudo usermod -aG docker $USER && newgrp docker'
* 文档:https://docs.docker.com/engine/install/linux-postinstall/

问题2:解决方法

#创建docker组
sudo groupadd docker
#将您的用户添加到该docker组
sudo usermod -aG docker $USER
#在Linux上,运行以下命令来激活对组的更改
newgrp docker

问题3:root账号启动docker导致无法启动

还是问题2的显示

问题3:解决办法:
先用root用户关闭docker,然后用test用户启动docker即可
docker启动和关闭命令

systemctl start docker 
systemctl stop docker

启动minikube,举例启动一个nginx

先准备一个nginx的yaml文件,名字为nginx-deployment.yaml
内容如下:

apiVersion: apps/v1
kind: Deployment
metadata:name: nginx-deployment
spec:selector:matchLabels:app: nginxreplicas: 2template:metadata:labels:app: nginxspec:containers:- name: nginximage: nginx:1.7.9ports:- containerPort: 80

启动minikube并且启动nginx

minikube start --driver=docker
kubectl create -f nginx-deployment.yaml
[test@VM-16-14-centos ~]$ kubectl get pods -l app=nginx
NAME                                READY   STATUS    RESTARTS   AGE
nginx-deployment-5d59d67564-k6q76   1/1     Running   0          84s
nginx-deployment-5d59d67564-sgzjw   1/1     Running   0          84s


http://www.ppmy.cn/news/1424961.html

相关文章

Apache Storm的详细配置

Apache Storm的详细配置主要涉及以下几个方面: Zookeeper配置:Apache Storm使用Zookeeper来进行协调和配置管理。你需要配置Zookeeper集群的连接信息,包括Zookeeper服务器的主机和端口。 Storm Nimbus配置:Nimbus是Storm的主节点,负责分配任务给各个工作节点。你需要配置N…

fatal: Out of memory, malloc failed

git 切分支&#xff0c;或者clone仓库的时候碰到这个错误&#xff0c;看网上很多配置config文件&#xff0c;都尝试了没效果。 自测了一个可行的方式&#xff1a; 由于本人用的sourcetree 所以解决方式如下&#xff1a; git升级为最新版&#xff0c;选择系统GIt版本&#xf…

vue对比功能,实现竖向table,可多列数据对比

一、实现效果 二、具体代码 1、页面代码 <template><div class"app-container"><el-row><!--列表选择--><el-col :span"6" :xs"24"><div class"tac"><div style"display: inline-block;…

Python 天气预测

Python天气预测通常涉及到数据采集、数据预处理、选择和训练模型、以及预测和可视化等步骤。以下是使用Python进行天气预测的一般流程&#xff1a; 数据采集 使用爬虫技术从天气网站&#xff08;如Weather Underground、中国天气网等&#xff09;爬取历史天气数据&#xff0c…

mysql 如何查看一条SQL被回滚了

MySQL中查看一条SQL是否被回滚&#xff0c;通常不是一个直接的过程&#xff0c;因为MySQL本身并不提供直接的方式来追踪单个SQL语句的执行和回滚情况。但是&#xff0c;你可以通过一些方法和工具来间接地达到这个目的。下面&#xff0c;我将从多个角度介绍如何分析和判断SQL语句…

AItoolchain相关技术学习

AItoolchain主要模块包括&#xff1a; 模型转换&#xff1a;将深度学习模型转换为特定硬件平台可以识别和执行的格式。嵌入式运行环境&#xff1a;提供异构模型的运行库支持&#xff0c;确保模型在目标设备上的运行效率。性能验证&#xff1a;包括静态和动态性能评估&#xff…

死磕GMSSL通信-C/C++系列(一)

死磕GMSSL通信-C/C++系列(一) 最近再做国密通信的项目开发,以为国密也就简单的集成一个库就可以完事了,没想到能有这么多坑。遂写下文章,避免重复踩坑。以下国密通信的坑有以下场景 1、使用GMSSL guanzhi/GmSSL进行通信 2、使用加密套件SM2-WITH-SMS4-SM3 使用心得 ​…

ssm420基于JavaEE的企业人事管理信息系统的设计与实现论文

摘 要 现代经济快节奏发展以及不断完善升级的信息化技术&#xff0c;让传统数据信息的管理升级为软件存储&#xff0c;归纳&#xff0c;集中处理数据信息的管理方式。本企业人事管理信息系统就是在这样的大环境下诞生&#xff0c;其可以帮助管理者在短时间内处理完毕庞大的数据…