LoginSignup
1
0

More than 3 years have passed since last update.

kubernetesを学ぶ~その2:宅内LAN~

Last updated at Posted at 2021-02-02

目次

  1. 前回おさらい
  2. 宅内LANの設定
    1. ネットワーク情報の確認
    2. ブリッジネットワークの追加
  3. あとがき

前回のおさらい

 前回は、kubernetesを学ぶ~その1~で、環境の構築をしました。vagrantの環境でWindowsPCのパーソナルファイアウォールにしてやられましたが、構築あるあるだったので復習の意味で躓いてよかったと思います。

宅内LANの設定

ネットワーク情報の確認

構築したmaster、node1、node2のネットワーク情報を整理します。
ホストPC(ノートPC)のIPアドレスは、

Wireless LAN adapter Wi-Fi:

   接続固有の DNS サフィックス . . . . .:
   IPv4 アドレス . . . . . . . . . . . .: 192.168.11.101
   サブネット マスク . . . . . . . . . .: 255.255.255.0
   デフォルト ゲートウェイ . . . . . . .: 192.168.11.1

master、node1、node2のアダプタは、
Adapter 1: nat
Adapter 2: hostonly
とvagrant up コマンド時のログに表示されていたので、ブリッジ接続するネットワークが無い状態。

D:\Repository\kubernetes\vagrant-kubernetes>vagrant ssh master
Last login: Mon Feb  1 10:48:34 2021 from 10.0.2.2
Welcome to Ubuntu 18.04.5 LTS (GNU/Linux 4.15.0-135-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  System information as of Tue Feb  2 04:49:28 UTC 2021

  System load:  1.03              Users logged in:        1
  Usage of /:   7.6% of 38.71GB   IP address for enp0s3:  10.0.2.15
  Memory usage: 36%               IP address for enp0s8:  172.16.20.11
  Swap usage:   0%                IP address for docker0: 172.17.0.1
  Processes:    144               IP address for cni0:    10.244.0.1

 * Introducing self-healing high availability clusters in MicroK8s.
   Simple, hardened, Kubernetes for production, from RaspberryPi to DC.

     https://microk8s.io/high-availability

7 packages can be updated.
0 of these updates are security updates.
To see these additional updates run: apt list --upgradable

New release '20.04.1 LTS' available.
Run 'do-release-upgrade' to upgrade to it.


Last login: Mon Feb  1 10:48:34 2021 from 10.0.2.2

enp0s3がNAT、enp0s8がHostOnlyですね。
virtualBoxの設定画面からも確認ができますね。

ブリッジネットワークの追加

このままだと宅内LANの別端末から接続する時に、ホストPCのIPでガチャガチャする必要があるので、ブリッジ用のネットワークを追加しようと思います。

takara9さんのvagrantfileを修正します。
vagrantfileファイル内に修正箇所を明示してくれているので、そこを宅内LANの情報に修正。
※その前に、宅内LANで空いているIPを確認しときましょー。
 ルータのDHCPスコープ外のIPにしまーす。

修正し終わったら、vagrantの再起動して反映させます。

D:\Repository\kubernetes\vagrant-kubernetes>vagrant reload
==> master: Attempting graceful shutdown of VM...
==> master: Checking if box 'ubuntu/bionic64' version '20210129.0.0' is up to date...
==> master: Clearing any previously set forwarded ports...
==> master: Clearing any previously set network interfaces...
==> master: Specific bridge 'en0:Microsoft Wi-Fi Direct Virtual Adapter #2' not found. You may be asked to specify
==> master: which network to bridge to.
==> master: Available bridged network interfaces:
1) Killer(R) Wi-Fi 6 AX1650s 160MHz Wireless Network Adapter (201D2W)
2) Microsoft Wi-Fi Direct Virtual Adapter #2
3) Hyper-V Virtual Ethernet Adapter
==> master: When choosing an interface, it is usually the one that is
==> master: being used to connect to the internet.
==> master:
    master: Which interface should the network bridge to? 1
==> master: Preparing network interfaces based on configuration...
    master: Adapter 1: nat
    master: Adapter 2: hostonly
    master: Adapter 3: bridged

