Google-Compute-Engine

為什麼 CoreOS 不會自動啟動 etcd2,即使我的雲配置這麼說?

  • March 29, 2016

我在 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。我希望它更容易調試……

引用自:https://serverfault.com/questions/766760