CoreOS 配置工具已由 Ignition
代替 cloud-config
。
GitHub:https://github.com/coreos/ignition
使用 Ignition
需要两步:
Container Linux Config
( yaml
格式 )
container-linux-config-transpiler
将 Container Linux Config
转化为 Ignition Config
(json
格式)
$ ct-v0.5.0-x86_64-apple-darwin -in-file ignition.yaml > ignition.json
container-linux-config-transpiler
安装方法:
在 https://github.com/coreos/container-linux-config-transpiler/releases 下载二进制文件移入 PATH
,并赋予可执行权限之后即可使用。
官方文档:https://coreos.com/os/docs/latest/overview-of-ct.html
etcd:
name: coreos3
discovery: https://discovery.etcd.io/249ea9815631abc753fe4a4743f147d2
advertise_client_urls: http://192.168.57.102:2379
initial_advertise_peer_urls: http://192.168.57.102:2380
listen_client_urls: http://192.168.57.102:2379,http://0.0.0.0:4001
listen_peer_urls: http://0.0.0.0:2380
通过与网络接口名称( enp0s3
等)匹配来设置静态或动态 IP 地址
networkd:
units:
- name: 10-static.network
contents: |
[Match]
Name=enp0s3
[Network]
Address=192.168.57.102/24
- name: 20-dhcp.network
contents: |
[Match]
Name=enp0s8
[Network]
DHCP=yes
passwd:
users:
- name: core
ssh_authorized_keys:
- ssh-rsa SSH_PUB
groups:
- wheel
- sudo
- docker
systemd:
units:
- name: settimezone.service
enable: true
contents: |
[Unit]
Description=Set the time zone
[Service]
ExecStart=/usr/bin/timedatectl set-timezone PRC
RemainAfterExit=yes
Type=oneshot
storage:
files:
- filesystem: "root"
path: "/etc/hostname"
mode: 0644
contents:
inline: coreos3
- filesystem: "root"
path: "/etc/resolv.conf"
mode: 0644
contents:
inline: |
nameserver 114.114.114.114
https://github.com/khs1994-docker/coreos/blob/master/disk/ignition-1.example.yaml