1、需要的工具
当前最新稳定版2303.3.0,
地址:https://coreos.com/releases/
下载地址: https://stable.release.core-os.net/amd64-usr/current/
启动镜像: coreos_production_iso_image.iso
安装包: coreos_production_image.bin.bz2
数字签名文件: coreos_production_image.bin.bz2.sig
配置文档生成器工具:Container Linux Config Transpiler(ct),
下载地址: https://github.com/coreos/container-linux-config-transpiler/releases
http服务器:nginx;
在web目录下创建以coreos版本号为名称的文件夹2303.3.0,放入安装包和签名文件;
2、准备ignition文件
首先生成密钥文件,ssh-keygen -t rsa,
复制id_rsa.pub中的内容(以ssh-rsa开头的字符串);
编写yaml文件(旧式的cloud init文件),最简单的配置文件如下:
passwd:
users:
- name: core
groups:
- wheel
- docker
ssh_authorized_keys:
- ssh-rsa ... (以ssh-rsa开头的字符串)
生成ignition文件(本例中为node0.json):
ct -in-file node0.yaml -out-file node0.json
把生成的node0.json复制到web目录;
3、开始安装
使用启动镜像启动(不支持UEFI,只能是BIOS);
切换到root账号: sudo su;
下载ignition文件: wget http://IP/.../node0.json
安装: coreos-install -d /dev/sda -i node0.json -b http://IP/...
参数说明:
-d device
-i ignition config
-b base url
安装完成,重启。
4、远程登录
eval $(ssh-agent)
ssh-add
ssh core@ip
5、使用技巧
在不重装的情况下重新配置CoreOS
- 在/boot/coreos 下,创建名为first_boot空文档;
- 使用新的ignition文件覆盖/usr/share/oem/config.ign;
- 重启;
/usr/share/oem/config.ign的内容是最初安装时ignition.json 的内容;
附本人使用的node0.yaml
# https://coreos.com/os/docs/2303.3.0/configuration.html
passwd:
users:
# 新建账号 core
- name: core
groups:
- wheel
- docker
ssh_authorized_keys:
- ssh-rsa ... (以ssh-rsa开头的字符串)
storage:
files:
# 修改计算机名为node0
- path: /etc/hostname
filesystem: root
contents:
inline: node0
mode: 0644
# 修改docker镜像地址
- path: /etc/docker/daemon.json
filesystem: root
contents:
inline: '{"registry-mirrors":["https://3ojlytcq.mirror.aliyuncs.com","https://docker.mirrors.ustc.edu.cn"]}'
mode: 0644
# 一些常用的alias
- path: /etc/bash/bashrc.d/alias
filesystem: root
contents:
inline: |
alias vi='vim'
alias ping='ping -c 4'
alias q='exit'
alias df='df -Th'
alias free='free -m'
alias ll='ls -lh'
alias hg='shutdown -h now'
mode: 0644
systemd:
units:
# 开机启动docker服务
- name: docker.service