2
2

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.

ubuntu 16.04でkubernetes-vagrant-coreos-clusterを使ってみる

Posted at

はじめに

3週遅れくらいのネタではありますが,いまさらkubernetesさわりたくなりました.

kubernetesを遊ぶ前に,まずkubernetesを動かせる環境を用意せねばならぬ.
クラウド礼賛の割には,あまりクラウド使わないオオカミ少年の自分.kubernetes + GCEじゃなく,ローカルにUbuntu 16.04の物理ホストを立ててkubernetes-vagrant-coreos-clusterでトライしてみることにした.

というチラシの裏.

インストール

Ubuntu 16.04 desktop

ぐぐれ

Ubuntu host環境

以下をインストールする.

  • git
  • virtualbox
  • vagrant
  • nfs

git

sudo apt-get install -y git

virtualbox & vagrant

主にぐぐれ

とりあえず,以下からdebをダウンロードしてダブルクリックするなり,dpkgなり,gdebiでインストールすればよいはず.

aptでも入るみたいなんで,面倒ならsudo apt-get install virtualbox vagrantでもいいのかもしれない.自分はaptのおまけに付いてくる大量の依存ライブラリを見て恐れをなして公式からdebを落としてポチポチ手動インストールした.

NFS

kubernetes-vagrant-coreos-clusterを何も考えずvagrant upすると以下の様なエラーが表示され,NFSが必要だということが分かる,という未来が見えたので先回りして入れておきます.

$ vagrant up 

...

It appears your machine doesn't support NFS, or there is not an
adapter to enable NFS on this machine for Vagrant. Please verify
that `nfsd` is installed on your machine, and try again. If you're
on Windows, NFS isn't supported. If the problem persists, please
contact Vagrant support.

NFSの設定方法をぐぐると,先達が書き残したありがたい情報を発見したので,何も考えずターミナルにコピペ.

sudo apt-get install nfs-kernel-server nfs-common portmap

kubernetesクラスタを作る

世界中の「k8sを触ってみる」系の記事で書かれまくっているpires/kubernetes-vagrant-coreos-clusterというありがたいソリューションを使わせてもらう.

クラスタ作成

とりあえず動かしてみるなら3コマンドという脅威のお手軽さ.
vagrant upしてしばらく待てば,masterとminionが適宜設定されkubernetes readyになっているはず.

git clone https://github.com/pires/kubernetes-vagrant-coreos-cluster.git
cd kubernetes-vagrant-coreos-cluster
vagrant up

確認

vagrant upが正常に終了したら,kubectl叩いてクラスターが見えることを確認します.

$ kubectl cluster-info
Kubernetes master is running at http://172.17.8.101:8080
kube-dns is running at http://172.17.8.101:8080/api/v1/proxy/namespaces/kube-system/services/kube-dns

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.

$ kubectl get nodes
NAME           STATUS    AGE
172.17.8.102   Ready     1h
172.17.8.103   Ready     1h

やったぜ.

クラスタのカスタマイズ等

ノード数変えたいとか,細かい使い方はぐぐれば出てくる.お好みのページを参考に無心でコマンドをコピペしていけばよいはず.

この先へ

そして本題のk8s自体の使い方を習得するという作業が残っている.俺たちの戦いはこれからだ!
(っていうか,簡単すぎて何が起こっているのか理解出来なかったわけだが...:scream: )

参考

2
2
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
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?