公告
由于博客进行大版本升级,导致博客部分文章存在乱码情况,请注意甄别...
恢复时间---待定
由于博客进行大版本升级,导致博客部分文章存在乱码情况,请注意甄别...
恢复时间---待定
cat
命令用来连接多个文件并打印到标准输出。
cat [OPTION]... [FILE]...
-
则读取标准输入。(长选项与短选项等价)
cp
命令用来将一个或多个源文件或者目录复制到指定的目的文件或目录。它可以将单个源文件复制成一个指定文件名的具体的文件或一个已经存在的目录下。cp
命令还支持同时复制多个文件,当一次复制多个文件时,目标文件参数必须是一个已经存在的目录,否则将出现错误。
find
命令用来在指定目录下查找文件。任何位于参数之前的字符串都将被视为欲查找的目录名。如果使用该命令时不设置任何参数,则 find
命令将在当前目录下查找子目录与文件,并将查找到的子目录和文件全部显示。
ls [选项] [文件名…]
[-1abcdfgiklmnopqrstuxABCDFGLNQRSUX] [-w cols] [-T cols] [-I pattern] [–full-time]
[–format={long,verbose,commas,across,vertical,single-col‐umn}]
[–sort={none,time,size,extension}] [–time={atime,access,use,ctime,status}]
[–color[={none,auto,always}]] [–help] [–version] [–]
mv
命令用于对文件或目录重新命名,或者将文件从一个目录移到另一个目录中。
|
|
|
|
将 /usr/men/ 目录中的所有文件移动到当前目录(用 . 表示)。
sudo apt-get update && sudo apt-get upgrade
sudo hostnamectl hostname ubuntu
# 安装
sudo apt-get install nfs4-acl-tools nfs-common -y
# 安装
sudo apt-get install qemu-guest-agent -y
# 启动-开机启动-查看状态
sudo systemctl enable qemu-guest-agent && sudo systemctl start qemu-guest-agent && sudo systemctl status qemu-guest-agent
sudo vim /etc/hosts
10.10.10.111 ubuntu Ubuntu
ulimit -SHn 65535
修改limits.conf文件
添加htlm-gitlab源
helm repo add gitlab https://charts.gitlab.cn
列出repo
helm repo list
创建空间
kubectl create namespace gitlab
修改gitlab-runner.yaml文件
sudo vim gitlab-runner.yaml
imagePullPolicy: IfNotPresent # 镜像拉取策略,IfNotPresent 表示如果本地有镜像则不拉取
concurrent: 5 # 同时运行的 Runner 数量
checkInterval: 30 # Runner 定期检查任务的时间间隔(秒)
logLevel: info # 日志级别
## Gitlab服务器地址
gitlabUrl: https://gitlab.hckz.top # Gitlab 服务的访问地址
## 注册token
runnerRegistrationToken: "glrt-t1_xxxxxxxxxxxxxxxx_7" # 用于注册 Runner 的 token
# 创建RBAC (角色访问控制)
rbac:
create: true # 是否创建 RBAC 资源
serviceAccount:
create: true # 是否创建服务账户
# 添加 hosts 文件解析配置
hostAliases:
- ip: "10.10.10.140" # 指定的 IP 地址
hostnames:
- "gitlab.hckz.top" # 与 IP 地址对应的主机名
runners:
config: |
[[runners]]
[runners.kubernetes]
namespace = "{{.Release.Namespace}}" # 指定运行器使用的命名空间
image = "ubuntu:20.04" # 指定 Pod 中使用的基础镜像
[[runners.kubernetes.host_aliases]]
ip = "10.10.10.140" # 指定 IP 地址
hostnames = ["gitlab.hckz.top"] # 与 IP 地址对应的主机名
[[runners.kubernetes.volumes.host_path]]
name = "docker" # 卷名称
mount_path = "/var/run/docker.sock" # 容器中挂载路径
host_path = "/var/run/docker.sock" # 主机上的路径
[runners.kubernetes.security_context]
run_as_user = 100 # 设置运行容器的用户 ID
fs_group = 65533 # 设置文件系统组 ID
securityContext:
runAsUser: 100 # 运行容器的用户 ID
fsGroup: 65533 # 文件系统组 ID
metrics:
enabled: false # 是否启用监控指标
安装命令
kubectl -n ingress-nginx get deployments.apps ingress-nginx-controller-nginx -o jsonpath='{.spec.template.spec.containers[0].image}' && echo
>> swr.cn-east-2.myhuaweicloud.com/kuboard-dependency/ingress-nginx:v1.0.0
kubectl -n ingress-nginx get deployments.apps ingress-nginx-controller-nginx -o jsonpath='{.metadata.labels.app\.kubernetes\.io\/version}' && echo
>> 1.0.0
kubectl -n calico-system get deployment calico-kube-controllers -o jsonpath='{.spec.template.spec.containers[0].image}' && echo
>> docker.io/calico/kube-controllers:v3.29.1
kubectl -n kube-system get cm kubeadm-config -o jsonpath='{.data.ClusterConfiguration}' | grep kubernetesVersion
>> kubernetesVersion: v1.31.3
kubectl version -o yaml
>>
clientVersion:
buildDate: "2024-11-19T13:51:52Z"
compiler: gc
gitCommit: c83cbee114ddb732cdc06d3d1b62c9eb9220726f
gitTreeState: clean
gitVersion: v1.31.3
goVersion: go1.22.8
major: "1"
minor: "31"
platform: linux/amd64
kustomizeVersion: v5.4.2
serverVersion:
buildDate: "2024-11-19T13:48:20Z"
compiler: gc
gitCommit: c83cbee114ddb732cdc06d3d1b62c9eb9220726f
gitTreeState: clean
gitVersion: v1.31.3
goVersion: go1.22.8
major: "1"
minor: "31"
platform: linux/amd64
系统检查升级:
|
|
配置主机名
|
|
安装nfs 安装nfs
|
|
qemu-guest-agent-虚拟机使用-非虚拟机可不用安装 安装qume
sudo apt-get update && sudo apt-get upgrade
sudo apt-get install cloud-init
sudo vim /etc/cloud/cloud.cfg
# /etc/cloud/cloud.cfg
# The top level settings are used as module
# and base configuration.
# 顶级设置用于模块和基本配置
# A set of users which may be applied and/or used by various modules
# when a 'default' entry is found it will reference the 'default_user'
# from the distro configuration specified below
# 定义要使用的用户配置,'default' 会引用下方 'default_user' 配置
users:
- default # 使用默认用户配置
# If this is set, 'root' will not be able to ssh in and they
# will get a message to login instead as the default $user
# 如果设置为 true,将禁用 root 用户的 SSH 登录
disable_root: true # 禁用 root 用户登录
# This will cause the set+update hostname module to not operate (if true)
# 如果为 true,主机名设置模块将不会操作
preserve_hostname: false # 保持主机名不变
# If you use datasource_list array, keep array items in a single line.
# If you use multi line array, ds-identify script won't read array items.
# Example datasource config
# 数据源配置示例
# datasource:
# Ec2:
# metadata_urls: [ 'blah.com' ]
# timeout: 5 # (defaults to 50 seconds)
# max_wait: 10 # (defaults to 120 seconds)
# The modules that run in the 'init' stage
# 在 'init' 阶段运行的模块
cloud_init_modules:
- seed_random # 生成随机数种子
- bootcmd # 执行引导时命令
- write_files # 写入文件
- growpart # 扩展磁盘分区
- resizefs # 调整文件系统大小
- disk_setup # 磁盘设置
- mounts # 挂载分区
- set_hostname # 设置主机名
- update_hostname # 更新主机名
- update_etc_hosts # 更新 /etc/hosts 文件
- ca_certs # 设置证书
- rsyslog # 启动 rsyslog 服务
- users_groups # 配置用户和组
- ssh # 配置 SSH 服务
- set_passwords # 设置用户密码
# The modules that run in the 'config' stage
# 在 'config' 阶段运行的模块
cloud_config_modules:
- wireguard # 配置 WireGuard VPN
- snap # 配置 snap 软件包
- ubuntu_autoinstall # 启用 Ubuntu 自动安装
- ssh_import_id # 从 ssh 密钥导入 ID
- keyboard # 设置键盘布局
- locale # 设置地区和语言环境
- grub_dpkg # 配置 GRUB 引导加载程序
- apt_pipelining # 启用 apt 管道
- apt_configure # 配置 apt
- ubuntu_pro # 配置 Ubuntu Pro 订阅
- ntp # 配置 NTP 时间同步
- timezone # 设置时区
- disable_ec2_metadata # 禁用 EC2 元数据(适用于非 EC2 环境)
- runcmd # 执行自定义命令
- byobu # 安装 Byobu 终端复用器
# The modules that run in the 'final' stage
# 在 'final' 阶段运行的模块
cloud_final_modules:
- package_update_upgrade_install # 更新并安装包
- fan # 配置风扇控制
- landscape # 配置 Landscape 管理工具
- lxd # 配置 LXD 容器
- ubuntu_drivers # 自动安装 Ubuntu 驱动
- write_files_deferred # 延迟写入文件
- puppet # 配置 Puppet 管理工具
- chef # 配置 Chef 管理工具
- ansible # 配置 Ansible 管理工具
- mcollective # 配置 MCollective 管理工具
- salt_minion # 配置 Salt Minion
- reset_rmc # 重置 RMC(远程管理控制)
- scripts_vendor # 执行厂商提供的脚本
- scripts_per_once # 执行一次性脚本
- scripts_per_boot # 每次启动时执行脚本
- scripts_per_instance # 每个实例执行脚本
- scripts_user # 执行用户自定义脚本
- ssh_authkey_fingerprints # 配置 SSH 密钥指纹
- keys_to_console # 将密钥传输到控制台
- install_hotplug # 安装热插拔设备
- phone_home # 向云服务发送信息
- final_message # 显示最终信息
- power_state_change # 处理电源状态变化
# System and/or distro specific settings
# 系统和/或发行版特定的设置
# (not accessible to handlers/transforms)
system_info:
# This will affect which distro class gets used
# 这将影响使用哪个发行版类
distro: ubuntu # 设置发行版为 Ubuntu
# Default user name + that default users groups (if added/used)
# 默认用户名和默认用户组
default_user:
name: ubuntu # 设置默认用户名为 ubuntu
lock_passwd: True # 锁定密码(禁止设置密码)
gecos: Ubuntu # 用户的 GECOS 字段(用于显示的名称)
groups: [adm, cdrom, dip, lxd, sudo] # 用户所属的组
sudo: ["ALL=(ALL) NOPASSWD:ALL"] # 允许该用户使用 sudo 执行任何命令,不需要密码
shell: /bin/bash # 设置用户默认的 shell 为 bash
network:
dhcp_client_priority: [dhcpcd, dhclient, udhcpc] # 设置 DHCP 客户端优先级
renderers: ['netplan', 'eni', 'sysconfig'] # 配置网络渲染器
activators: ['netplan', 'eni', 'network-manager', 'networkd'] # 网络激活器
# Automatically discover the best ntp_client
# 自动选择最合适的 NTP 客户端
ntp_client: auto # 自动选择 NTP 客户端
# Other config here will be given to the distro class and/or path classes
# 其他配置将传递给发行版类和/或路径类
paths:
cloud_dir: /var/lib/cloud/ # Cloud-init 数据存储目录
templates_dir: /etc/cloud/templates/ # 模板文件目录
# 配置包镜像源
package_mirrors:
- arches: [i386, amd64]
failsafe:
primary: http://repo.huaweicloud.com/ubuntu
security: http://repo.huaweicloud.com/ubuntu
search:
primary:
- http://repo.huaweicloud.com/ubuntu/
security: []
- arches: [arm64, armel, armhf]
failsafe:
primary: http://repo.huaweicloud.com/ubuntu-ports
security: http://repo.huaweicloud.com/ubuntu-ports
search:
primary:
- http://repo.huaweicloud.com/ubuntu-ports/
security: []
- arches: [default]
failsafe:
primary: http://repo.huaweicloud.com/ubuntu-ports
security: http://repo.huaweicloud.com/ubuntu-ports
ssh_svcname: ssh # SSH 服务名称
sudo cloud-init clean && sudo cloud-init init && sudo cloud-init modules --mode=config
reboot
sudo systemctl enable cloud-init && sudo systemctl start cloud-init && sudo cloud-init status
sudo hostnamectl hostname gitlab
10.10.10.130 gitlab GITLAB gitlab.hckz.top
sudo apt-get update && sudo apt-get upgrade
# 安装
sudo apt-get install qemu-guest-agent
# 启动-开机启动-查看状态
sudo systemctl enable qemu-guest-agent && sudo systemctl start qemu-guest-agent && sudo systemctl status qemu-guest-agent
sudo apt-get install nfs4-acl-tools nfs-common -y
sudo apt-get install -y conntrack ipvsadm ipset jq iptables curl sysstat wget vim net-tools git
sudo apt-get install -y curl openssh-server ca-certificates tzdata perl golang libc6 libnfs-utils libnfs-dev
ulimit -SHn 65535
sudo vim /etc/security/limits.conf
* soft nofile 655360
* hard nofile 131072
* soft nproc 655350
* hard nproc 655350
* seft memlock unlimited
* hard memlock unlimitedd
ulimit -a
sudo apt-get install chrony
备份原有配置
sudo mv /etc/chrony/chrony.conf /etc/chrony/chrony.conf.bak
修改配置文件