使用Ubuntu22+Minikube快速搭建K8S开发环境

2023-12-23 23:39:46

安装Vmware

这一步,可以参考我的如下课程。
在这里插入图片描述

安装Ubuntu22

下载ISO镜像

这里我推荐从清华镜像源下载,速度会快非常多。
下载地址:https://mirrors.tuna.tsinghua.edu.cn/ubuntu-releases/22.04.3/

如果你报名了我的这门视频课程,则相关资料我会提前给你准备好,不需要自己下载。

使用VMWare安装

详细步骤录制视频的时候忘了截图了,大家仔细看一遍视频跟着练一遍就可以了。下面这张图是等待安装时候的图片。
在这里插入图片描述

安装Minikube

下载

这里推荐从官网下载:https://minikube.sigs.k8s.io/docs/start/

在这里插入图片描述

将如下地址直接复制到浏览器或者迅雷进行下载会更快:https://storage.googleapis.com/minikube/releases/latest/minikube_latest_amd64.deb

如果你报名了本门课程,这个资料也会提前给你准备好,不需要自己手动下载。

Ubuntu22配置国内源

备份数据:

sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup

修改配置:

sudo vim /etc/apt/sources.list

替换为如下任何一个源都可以。

清华源:

# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-security main restricted universe multiverse

# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse

阿里源

deb http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse

中科大源

deb https://mirrors.ustc.edu.cn/ubuntu/ jammy main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ jammy main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ jammy-security main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ jammy-security main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse

网易163源

deb http://mirrors.163.com/ubuntu/ jammy main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ jammy-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ jammy-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ jammy-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ jammy-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ jammy main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ jammy-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ jammy-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ jammy-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ jammy-backports main restricted universe multiverse

Ubuntu22安装搜狗输入法

第一步:添加中文语言的支持。
第二步:安装fcitx

sudo apt update
sudo apt install fcitx

第三步:设置fcitx为系统输入法
第四步:设置fcitx开机启动,并卸载ibus输入法框架

sudo cp /usr/share/applications/fcitx.desktop /etc/xdg/autostart/
sudo apt remove --purge ibus

第五步:下载搜狗输入法 https://shurufa.sogou.com/linux
第六步:通过命令行安装搜狗输入法

sudo dpkg -i sogoupinyin_4.2.1.145_amd64.deb
sudo apt -f install

第七步:安装完毕后,还需要再安装一些搜狗输入法的依赖:

sudo apt install libqt5qml5 libqt5quick5 libqt5quickwidgets5 qml-module-qtquick2
sudo apt install libgsettings-qt1

第八步:注销计算机并重新登录即可正常使用搜狗输入法

Ubuntu22安装Docker

参考文档:https://docs.docker.com/desktop/install/ubuntu/

如果已经安装了docker,先卸载:

sudo systemctl stop docker
sudo apt-get autoremove docker docker-ce docker-engine  docker.io  containerd runc
sudo apt-get autoremove docker*

安装docker

sudo apt install docker.io

将当前用户添加到docker用户组,让当前用户可以正常执行docker命令:

sudo usermod -aG docker $USER

设置docker开机自动启动:

sudo systemctl enable docker

配置docker国内镜像:

# 编辑daemon.json
sudo vim /etc/docker/daemon.json
 
# 添加内容
{
    "registry-mirrors": [
        "https://registry.hub.docker.com",
        "http://hub-mirror.c.163.com",
        "https://mirror.baidubce.com",
        "https://docker.mirrors.sjtug.sjtu.edu.cn",
        "https://docker.nju.edu.cn"
    ]
}
 
# 重启docker
sudo systemctl restart docker

解决权限问题:

sudo chmod 777 /var/run/docker.sock

拉取redis镜像进行测试:

docker pull redis
docker images

安装minikube

将deb文件上传到一个Ubuntu的一个空目录中。

执行下面的命令安装:

sudo dpkg -i minikube_latest_amd64.deb

使用minikube启动k8s环境

默认配置启动:

minikube start

使用国内镜像加速启动:

minikube start --driver=docker --container-runtime=containerd --image-mirror-country=cn

配置kubectl别名

vim  ~/.bashrc 

# 添加
alias kubectl="minikube kubectl -- "

文章来源:https://blog.csdn.net/qq_37703224/article/details/135173651
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。