oomichi / try-kubernetes

12 stars 5 forks source link

Update OpenStack IaaS for ubuntu 16.04 and Queens #27

Closed oomichi closed 6 years ago

oomichi commented 6 years ago

最新環境(Ubuntu 16.04、Queens)で OpenStack IaaS を運用する。 Ubuntu 18.04 が最新だが、cloud-archive の Queens が 16.04 しかサポートしていないため、16.04 で構築する。

oomichi commented 6 years ago

まずは ubuntu 18.04 DVD 作成

$ wget http://releases.ubuntu.com/18.04/ubuntu-18.04-live-server-amd64.iso
$ growisofs -dvd-compat -Z /dev/dvdrw=ubuntu-18.04-live-server-amd64.iso

手動インストール Ansible playbook実行端末の pub key を対象マシンに格納

ubuntu@iaas-ctrl:~$ mkdir .ssh
ubuntu@iaas-ctrl:~$ chmod 700 .ssh
ubuntu@iaas-ctrl:~$ cd .ssh
ubuntu@iaas-ctrl:~/.ssh$ ls
ubuntu@iaas-ctrl:~/.ssh$ vi authorized_keys
ubuntu@iaas-ctrl:~/.ssh$ chmod 600 authorized_keys

Ansible playbook実行端末から対象マシンにパスワード無しで ssh ログインできることを確認 Ansible playbookを実行するが下記のとおり python が無いためエラー

$ ansible-playbook 00_base.yaml -i hosts --ask-become-pass
SUDO password:
[..]
fatal: [172.27.138.60]: FAILED! => {"changed": false, "module_stderr": "Shared connection to 172.27.138.60 closed.\r\n", "module_stdout": "\r\n/bin/sh: 1: /usr/bin/python: not found\r\n", "msg": "MODULE FAILURE", "rc": 127}

pythonを別途インストール。OSインストール時に一緒にインストールできる方法を知る必要あり

$ sudo apt-get install python

Cloud-archiveの追加時に下記のようにエラー

fatal: [172.27.138.60]: FAILED! => {"changed": true, "cmd": "add-apt-repository cloud-archive:queens", "delta": "0:00:30.141932", "end": "2018-07-03 23:26:07.635733", "msg": "command exceeded timeout", "rc": null, "start": "2018-07-03 23:25:37.493801", "stdout": " Ubuntu Cloud Archive for OpenStack Queens\r\n More info: https://wiki.ubuntu.com/ServerTeam/CloudArchive\r\nPress [ENTER] to continue or Ctrl-c to cancel adding it.", "stdout_lines": [" Ubuntu Cloud Archive for OpenStack Queens", " More info: https://wiki.ubuntu.com/ServerTeam/CloudArchive", "Press [ENTER] to continue or Ctrl-c to cancel adding it."]}
        to retry, use: --limit @/home/oomichi/try-kubernetes/ci/11_mini_openstack/00_base.retry

expected を修正したが再度下記のようにエラー

cloud-archive for Queens only supported on xenial

結局 Queens は 18.04 をサポートしないことが判明。16.04 で試すことにする。

oomichi commented 6 years ago

Pikeで使っていたansible playbookを使って Queens を設定していたら、Keystone サービスが使えない問題が発生。 たぶん、Apache を経由して他の OpenStack サービスにつながるように設定が変わったことに追従できていないから。 公式ドキュメントを見て確認する。 https://docs.openstack.org/queens/install/

DevStackでは下記の処理 lib/keystone

277     if [ "$KEYSTONE_DEPLOY" == "mod_wsgi" ]; then
278         iniset $KEYSTONE_CONF DEFAULT logging_exception_prefix "%(asctime)s.%(msecs)03d %(process)d TRACE %(name)s %(instance)s"
279         _config_keystone_apache_wsgi
280     else # uwsgi
281         write_uwsgi_config "$KEYSTONE_PUBLIC_UWSGI_CONF" "$KEYSTONE_PUBLIC_UWSGI" "/identity"
282         write_uwsgi_config "$KEYSTONE_ADMIN_UWSGI_CONF" "$KEYSTONE_ADMIN_UWSGI" "/identity_admin"
283     fi

このコミットは

commit 6ed53156b6198e69d59d1cf3a3497e96f5b7a870
Author: Sean Dague <sean@dague.net>
Date:   Thu Apr 13 13:33:16 2017 -0400

で入った。 原因は Queens の keystoneパッケージで /etc/apache2/sites-available/keystone.conf が設定され、それが下記のように 5000 番ポートを指定されているにもかかわらず、bootstrap の一部で 35357 を指定しているから?

