当前位置: 首页 > news >正文

如何做网站路径分析营销推广平台

如何做网站路径分析,营销推广平台,重庆网站建设维护,wordpress教程nginx环境 系统 : entOS Linux release 7.9.2009 (CoreIP:192.168.44.177 硬件要求:控制平面最少需要 2c2g 安装前环境准备 如果是集群部署还需要配置时间同步 关闭防火墙 systemctl disable firewalld关闭selinux setenforce 0sed -i s/SELI…

环境

  • 系统 : entOS Linux release 7.9.2009 (Core
  • IP:192.168.44.177

硬件要求:控制平面最少需要 2c2g

安装前环境准备

如果是集群部署还需要配置时间同步

  1. 关闭防火墙

     systemctl disable firewalld
    
  2. 关闭selinux

     setenforce 0sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config 
    
  3. 关闭swap分区

    如果没有开启swap分区可以跳过这步

     swapoff -a
    

    删除掉 /etc/fstab 有关swap分区的信息

  4. 设置主机名

     hostnamectl set-hostname k8s-mastersu 			# 可以直接切换到 新的主机名
    

开始安装容器运行时(containerd)
安装和配置先决条件

  1. 转发 IPv4 并让 iptables 看到桥接流量
cat <<EOF | sudo tee /etc/modules-load.d/k8s.conf
overlay
br_netfilter
EOF
sudo modprobe overlay
sudo modprobe br_netfilter
# 设置所需的 sysctl 参数,参数在重新启动后保持不变
cat <<EOF | sudo tee /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-iptables  = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.ipv4.ip_forward                 = 1
EOF
# 应用 sysctl 参数而不重新启动
sudo sysctl --system

通过运行以下指令确认 br_netfilter 和 overlay 模块被加载:

lsmod | grep br_netfilter
lsmod | grep overlay

通过运行以下指令确认 net.bridge.bridge-nf-call-iptables、net.bridge.bridge-nf-call-ip6tables 和 net.ipv4.ip_forward 系统变量在你的 sysctl 配置中被设置为 1:

sysctl net.bridge.bridge-nf-call-iptables net.bridge.bridge-nf-call-ip6tables net.ipv4.ip_forward

开始安装containerd容器运行时

https://github.com/containerd/containerd/blob/main/docs/getting-started.md#advanced-topics 官网安装指南
通常,您还必须 从其官方网站安装runcCNI 插件。

  1. 安装containerd
    下载安装包解压安装

安装包路径:https://github.com/containerd/containerd/releases
没有科学上网的话很慢,可以到我的网盘获取:链接:https://pan.baidu.com/s/1QakzbfaHM4bbyZ2MjRdIhQ
提取码:afh0

wget https://github.com/containerd/containerd/releases/download/v1.7.15/containerd-1.7.15-linux-amd64.tar.gz
tar Cxzvf /usr/local containerd-1.7.15-linux-amd64.tar.gz

使用systemd启动containerd
获取containerd.service文件

https://raw.githubusercontent.com/containerd/containerd/main/containerd.service

将containerd.service文件移动到 /usr/local/lib/systemd/system/ 目录下

如果/usr/local/lib/systemd/system/ 目录不存在则创建

mkdir -p  /usr/local/lib/systemd/system/
mv containerd.service /usr/local/lib/systemd/system/

重新加载systemd服务

containerd 的默认socket文件路径为 /run/containerd/containerd.sock
高版本的k8s现在默认都使用 containerd作为 容器运行时,包括现在使用的k8s1.28

systemctl daemon-reload
systemctl enable --now containerd
  1. 安装runc

下载地址:https://github.com/opencontainers/runc/releases

wget https://github.com/opencontainers/runc/releases/download/v1.1.12/runc.amd64
install -m 755 runc.amd64 /usr/local/sbin/runc
  1. 安装CNI插件

下载地址: https://github.com/containernetworking/plugins/releases

wget https://github.com/containernetworking/plugins/releases/download/v1.4.1/cni-plugins-linux-amd64-v1.4.1.tgz
mkdir -p /opt/cni/bin
tar Cxzvf /opt/cni/bin cni-plugins-linux-amd64-v1.4.1.tgz
  1. 修改containerd cgroup为 systemd

containerd 使用位于 的配置文件/etc/containerd/config.toml来指定守护进程级别选项。
使用二进制安装目录默认是没有,是需要自己手动创建。
默认配置可以通过 生成containerd config default > /etc/containerd/config.toml

mkdir  /etc/containerd/
containerd config default > /etc/containerd/config.toml
[root@k8s-master ~]# vim /etc/containerd/config.toml[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc.options]BinaryName = ""CriuImagePath = ""CriuPath = ""CriuWorkPath = ""IoGid = 0IoUid = 0NoNewKeyring = falseNoPivotRoot = falseRoot = ""ShimCgroup = ""SystemdCgroup = true			# 将flase 修改为 true
  1. 设置sandbox_image 镜像

默认配置为:sandbox_image = “registry.k8s.io/pause:3.8”
必须修改为你后面拉取pause镜像一致的版本和地址,后面将使用阿里云的镜像,所以这里可以提前写好。

[root@k8s-master ~]# vim /etc/containerd/config.tomlsandbox_image = "registry.aliyuncs.com/google_containers/pause:3.9"
  1. 重启containerd,使用上面两个修改生效

     systemctl restart containerd
    

安装k8s
这里使用阿里云的yum源进行安装目录最新的版本为1.28

  1. 配置yum源
cat >  /etc/yum.repos.d/kubernetes.repo << EOF
[kubernetes]
name=Kubernetes
baseurl=http://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=0
repo_gpgcheck=0
gpgkey=http://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpghttp://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
EOF
  1. 安装

     yum -y install kubeadm kubectl kubelet --disableexcludes=kubernetes
    
  2. 启动kubelet

     systemctl enable kubelet --now
    
  3. 使用 kubeadm 创建集群
    4.1. 修改初始集群默认配置文件

     kubeadm config print init-defaults > init-defaults.yaml
    
[root@k8s-master ~]# vim init-defaults.yaml
apiVersion: kubeadm.k8s.io/v1beta3
bootstrapTokens:
- groups:- system:bootstrappers:kubeadm:default-node-tokentoken: abcdef.0123456789abcdefttl: 24h0m0susages:- signing- authentication
kind: InitConfiguration
localAPIEndpoint:advertiseAddress: 192.168.44.177		# 集群宣告地址,k8smaster节点地址bindPort: 6443
nodeRegistration:criSocket: unix:///var/run/containerd/containerd.sock   # 容器运行时 sock文件地址,上面有提到imagePullPolicy: IfNotPresentname: k8s-master		# 节点名称taints: null
---
apiServer:timeoutForControlPlane: 4m0s
apiVersion: kubeadm.k8s.io/v1beta3
certificatesDir: /etc/kubernetes/pki
clusterName: kubernetes
controllerManager: {}
dns: {}
etcd:local:dataDir: /var/lib/etcd
imageRepository: registry.aliyuncs.com/google_containers		# 镜像拉取地址
kind: ClusterConfiguration
kubernetesVersion: 1.28.0
networking:dnsDomain: cluster.localserviceSubnet: 10.96.0.0/12podSubnet: 10.244.0.0/16		# pod地址,这里配置的地址范围和后面的网络插件的地址范围是一致的,注意一下。
scheduler: {}

4.2. 使用初始化配置文件拉取镜像

	kubeadm config images list --config=init-defaults.yaml # 查看需要哪些镜像kubeadm config images pull --config=init-defaults.yaml # 拉取镜像
[root@k8s-master ~]# kubeadm config images pull --config=init-defaults.yaml 
[config/images] Pulled registry.aliyuncs.com/google_containers/kube-apiserver:v1.28.0
[config/images] Pulled registry.aliyuncs.com/google_containers/kube-controller-manager:v1.28.0
[config/images] Pulled registry.aliyuncs.com/google_containers/kube-scheduler:v1.28.0
[config/images] Pulled registry.aliyuncs.com/google_containers/kube-proxy:v1.28.0
[config/images] Pulled registry.aliyuncs.com/google_containers/pause:3.9		# 回顾一下,这个pause镜像,在配置containerd使用的sandbox有使用到
[config/images] Pulled registry.aliyuncs.com/google_containers/etcd:3.5.9-0
[config/images] Pulled registry.aliyuncs.com/google_containers/coredns:v1.10.1

4.3. 初始化集群

kubeadm	init --config=init-defaults.yaml
Your Kubernetes control-plane has initialized successfully!		# 控制平面初始化成功To start using your cluster, you need to run the following as a regular user:mkdir -p $HOME/.kubesudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/configsudo chown $(id -u):$(id -g) $HOME/.kube/configAlternatively, if you are the root user, you can run:export KUBECONFIG=/etc/kubernetes/admin.confYou should now deploy a pod network to the cluster.
Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at:https://kubernetes.io/docs/concepts/cluster-administration/addons/Then you can join any number of worker nodes by running the following on each as root:kubeadm join 192.168.92.40:6443 --token abcdef.0123456789abcdef \--discovery-token-ca-cert-hash sha256:b31f38202281a96d1f721899dc56e95f770c7bbfea75b2b1076f1fed602e1318

4.4. 将kubectl证书添加到环境变量,否则你将无法使用kubectl命令
如果你是普通用户执行如下命令:

最好是添加到环境变量文件中,以免重启变量失效

mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

如果你是root用户执行如下

 export KUBECONFIG=/etc/kubernetes/admin.conf
  1. 安装网络插件

网络插件很多,作用都是为了让Pod之间可以互相通信,这里选择简单的三层网络flannel

kubectl apply -f https://github.com/flannel-io/flannel/releases/latest/download/kube-flannel.yml

扩展:
1) coredns依赖网络插件,如果没有网路插件coredns是无法启动
2)如果没有安装网络插件 node 的状态为noReady

