我在 Google Compute Engine 实例上运行 CoreOS beta 991.1.0,其中 cloud-config 通过user_data
元数据变量进行配置。我的云配置如下所示:
#cloud-config
write_files:
- path: "/etc/kubernetes/kube.conf"
permissions: "0644"
owner: "root"
content: |
apiVersion: v1
kind: Config
clusters:
- name: kube
cluster:
server: https://127.0.0.1:443
certificate-authority: /etc/kubernetes/ssl/ca.pem
users:
- name: kubelet
user:
client-certificate: /etc/kubernetes/ssl/master-client.pem
client-key: /etc/kubernetes/ssl/master-client-key.pem
contexts:
- context:
cluster: kube
user: kubelet
ssh_authorized_keys:
- "SECRET"
coreos:
etcd2:
discovery: https://discovery.etcd.io/106b575a45f2abefdaea40ebba4d0d84
initial-advertise-peer-urls: https://$private_ipv4:2380
listen-peer-urls: https://$private_ipv4:2380
listen-client-urls: https://0.0.0.0:2379
advertise-client-urls: https://$private_ipv4:2379
units:
- name: etcd2.service
command: start
drop-ins:
- name: 30-certificates.conf
content: |
[Service]
# Client Env Vars
Environment=ETCD_TRUSTED_CA_FILE=/etc/kubernetes/ssl/ca.pem
Environment=ETCD_CERT_FILE=/etc/kubernetes/ssl/master-client.pem
Environment=ETCD_KEY_FILE=/etc/kubernetes/ssl/master-client-key.pem
# Peer Env Vars
Environment=ETCD_PEER_TRUSTED_CA_FILE=/etc/kubernetes/ssl/ca.pem
Environment=ETCD_PEER_CERT_FILE=/etc/kubernetes/ssl/master-peer.pem
Environment=ETCD_PEER_KEY_FILE=/etc/kubernetes/ssl/master-peer-key.pem
- name: fleet.service
command: start
- name: swap.service
command: start
content: |
[Unit]
Description=Turn on swap
[Service]
Type=oneshot
Environment="SWAPFILE=/swap"
RemainAfterExit=true
ExecStartPre=/usr/sbin/losetup -f $SWAPFILE
ExecStart=/usr/bin/sh -c "/sbin/swapon $(/usr/sbin/losetup -j $SWAPFILE | /usr/bin/cut -d : -f 1)"
ExecStop=/usr/bin/sh -c "/sbin/swapoff $(/usr/sbin/losetup -j $SWAPFILE | /usr/bin/cut -d : -f 1)"
ExecStopPost=/usr/bin/sh -c "/usr/sbin/losetup -d $(/usr/sbin/losetup -j $SWAPFILE | /usr/bin/cut -d : -f 1)"
[Install]
WantedBy=local.target
但是,即使我已将 etcd2 配置为在启动时启动,它也没有。为什么 etcd2 不会自动启动?
错误就像命名 GCE 元数据变量一样简单
user_data
,但它应该是user-data
。我希望它更容易调试......