~ 省略 ~

node1、node2ともに同じようなログ。

途中でブリッジのアダプタを選択するようにメッセージが現れたので、1)のアダプタを指定しました。

master、node1、node2にアクセスします。

masterにログイン
D:\Repository\kubernetes\vagrant-kubernetes>vagrant ssh master
Welcome to Ubuntu 18.04.5 LTS (GNU/Linux 4.15.0-135-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  System information as of Tue Feb  2 05:58:31 UTC 2021

  System load:     0.4               IP address for enp0s3:  10.0.2.15
  Usage of /:      7.7% of 38.71GB   IP address for enp0s8:  172.16.20.11
  Memory usage:    34%               IP address for enp0s9:  192.168.11.40
  Swap usage:      0%                IP address for docker0: 172.17.0.1
  Processes:       147               IP address for cni0:    10.244.0.1
  Users logged in: 0

 * Introducing self-healing high availability clusters in MicroK8s.
   Simple, hardened, Kubernetes for production, from RaspberryPi to DC.

     https://microk8s.io/high-availability

7 packages can be updated.
0 of these updates are security updates.
To see these additional updates run: apt list --upgradable

New release '20.04.1 LTS' available.
Run 'do-release-upgrade' to upgrade to it.


Last login: Tue Feb  2 05:29:28 2021 from 10.0.2.2
node1にログイン
D:\Repository\kubernetes\vagrant-kubernetes>vagrant ssh node1
Welcome to Ubuntu 18.04.5 LTS (GNU/Linux 4.15.0-135-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  System information as of Tue Feb  2 06:00:15 UTC 2021

  System load:     0.03              IP address for enp0s3:  10.0.2.15
  Usage of /:      5.6% of 38.71GB   IP address for enp0s8:  172.16.20.12
  Memory usage:    3%                IP address for enp0s9:  192.168.11.41
  Swap usage:      0%                IP address for docker0: 172.17.0.1
  Processes:       132               IP address for cni0:    10.244.1.1
  Users logged in: 0

 * Introducing self-healing high availability clusters in MicroK8s.
   Simple, hardened, Kubernetes for production, from RaspberryPi to DC.

     https://microk8s.io/high-availability

7 packages can be updated.
0 of these updates are security updates.
To see these additional updates run: apt list --upgradable

New release '20.04.1 LTS' available.
Run 'do-release-upgrade' to upgrade to it.


Last login: Tue Feb  2 05:42:40 2021 from 10.0.2.2
node2にログイン
D:\Repository\kubernetes\vagrant-kubernetes>vagrant ssh node2
Welcome to Ubuntu 18.04.5 LTS (GNU/Linux 4.15.0-135-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  System information as of Tue Feb  2 06:01:03 UTC 2021

  System load:  0.22              Users logged in:        0
  Usage of /:   5.5% of 38.71GB   IP address for enp0s3:  10.0.2.15
  Memory usage: 3%                IP address for enp0s8:  172.16.20.13
  Swap usage:   0%                IP address for enp0s9:  192.168.11.42
  Processes:    132               IP address for docker0: 172.17.0.1

 * Introducing self-healing high availability clusters in MicroK8s.
   Simple, hardened, Kubernetes for production, from RaspberryPi to DC.

     https://microk8s.io/high-availability

7 packages can be updated.
0 of these updates are security updates.
To see these additional updates run: apt list --upgradable

New release '20.04.1 LTS' available.
Run 'do-release-upgrade' to upgrade to it.


Last login: Tue Feb  2 05:40:48 2021 from 10.0.2.2

これで、↓のイメージになりました。
02.PNG

あとがき

 実は、今回のネットワーク確認で色々と手こずっていた。NATの設定がいらねーと思ってvirtualBoxからNATをブリッジに変更してみたりしたが、vagrantからのsshが繋がんなくなったりと色々起きた。
 ひとまず、もとに戻してブリッジ用のネットワークアダプタ追加して対処したが、vagrantのこともよく理解しないとハマると再認識した。
※原因はわかっていないw
 次回は、kubctlや用語についてまとめてみようと思う。

参考文献

15Stepで習得Dockerから入るKubernetes

1
0
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
0