Listen 5000

<VirtualHost *:5000>
    WSGIScriptAlias / /usr/bin/keystone-wsgi-public
    WSGIDaemonProcess keystone-public processes=5 threads=1 user=keystone group=keystone display-name=%{GROUP}
    WSGIProcessGroup keystone-public
    WSGIApplicationGroup %{GLOBAL}
    WSGIPassAuthorization On
    LimitRequestBody 114688

公式ドキュメント(https://docs.openstack.org/keystone/queens/install/keystone-install-ubuntu.html#install-and-configure-components )では全て 5000 を指定している。 確かに 5000 で keystone サービスが動作していることを確認した。

$ curl http://iaas-ctrl:5000/v3
{"version": {"status": "stable", "updated": "2018-02-28T00:00:00Z", "media-types": [{"base": "application/json", "type": "application/vnd.openstack.identity-v3+json"}], "id": "v3.10", "links": [{"href": "http://iaas-ctrl:5000/v3/", "rel": "self"}]}}

https://github.com/oomichi/try-kubernetes/commit/43f39e69e8195ec2b173031b201bf97808bd6253 で関係ファイルを更新した。

oomichi commented 6 years ago

07_glance.yaml 実施後、glance サービスを確認したところ、次のようにエラーになった。

$ openstack image list
Internal Server Error (HTTP 500) (Request-ID: req-ce05a944-0187-434b-b8cb-f2a5a92d12cc)

images テーブルが DB に存在しないための模様 /var/log/glance/glance-api.log

2018-07-03 18:52:21.197 6397 ERROR glance.common.wsgi     util.raise_from_cause(newraise, exc_info)
2018-07-03 18:52:21.197 6397 ERROR glance.common.wsgi   File "/usr/lib/python2.7/dist-packages/sqlalchemy/util/compat.py", line 203, in raise_from_cause
2018-07-03 18:52:21.197 6397 ERROR glance.common.wsgi     reraise(type(exception), exception, tb=exc_tb, cause=cause)
2018-07-03 18:52:21.197 6397 ERROR glance.common.wsgi   File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1182, in _execute_context
2018-07-03 18:52:21.197 6397 ERROR glance.common.wsgi     context)
2018-07-03 18:52:21.197 6397 ERROR glance.common.wsgi   File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/default.py", line 470, in do_execute
2018-07-03 18:52:21.197 6397 ERROR glance.common.wsgi     cursor.execute(statement, parameters)
2018-07-03 18:52:21.197 6397 ERROR glance.common.wsgi DBNonExistentTable: (sqlite3.OperationalError) no such table: images

公式ドキュメントには glance-registry と glance-api のサービス再起動が記載。実施したところ問題は解消した。 https://github.com/oomichi/try-kubernetes/commit/3802faa6c49585e19951ef2860b2acd5f826853e で対応済み

oomichi commented 6 years ago

Cinder設定を追加する。 https://docs.openstack.org/cinder/queens/install/index-ubuntu.html

ファイル上に lvm 環境を作って、それを Cinder のバックエンドとして使う。 DevStackでも同様のことを行っている。

 94 function _create_lvm_volume_group {
 95     local vg=$1
 96     local size=$2
 97
 98     local backing_file=$DATA_DIR/$vg$BACKING_FILE_SUFFIX
 99     if ! sudo vgs $vg; then
100         # Only create if the file doesn't already exists
101         [[ -f $backing_file ]] || truncate -s $size $backing_file
102         local vg_dev
103         vg_dev=`sudo losetup -f --show $backing_file`
104
105         # Only create volume group if it doesn't already exist
106         if ! sudo vgs $vg; then
107             sudo vgcreate $vg $vg_dev
108         fi
109     fi
110 }

同じことをする。

$ truncate -s $size $backing_file
$ vg_dev=`sudo losetup -f --show $backing_file`
$ sudo vgcreate cinder-volumes $vg_dev

途中のansibleスクリプトでの実施結果

$ sudo vgdisplay
[..]
  --- Volume group ---
  VG Name               cinder-volumes
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  1
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                0
  Open LV               0
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               100.00 GiB
  PE Size               4.00 MiB
  Total PE              25599
  Alloc PE / Size       0 / 0
  Free  PE / Size       25599 / 100.00 GiB
  VG UUID               J6wDhc-vKvo-TcTu-akZy-jmHw-H5Fy-Fb7wR9

