首页 > 其他分享 >实践项目-模拟公司自动化运维

实践项目-模拟公司自动化运维

时间:2024-08-28 14:47:58浏览次数:8  
标签:node2 运维 etc 自动化 node1 docker k8s com 模拟

(20240828,准备更新PostgreSQL部分)

大纲

image
image

环境配置

系统:Debian 12.06
环境:阿里云ECS 以及 虚拟机

序号 IP地址 域名 主机名
1 192.168.100.12 k8s-master.yourname.com k8s-master
2 192.168.100.15 k8s-node1.yourname.com k8s-node1
3 192.168.100.16 k8s-node2.yourname.com k8s-node2
4 192.168.100.20 k8s-register.yourname.com k8s-register

VMware虚拟网络编辑器

image
image

ssh设置

sudo apt-get update && apt-get upgrade
sudo apt-get install vim

/etc/ssh/sshd_config

...
PermitRootLogin yes
PubkeyAuthentication no
...

master连通其他node

ssh-keygen -t rsa -b 2048
 for i in master node1 node2 register; do ssh-copy-id root@k8s-$i; done

静态IP设置
/etc/network/interfaces
其他主机修改IP即可

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

auto ens33
iface ens33 inet static
address 192.168.100.12
netmask 255.255.255.0
gateway 192.168.100.254
search localdomain
nameserver 8.8.8.8
nameserver 114.114.114.114
/etc/init.d/networking restart

主机名和域名
/etc/hostname

k8s-master

/etc/hosts

127.0.0.1       localhost
127.0.1.1       k8s01

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

192.168.100.12 k8s-master.yourname.com k8s-master
192.168.100.15 k8s-node1.yourname.com k8s-node1
192.168.100.16 k8s-node2.yourname.com k8s-node2
192.168.100.21 k8s-register.yourname.com k8s-register

用scp将hosts文件传输到node

for i in node1 node2 register; do scp /etc/hosts root@k8s-$i:/etc/hosts; done

关闭swap

for i in node1 node2 register; do swapoff -a; done
for i in node1 node2 register; do sed -i 's/.*swap.*/#&/' /etc/fstab; done

cat >> /etc/sysctl.d/k8s.conf << EOF
vm.swappiness=0
EOF

内核优化

cat << EOF | sudo tee /etc/sysctl.d/k8s.conf
net.ipv4.ip_forward = 1
EOF
for i in node1 node2 register; do sudo modprobe overlay; done
for i in node1 node2 register; do sudo modprobe br_netfilter; done
for i in node1 node2 register; do sysctl -p /etc/sysctl.d/k8s.conf; done

实践

域名DNS

用的是阿里云,我直接买了一个域名,但因为是个人服务器,不涉及商用没买SSL。
【阿里云-域名解析DNS01-简单介绍】 | chrisjing-com

Docker

sudo apt update
sudo apt install apt-transport-https ca-certificates curl software-properties-common
sudo curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://mirrors.aliyun.com/docker-ce/linux/debian $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

sudo apt update
sudo apt-get install docker-ce docker-ce-cli containerd.io
docker -v
docker compose version
cat > /etc/docker/daemon.json <<EOF
{
    "log-driver": "json-file",
    "log-opts": {
       "max-size": "20m",
       "max-file": "3"
    },
    "registry-mirrors": [
        "https://docker.m.daocloud.io",
        "https://dockerhub.icu",
        "https://docker.anyhub.us.kg",
        "https://docker.1panel.live"
    ]
}
EOF
systemctl daemon-reload
systemctl restart docker
systemctl enable docker

Nginx

mv default.conf default.conf.bak
touch default.conf
vim default.conf
server {
    listen 80;
    listen [::]:80;

    server_name example.com;

    access_log /var/log/nginx/access.log main;

    location / {
      proxy_pass http://127.0.0.1:8080/;
      rewrite ^/(.*)$ /$1 break;
      proxy_redirect off;
      proxy_set_header Host $host;
      proxy_set_header X-Forwarded-Proto $scheme;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header Upgrade-Insecure-Requests 1;
      proxy_set_header X-Forwarded-Proto https;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
      root   /usr/share/nginx/html;
    }
}

