1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

k3osをさくらVPSにインストールする

1
Last updated at Posted at 2019-06-13

k3osをさくらVPSに入れようとしたら詰まったけど、出来たのでメモ。
ネット設定事情によりgithubからキー取得の機能は利用せず、
公開鍵は直接指定です。
追記(6/18):ごめんなさい設定内容が間違ってました。;;

k3osをダウンロード

https://github.com/rancher/k3os/releases/tag/v0.2.1
k3os-amd64.isoをダウンロードする。

sftpでアップロード

管理画面で各種設定のOSインストールを選ぶ。
カスタムOS設定で、sftpでファイルをisoをアップロードします。

cloud-initのコンフィグ

さくらのコンソールでusername: rancherで、ログインします。
sshはつながりません。

ここを参考にcloud-initのコンフィグを書いて保存します。
追記(6/18):ごめんなさい設定内容が間違ってました。;;今のところ、こうじゃないと上手く動きません。
https://github.com/rancher/k3os

cloud-init.yaml

ssh_authorized_keys:
- ssh-rsa AAAA.....w==
write_files:
- enconding: ""
  content: |-
    #!/bin/bash
    write_log () {
        local message="${1}"
        logger -t "boot-cmd" "${message}"
        echo "${message}"
    }
    write_log "Getting the service using eth0..."
    ETH0=$(connmanctl services | awk '{ print $3 }' | while read -r s1; do connmanctl services $s1 | grep -q "eth0" && echo "$s1"; done)
    write_log "eth0 is bound to: ${ETH0}"
    write_log "Setting up manual net config..."
    connmanctl config $ETH0 --ipv4 manual 133.0.XX.XX 255.255.255.0 133.XX.XX.1 --nameservers  	210.224.163.X 210.224.163.X
    connmanctl config $ETH0 --timeservers 133.XX.XX.1  # keeps .1 as optional ntp server but prefers .4
    connmanctl config $ETH0 --ipv6 off
    write_log "Restarting connman..."
    service connman restart
    write_log "$(connmanctl services $ETH0)"
    write_log "Network setup done."
  owner: root:root
  path: /etc/boot-cmd.sh
  permissions: '0755'
boot_cmd:
- "/etc/boot-cmd.sh"
hostname: k3os-server01

ssh_authorized_keysの設定
ここで、公開鍵を指定します。
- github: XXXX という書き方ができるみたいですが、ネットができていないため使えません。

write_filesの設定
ここでネットワーク設定を行う。
設定情報は、さくら管理画面のネットワーク情報から確認できます。

インストール

インストールするには、以下を打ち込みます。
sudo os-config

以下で、yを選択して、先ほど保存した、cloud-init.yaml ファイルを指定します。

Config system with cloud-init file? [y/N]:y

完了

あとは再起動が終わると、sshでログインできます。
ログインした状態で、kubectlなどを使うことができます。

何が問題だったか。

この手順を、10数回繰り替えして分かったのが以下です。(軽いだけにインストールは激早でした。)

  1. k3osのisoにはさくらVPSのネットワーク設定が含まれていないので、ネットに繋がらないので、sudo os-configのgithubを指定すると、ネットワークタイムアウトする。

  2. cloud-initファイルを使うと、githubがスキップされ指定できない。

  3. cloud-initにgithubを記録しても、ネットワーク設定前にキーを取ってこようとするため失敗する。

  4. ログインに失敗すると、再インストールからやり直し。

githubキーを指定しつつ、インストールできるやり方が分かればいいな。

おまけ

k3osのネットワークマネージャーは、connmanctlを使っていたので、再起動せずにネットワークを書き換えたいときはこれが使える。
https://ahmermansoor.blogspot.com/2019/05/configure-network-on-k3os-machine.html

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?