操作系统
utuntu 22.04.3
//记得添加host配置,karma 是我的主机名,可根据自己的修改
vim /etc/hosts
192.168.9.15 karma
本机环境
su root
//更新软件源
sudo apt update
//升级软件源
sudo apt upgrade
//安装网络
apt install ifupdown
apt install network-manager
apt install net-tools
//开启时间同步
sudo apt install ntp
sudo systemctl status ntp
sudo systemctl start ntp
sudo systemctl enable ntp
date
//设置时区
sudo timedatectl set-timezone Asia/Shanghai
安装docker
//安装证书
apt-get install ca-certificates curl gnupg lsb-release
//安装证书
curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
//设置阿里云
sudo add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
//安装docker最新版
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
//当前用户加入docker组
sudo usermod -aG docker $USER
//启动docker
systemctl start docker
//安装工具
apt-get -y install apt-transport-https ca-certificates curl software-properties-common
//重启
service docker restart
//测试
sudo docker run hello-world
//查看版本
sudo docker version
//查看镜像
sudo docker images
//从阿里云镜像获取
登录阿里云,在控制台中搜索:容器镜像服务
获得:https://xxxx.mirror.aliyuncs.com
//镜像加速
https://kubesphere.io/zh/docs/v3.4/faq/installation/configure-booster/
sudo mkdir -p /etc/docker
sudo vi /etc/docker/daemon.json
{
"registry-mirrors": ["https://xxxx.mirror.aliyuncs.com"]
}
sudo systemctl daemon-reload
sudo systemctl restart docker
k8s 前置
//安装必要工具
sudo apt install ebtables socat conntrack ipset
//下载kk
https://github.com/kubesphere/kubekey/releases/download/v3.2-alpha.1-console/kubekey-v3.2-alpha.1-console-linux-amd64.tar.gz
tar -zxvf 'kubekey-v3.2-alpha.1-console-linux-amd64 (1).tar.gz'
//授权
chmod +x kk
//设置中国区域
export KKZONE=cn
单节点安装allinone
参考:https://kubesphere.io/zh/docs/v3.4/quick-start/all-in-one-on-linux/
//设置中国区域
export KKZONE=cn
//安装
./kk create cluster --with-kubernetes v1.22.12 --with-kubesphere v3.4.0
//查看日志
kubectl logs -n kubesphere-system $(kubectl get pod -n kubesphere-system -l 'app in (ks-install, ks-installer)' -o jsonpath='{.items[0].metadata.name}') -f
多节点安装
·
参考:https://kubesphere.io/zh/docs/v3.4/installing-on-linux/introduction/multioverview/
//设置中国区域
export KKZONE=cn
//创建配置文件
./kk create config --with-kubesphere v3.4.0 --with-kubernetes v1.22.12
./kk create config --with-kubesphere v3.3.2 --with-kubernetes v1.23.7
//配置参考官网即可
//安装
./kk create cluster -f config-sample.yaml
程序会自动把当前节点的主机名设置为当前登录主机名,记得加ip映射,然后重启,比当前节点名称masternode,要在/etc/hosts 添加 192.168.9.15 masternode
config-sample.yaml(其余部分保持默认),
spec:
hosts:
- {name: masternode, address: 192.168.9.15, internalAddress: 192.168.9.15, user: karma, password: "5C35BA0F86A595CE83B955FF679BAF3B"}
roleGroups:
etcd:
- masternode
control-plane:
- masternode
worker:
- masternode
nginx配置
server {
listen 8080;
server_name 192.168.9.15;
location / {
proxy_pass http://192.168.9.15:30880;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
location /login {
proxy_pass http://192.168.9.15:30880/login;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
nginx配置主机ssh 22端口映射
stream {
server {
listen 8081;
proxy_pass localhost:22;
}
}
卸载
./kk delete cluster
./kk delete cluster [-f config-sample.yaml]