基于Centos:服务器基础环境安装: JDK、Maven、Python、Go、Docker、K8s
创建用户。
·
创建用户
useradd dev
groupadd op
chown -R :op /opt
chmod -R 770 /opt
usermod -aG op dev
JDK8
yum install -y java-1.8.0-openjdk-devel
echo '
export JAVA_HOME=/usr/lib/jvm/java-1.8.0/
' >> /etc/profile
source /etc/profile
JDK11
yum install -y java-11-openjdk-devel.x86_64
echo '
export ES_JAVA_HOME=/usr/lib/jvm/java-11-openjdk-11.0.19.0.7-1.el7_9.x86_64
export LS_JAVA_HOME=/usr/lib/jvm/java-11-openjdk-11.0.19.0.7-1.el7_9.x86_64
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-11.0.19.0.7-1.el7_9.x86_64
' >> /etc/profile
source /etc/profile
maven
yum install -y maven
echo '<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<mirrors>
<mirror>
<id>ali-maven</id>
<mirrorOf>*</mirrorOf>
<name>ali mirror</name>
<url>https://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>
</mirrors>
</settings>' > /etc/maven/settings.xml
Python3
yum install -y python3 python3-pip
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
Go
yum install -y epel-release golang
go version
NodeJS
curl -sL https://rpm.nodesource.com/setup_14.x | sudo -E bash -
yum install -y nodejs
其它工具
yum install -y htop zip unzip git
Docker
yum -y remove docker-*
yum -y remove containerd*
rm -rf /var/lib/docker
yum list installed |grep docker
rpm -qa |grep docker
sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
sudo yum install -y yum-utils
sudo yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
sudo yum install -y docker-ce-20.10.1 docker-ce-cli-20.10.1 containerd.io docker-compose-plugin
sudo systemctl start docker
sudo systemctl enable docker
Kubernetes
首先设置hostname 和hosts文件
hostnamectl set-hostname master
hostnamectl set-hostname node01
hostnamectl set-hostname node02
echo '
172.17.12.218 master
172.17.12.216 node01
172.17.12.217 node02' >> /etc/hosts
配置防火墙和网络
systemctl stop firewalld && systemctl disable firewalld
sed -i 's/enforcing/disabled/' /etc/selinux/config && setenforce 0
swapoff -a
sed -ri 's/.*swap.*/#&/' /etc/fstab
cat > /etc/sysctl.d/k8s.conf << EOF
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
EOF
sysctl --system
安装kubeadm
cat > /etc/yum.repos.d/kubernetes.repo << EOF
[kubernetes]
name=Kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
enabled=1
gpgcheck=0
repo_gpgcheck=0
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
EOF
yum install -y kubelet-1.23.0 kubeadm-1.23.0 kubectl-1.23.0
systemctl enable kubelet
主节点初始化
kubeadm init \
--kubernetes-version 1.23.0 \
--apiserver-advertise-address=0.0.0.0 \
--service-cidr=10.96.0.0/16 \
--pod-network-cidr=10.244.0.0/16 \
--image-repository registry.aliyuncs.com/google_containers
主节点安装网络插件
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
从节点执行主节点初始化完成后输出的token信息加入主节点即可;
更多推荐
已为社区贡献2条内容
所有评论(0)