到此k8s单节点就部署完成。

运行应用
由于k8s控制平面一般是不能调度Pod的,是因为master节点上被打上了污点,所以一般的Pod无法调度到k8s master节点。

查看节点上的污点

[root@k8s-master ~]# kubectl get node
NAME         STATUS   ROLES           AGE   VERSION
k8s-master   Ready    control-plane   16m   v1.28.2
[root@k8s-master ~]# kubectl describe node k8s-master | grep -i taint
Taints:             node-role.kubernetes.io/control-plane:NoSchedule

去除污点

[root@k8s-master ~]# kubectl taint node k8s-master node-role.kubernetes.io/control-plane:NoSchedule-
node/k8s-master untainted

运行应用
运行一个nginx,并将端口映射到主机端口

kubectl run nginx --image=nginx --labels="app=nginx" --port=80
kubectl expose pod nginx --port=80 --target-port=80  --labels="app=nginx" --type=NodePort
[root@k8s-master ~]# kubectl get pod
NAME    READY   STATUS    RESTARTS   AGE
nginx   1/1     Running   0          4m48s
[root@k8s-master ~]# kubectl get svc
NAME         TYPE        CLUSTER-IP    EXTERNAL-IP   PORT(S)        AGE
kubernetes   ClusterIP   10.96.0.1     <none>        443/TCP        36m
nginx        NodePort    10.97.129.0   <none>        80:31493/TCP   62s