システム再起動後にも残るか調べる。→ 残らない、起動スクリプトとして追加済み。

oomichi commented 6 years ago

VM起動で以下のようにエラーになる

$ openstack server create --flavor m1.medium --image Ubuntu-16.04-x86_64 \
>    --nic net-id=$PROVIDER_NET_ID --security-group default \
>    --key-name mykey vm01

...

$ nova list
+--------------------------------------+------+--------+------------+-------------+----------+
| ID                                   | Name | Status | Task State | Power State | Networks |
+--------------------------------------+------+--------+------------+-------------+----------+
| 71ba2378-2337-410c-9c81-1060602c376d | vm01 | ERROR  | -          | NOSTATE     |          |
+--------------------------------------+------+--------+------------+-------------+----------+

nova-conductor.log

2018-07-06 11:55:48.638 2163 ERROR nova.conductor.manager [req-bfbde3c8-c09b-4adb-b058-41fcd6ba5254 e5e99065fd524f328c2f81e28a6fbc42 682e74f275fe427abd9eb6759f3b68c5 - default default] Failed to schedule instances: NoValidHost_Remote: No valid host was found.

nova-schedulerはPlacementから「適切な候補nodeがない」と通知される

2018-07-06 12:07:57.238 1910 DEBUG nova.scheduler.manager [req-fc8f5546-cb06-4b0b-a1c7-d23180264329 e5e99065fd524f328c2f81e28a6fbc42 682e74f275fe427abd9eb6759f3b68c5 - default default] Starting to schedule for instances: [u'20e49bad-d64f-4e57-b9b1-7692fb72dbe2'] select_destinations /usr/lib/python2.7/dist-packages/nova/scheduler/manager.py:110
2018-07-06 12:07:59.657 1910 DEBUG nova.scheduler.manager [req-fc8f5546-cb06-4b0b-a1c7-d23180264329 e5e99065fd524f328c2f81e28a6fbc42 682e74f275fe427abd9eb6759f3b68c5 - default default] Got no allocation candidates from the Placement API. This may be a temporary occurrence as compute nodes start up and begin reporting inventory to the Placement service. select_destinations /usr/lib/python2.7/dist-packages/nova/scheduler/manager.py:135

しかしnova-cpu01は正常認識されている

$ nova service-list
+--------------------------------------+------------------+------------+----------+---------+-------+----------------------------+-----------------+-------------+
| Id                                   | Binary           | Host       | Zone     | Status  | State | Updated_at                 | Disabled Reason | Forced down |
+--------------------------------------+------------------+------------+----------+---------+-------+----------------------------+-----------------+-------------+
| 53d59728-4059-41e9-9d57-da911a7bc1d9 | nova-consoleauth | iaas-ctrl  | internal | enabled | up    | 2018-07-06T18:59:17.000000 | -               | False       |
| d6603967-072d-4de3-806b-5220a7c8a178 | nova-scheduler   | iaas-ctrl  | internal | enabled | up    | 2018-07-06T18:59:21.000000 | -               | False       |
| a7928fb8-d563-4cf4-b0e3-209167ebc539 | nova-conductor   | iaas-ctrl  | internal | enabled | up    | 2018-07-06T18:59:25.000000 | -               | False       |
| 1ee71f78-8491-49b3-b605-3f8d08f2abf9 | nova-compute     | iaas-cpu01 | nova     | enabled | up    | 2018-07-06T18:59:22.000000 | -               | False       |
+--------------------------------------+------------------+------------+----------+---------+-------+----------------------------+-----------------+-------------+

iaas-cpu01 からは正常にリソースを通知しているように見える

2018-07-06 12:05:15.402 1049 INFO nova.compute.resource_tracker [req-fd28aa4c-9f41-4ff8-8d78-93227b67f65e - - - - -] Final resource view: name=iaas-cpu01 phys_ram=15956MB used_ram=512MB phys_disk=442GB used_disk=0GB total_vcpus=4 used_vcpus=0 pci_stats=[]
oomichi commented 6 years ago

そもそも Placement の確認方法がわからない・・ https://docs.openstack.org/osc-placement/latest/cli/index.html だと普通に使えるように見えるが allocation サブコマンドは標準の openstack コマンドでは有効になっていない。 たしか extensible だったはずなので、その方法を調べる。 というか、普通のデバッグで必要じゃないのか?デフォルトで有効になっているべきだと思うけど

そもそも placement plugin が https://github.com/openstack/python-openstackclient/blob/master/doc/source/contributor/plugins.rst のリストに含まれていないぞ・・ ひとまず curl コマンドで代用

