k8s-離線安裝coreos

1.安裝準備javascript

 

下載isohtml

前往頁面https://coreos.com/os/docs/latest/booting-with-iso.htmljava

版本:stable 1465.7.0python

日期:2017.09.26json

 

準備ignition.jsonbash

{
  "ignition": {
    "version": "2.0.0",
    "config": {}
  },

  "storage": {
    "files": [
      {
        "filesystem": "root",
        "path": "/etc/hostname",
        "contents": {
          "source": "data:,systech01",
          "verification": {}
        },
        "mode": 420,
        "user": {},
        "group": {}
      },{
        "filesystem": "root",
        "path": "/etc/hosts",
        "contents": {
          "source": "data:,127.0.0.1%09localhost%0A127.0.0.1%20systech01",
          "verification": {}
        },
        "mode": 420,
        "user": {},
        "group": {}
      }     
    ]
  },
  "systemd": {
    "units": [
      {
        "name": "settimezone.service",
        "enable": true,
        "contents": "[Unit]\nDescription=time zone Asia/Shanghai\n[Service]\nExecStart=/usr/bin/timedatectl set-timezone Asia/Shanghai\nRemainAfterExit=yes\nType=oneshot  \n[Install]\nWantedBy=multi-user.target   \n"
      }
    ]
  },
  "networkd": {
    "units": [
      {
        "name": "00-static.network",
        "contents": "[Match]\nName=eth0\n\n[Network]\nDNS=192.168.3.1\nAddress=192.168.3.101/24\nGateway=192.168.3.1\nDHCP=no      \n"
      }
    ]
  },

  "passwd": {
    "users": [
      {
        "name": "core",
        "sshAuthorizedKeys": [
          "ssh-rsa AAAAB3NzaC1yc2EAAAADAQA...kYoT8jhrw== mengkzhaoyun@gmail.com"
        ]
      },{
        "name": "root",
        "passwordHash ": "$1$maTXmv6V$4UuGlRDpBZtipAhlPZ2/J0"
      }
    ]
  }
}
  • /etc/hostname : 主機名
  • /etc/hosts : 本地域名解析設置
  • settimezone.service : 時區設置
  • 00-static.network : 靜態IP設置
  • users : 爲用戶core配置sshkey登錄,root密碼登錄(123456)

 

下載鏡像安裝文件服務器

模板URL-https://${channel}.release.core-os.net/amd64-usr/${version}/xxx網絡

例子-https://stable.release.core-os.net/amd64-usr/1465.7.0/version.txt
~/current/version.txt
~/1465.7.0/coreos_production_image.bin.bz2
~/1465.7.0/coreos_production_image.bin.bz2.DIGESTS
~/1465.7.0/coreos_production_image.bin.bz2.DIGESTS.asc
~/1465.7.0/coreos_production_image.bin.bz2.DIGESTS.sig
~/1465.7.0/coreos_production_image.bin.bz2.sig

搭建HTTP鏡像服務器ssh

使用python在本地建一個HTTP鏡像服務器,默認使用8000端口http://192.168.3.99:8000ide

$ cd c:/coreos
$ python -m SimpleHTTPServer

將上面下載的文件拷貝至c:/coreos目錄中

./ignition.json

./current/version.txt

./1465.7.0/coreos_production_image.bin.bz2

./1465.7.0/coreos_production_image.bin.bz2.DIGESTS :

./1465.7.0/coreos_production_image.bin.bz2.DIGESTS.asc

./1465.7.0/coreos_production_image.bin.bz2.DIGESTS.sig

./1465.7.0/coreos_production_image.bin.bz2.sig

 

2.硬盤安裝CoreOS

 

啓動鏡像

設置好虛擬機配置爲Linux/coreos64,內存>1G,加載[Linux]coreos_1465.7.0_production_iso_image.iso啓動鏡像

注意:內存大小要大於1G,由於加載ISO時coreos將在內存裏面跑,須要使用命令安裝到本地的硬盤上。

 

安裝coreos

# 下載 ignition.json
$ wget http://192.168.3.99:8000/
# 安裝命令
$ sudo coreos-install -b http://192.168.3.99:8000 -d /dev/sda -C stable -i ~/ignition.jsonignition.json

注意:/dev/sda指硬盤安裝,由coreos維護的默認路徑,指向硬盤根目錄

 

3.其餘

 

使用coreos-install安裝coreos

[汪雲飛2014.11.03]平臺雲基石-CoreOS之離線安裝篇(無需互聯網)

[涯餘2015.01.21]Coreos 安裝及配置

上面兩篇博文很仔細的記錄了ISO離線安裝coreos的步驟,本文參考了部份內容。

 

coreos設置靜態IP

在/etc/systemd/network下新建一個文件00-static.network

[Match]

Name=eth0

 

[Network]

DNS=192.168.3.1

Address=192.168.3.231/24

Gateway=192.168.3.1

DHCP=no     

eth0 : 默認的網卡名稱,設置時請檢查默認網卡的名稱,使用(ip a)命令查看

 

而後重啓網絡服務

$ sudo systemctl daemon-reload
$ sudo systemctl restart systemd-networkd

 

如何生成password的hash

來源coreos官網,有如下幾種生成hash的方式:

# On Debian/Ubuntu (via the package "whois")
mkpasswd --method=SHA-512 --rounds=4096

# OpenSSL (note: this will only make md5crypt.  While better than plantext it should not be considered fully secure)
openssl passwd -1

# Python (change password and salt values)
python -c "import crypt, getpass, pwd; print crypt.crypt('password', '\$6\$SALT\$')"

# Perl (change password and salt values)
perl -e 'print crypt("password","\$6\$SALT\$") . "\n"'

來自 <https://coreos.com/os/docs/latest/cloud-config.html>

上文使用openssl生成的hash,用於ignition.json中的示例

123456

$1$maTXmv6V$4UuGlRDpBZtipAhlPZ2/J0

 

鏡像文件下載

百度雲分享

http://pan.baidu.com/s/1o81GAbo

相關文章
相關標籤/搜索