service类型为 NodePort 将service端口随机映射到 所有主机上,默认范围在 30000-32767,以上是映射到了 31493端口上

在这里插入图片描述

http://www.tj-hxxt.cn/news/58207.html

相关文章:

  • wordpress轻物语主题湘潭seo优化
  • 专门做ppt的网站廊坊seo整站优化
  • 世界做诡异的地方网站黑帽seo排名技术
  • 商贸网站建设网站推广服务外包
  • 网站建设与管理实验大众网疫情最新消息
  • 遵义网站优化百度大数据分析
  • 手机网站建设 广州深圳关键词优化软件
  • 邱县手机网站建设seo网站优化经理
  • 推广优化厂商联系方式魔贝课凡seo
  • 仿牌网站空间百度seo和sem
  • 怎么做国外网站seo入门教程网盘
  • 动态网站建设与规划seo页面优化技术
  • 网站顶级导航制作方法便民信息微信平台推广
  • 做壁画在哪个网站比较好的友链平台
  • 开宾馆做独家网站好吗营销策划的六个步骤
  • 呼叫中心系统平台百度seo优化方法
  • 网站运行与维护北京软件开发公司
  • 汕头教育的网站建设免费网站开发平台
  • 有哪些做动图网站关键词优化排名怎么做
  • 安卓手机做网站专业网站优化公司
  • 中国建设银行官网站电话常见的系统优化软件
  • 邢台集团网站建设济宁百度竞价推广
  • 网站制作代理加盟珠海网络推广公司
  • 手机销售网站建设项目书网站流量查询平台
  • 黑黑网站如何搭建自己的网站
  • Spring做网站和什么网站推广的技巧
  • 素材网站怎么做大连seo
  • 网站维护报价单苏州网站外包
  • 大连网站优化方案宝鸡网站seo
  • 网站如何备案要关站吗上海有哪些优化网站推广公司