$ curl -X GET http://iaas-ctrl:8778/resource_classes -H "X-Auth-Token: $TOKEN" -H "OpenStack-API-Version: placement 1.10"
{"resource_classes": [{"name": "VCPU", "links": [{"href": "/resource_classes/VCPU", "rel": "self"}]}, {"name": "MEMORY_MB", "links": [{"href": "/resource_classes/MEMORY_MB", "rel": "self"}]}, {"name": "DISK_GB", "links": [{"href": "/resource_classes/DISK_GB", "rel": "self"}]}, {"name": "PCI_DEVICE", "links": [{"href": "/resource_classes/PCI_DEVICE", "rel": "self"}]}, {"name": "SRIOV_NET_VF", "links": [{"href": "/resource_classes/SRIOV_NET_VF", "rel": "self"}]}, {"name": "NUMA_SOCKET", "links": [{"href": "/resource_classes/NUMA_SOCKET", "rel": "self"}]}, {"name": "NUMA_CORE", "links": [{"href": "/resource_classes/NUMA_CORE", "rel": "self"}]}, {"name": "NUMA_THREAD", "links": [{"href": "/resource_classes/NUMA_THREAD", "rel": "self"}]}, {"name": "NUMA_MEMORY_MB", "links": [{"href": "/resource_classes/NUMA_MEMORY_MB", "rel": "self"}]}, {"name": "IPV4_ADDRESS", "links": [{"href": "/resource_classes/IPV4_ADDRESS", "rel": "self"}]}, {"name": "VGPU", "links": [{"href": "/resource_classes/VGPU", "rel": "self"}]}, {"name": "VGPU_DISPLAY_HEAD", "links": [{"href": "/resource_classes/VGPU_DISPLAY_HEAD", "rel": "self"}]}]}
$

問題となっている allocation_candidates は Pikeの最後のmicroversionとしてリリースされたもの