标签:node2,运维,etc,自动化,node1,docker,k8s,com,模拟
From: https://www.cnblogs.com/mugetsukun/p/18357404

相关文章

  • 8.28 模拟赛
    比赛复盘浏览所有题后发现所有题都是普及难度。A。数据范围这么小,暴力DP就行。不对\(10^{40}\)的答案……要高精度!!尝试了vector写高精乘发现异常简单。B。一年前我就能不看题解独立切。很快写完了。我清晰地记着分数加分数时分子分母要开__int128。C。又是小\({\Omega......
  • 数据库服务器运维最佳实践
    数据库服务器运维最佳实践  数据库服务器运维的最佳实践涵盖了多个方面,包括硬件选择、系统配置、性能优化、安全管理、数据备份与恢复、高可用性和灾难恢复等。以下将详细阐述这些方面,并给出部分可执行的代码示例,但请注意,由于环境差异,某些代码可能需要调整才能直接运行。1.......
  • 关于shadow-root影子控件的selenium ui自动化
    首先这个控件和iframe有异曲同工之妙,也是嵌套的一个html,所以定位不能像普通定位一样下面实践一下首先准备一个root.html<!DOCTYPEhtml><html><head><title>带有shadow-root的页面</title></head><body><h1class="test">带有shadow-root的页面</h1>......
  • 运维怎么转行网络安全?零基础入门到精通,收藏这一篇就够了
    经常有人问我:干网工、干运维多年遇瓶颈,想学点新技术给自己涨涨“身价”,应该怎么选择?聪明人早已经用脚投票:近年来,越来越多运维的朋友寻找新的职业发展机会,将目光聚焦到了网络安全产业。1、为什么我建议你学习网络安全?有一种技术人才:华为阿里平安等大厂抢着要,甚至高薪难求......
  • 【数据结构】关于二叉搜索树,你知道如何实现增删模拟吗???(超详解)
    前言:......
  • 8.26 模拟赛(NOIP十三连测 #7)
    2024--梦熊&太戈--NOIP十三连测#7【订正】-比赛-梦熊联盟(mna.wang)总结T1基本和CF1245F相同。很快就写完了。T2题意特别难懂,模拟了很长时间后题意还是有些晕,就先放弃了。T3相较于T2看上去简单的多,先冲T3。特殊性质\(A\)有\(50\)分,这可能是正解的关键。尝......
  • 模拟版图设计工程师要学些什么?从入门到入行,你想知道的都在这里了
    IC模拟版图设计是门槛最低的IC设计方向,最低专科学历即可,其他IC设计大多要求本科以上,研究生学历,0基础小白经过几个月的学习也可以入行。那么,待遇还不低的模拟版图设计工程师入行都要学一些什么?下面我们来聊一聊 版图学习最好有一些工艺的基础,了解MOS的基本工作原理,比如PN结......
  • 8.27 模拟赛(2019 CSP-S 真题)
    省流:预计\(40+0+15+0\),实际\(35+4+15+0\)。比赛复盘开局浏览题。A没太看懂(廊桥是什么?机场里有这玩意?);B题很好读懂,但没思路;C括号序列感觉可做;D一眼不会。除C外都感觉没太有戏。顺序开题。看懂A后,分析了一段时间后忘记了题面中“先到先得”的原则,导致推到一些歪的贪心浪......
  • 玄学乱搞算法——模拟退火,SA
    \(\texttt{0x00:}\)前言在此之前只对模拟退火的大名有所耳闻,但并未在我的认知上激起太大的风浪,直到……在外培的一场模拟赛上,队内大佬yyc在丝毫没有思路的情况下用SA骗了70pts,赛后使得给我们上课的清华姚班老师惊掉下巴。至此,在感叹SA的神力的同时,它也进入了我的学习计......
  • 自动化部署Mysql数据库的脚本
    #!/bin/bash#authorhlc#createTime2024-06-17#modifyTime2024-06-18#version1.0#description自动安装Mysqlsource/etc/init.d/functions#定义参数#用于循环count=0#时间date=$(date"+%H:%M:%S:%N")#==========Mysql服务器参数==========#Mysql服......