$ curl -X GET http://iaas-ctrl:8778/allocation_candidates?resources=VCPU:4 -H "X-Auth-Token: $TOKEN" -H "OpenStack-API-Version: placement latest" --verbose
Note: Unnecessary use of -X or --request, GET is already inferred.
*   Trying 127.0.0.1...
* Connected to iaas-ctrl (127.0.0.1) port 8778 (#0)
> GET /allocation_candidates?resources=VCPU:4 HTTP/1.1
> Host: iaas-ctrl:8778
> User-Agent: curl/7.47.0
> Accept: */*
> X-Auth-Token: gAAAAABbP-VDcBhqmaJKmHXPeBeVIcGXdkUzrDK8BwO4dlubEBq6Mr6CexJHffxTbSpB2FqdU2nO79qpkbOhvh8EKevn9COKikgvfjPdbzZgSWfDpQ8aRA8TlXowA--R7LeLRNpMrqV19O1j1IwfKAZ-46bPi6f9llZxu8Ud7PZYrfyIcBizvhA
> OpenStack-API-Version: placement latest
>
< HTTP/1.1 200 OK
< Date: Fri, 06 Jul 2018 22:45:44 GMT
< Server: Apache/2.4.18 (Ubuntu)
< Cache-Control: no-cache
< OpenStack-API-Version: placement 1.17
< vary: OpenStack-API-Version
< x-openstack-request-id: req-186405d3-023e-4c50-b82f-ff27a2eece13
< Content-Length: 53
< Last-Modified: Fri, 06 Jul 2018 22:45:44 GMT
< Content-Type: application/json
<
* Connection #0 to host iaas-ctrl left intact
{"provider_summaries": {}, "allocation_requests": []}

Placement側にcpu01の情報が格納されていないように見える 以下で一度エラーになったから登録されていない?

2018-07-05 19:02:30.985 990 ERROR nova.compute.manager [req-18373cdd-c18c-45aa-aee9-14197ed0f3ae - - - - -] No compute node record for host iaas-cpu01

以下のコードでもエラーになっていた

1689     if not compute_driver:
1690         compute_driver = CONF.compute_driver
1691
1692     if not compute_driver:
1693         LOG.error("Compute driver option required, but not specified")
1694         sys.exit(1)

上記のERRORが出ないようにするため、nova-compute.conf にあったドライバ指定の部分を nova.conf に移動した。

oomichi commented 6 years ago

つぎは以下のエラーが出ていた。

2018-07-06 17:45:14.328 2162 WARNING nova.scheduler.utils [req-cb508854-ce15-4e4d-849d-e8222d58b8c5 e5e99065fd524f328c2f81e28a6fbc42 682e74f275fe427abd9eb6759f3b68c5 - default default] [instance: 45486b05-8376-4673-978e-3a4e11f6ef8a] Setting instance to ERROR state.: HostMappingNotFound: Host 'iaas-cpu01' is not mapped to any cell

以下を ctrl で実行してみたところ、cpu01 が認識された

# su -s /bin/sh -c "nova-manage cell_v2 discover_hosts --verbose" nova
Found 2 cell mappings.
Skipping cell0 since it does not contain hosts.
Getting computes from cell 'cell1': 94f79fc4-6551-4d1c-95d7-aed0499a243b
Checking host mapping for compute host 'iaas-cpu01': aa75bebc-7571-45ea-8377-6411ff54c30a
Creating host mapping for compute host 'iaas-cpu01': aa75bebc-7571-45ea-8377-6411ff54c30a
Found 1 unmapped computes in cell: 94f79fc4-6551-4d1c-95d7-aed0499a243b

ぐわ、https://github.com/oomichi/try-kubernetes/tree/master/ci/11_mini_openstack に書いてあった・・

oomichi commented 6 years ago

動くようになった

$ openstack server create --flavor m1.medium --image Ubuntu-16.04-x86_64 --key-name mykey vm01
..
$ nova list
+--------------------------------------+------+--------+------------+-------------+------------------------+
| ID                                   | Name | Status | Task State | Power State | Networks               |
+--------------------------------------+------+--------+------------+-------------+------------------------+
| cb546405-74c3-4b45-9981-21cbbfd54950 | vm01 | ACTIVE | -          | Running     | provider=192.168.1.104 |
+--------------------------------------+------+--------+------------+-------------+------------------------+
oomichi commented 6 years ago

2台のnucも追加する

nucに割り当てられた IP アドレスは dhcpd のログから確認できる /var/log/syslog

Jul  6 06:28:01 localhost dhcpd[949]: DHCPREQUEST for 192.168.1.64 from f4:4d:30:6e:9c:c0 (iaas-cpu03) via enp2s0
Jul  6 19:13:06 localhost dhcpd[1082]: DHCPREQUEST for 192.168.1.61 from f4:4d:30:6e:9a:a5 (iaas-cpu02) via enp2s0
Jul  6 19:13:20 localhost dhcpd[1082]: DHCPREQUEST for 192.168.1.59 from 64:00:6a:8e:33:0e (iaas-cpu01) via enp2s0

だめだ、BIOSでpxebootの設定が必要だったので HDMI ケーブルが必要。明日HDMI ケーブルを持ってきて作業する。

追加、完了

$ nova service-list
+--------------------------------------+------------------+------------+----------+---------+-------+----------------------------+-----------------+-------------+
| Id                                   | Binary           | Host       | Zone     | Status  | State | Updated_at                 | Disabled Reason | Forced down |
+--------------------------------------+------------------+------------+----------+---------+-------+----------------------------+-----------------+-------------+
| 53d59728-4059-41e9-9d57-da911a7bc1d9 | nova-consoleauth | iaas-ctrl  | internal | enabled | up    | 2018-07-09T19:05:56.000000 | -               | False       |
| d6603967-072d-4de3-806b-5220a7c8a178 | nova-scheduler   | iaas-ctrl  | internal | enabled | up    | 2018-07-09T19:05:53.000000 | -               | False       |
| a7928fb8-d563-4cf4-b0e3-209167ebc539 | nova-conductor   | iaas-ctrl  | internal | enabled | up    | 2018-07-09T19:05:54.000000 | -               | False       |
| 1ee71f78-8491-49b3-b605-3f8d08f2abf9 | nova-compute     | iaas-cpu01 | nova     | enabled | up    | 2018-07-09T19:05:52.000000 | -               | False       |
| 953a2743-b9bf-4ccd-a2f5-b4131d176db9 | nova-compute     | iaas-cpu03 | nova     | enabled | up    | 2018-07-09T19:05:51.000000 | -               | False       |
| 81bfa844-2712-4749-90f9-74921ec2a376 | nova-compute     | iaas-cpu02 | nova     | enabled | up    | 2018-07-09T19:05:56.000000 | -               | False       |
+--------------------------------------+------------------+------------+----------+---------+-------+----------------------------+-----------------+-------------+
GeorgeGuo2018 commented 4 years ago

Hi, oomichi, can you write all those in English?