基本按照Ubuntu官网的指南来安装,使用单节点模式,官网步骤参见网址:https://ubuntu.com/openstack/install
系统为Ubuntu 24.04.2,全新安装.
Welcome to Ubuntu 24.04.2 LTS (GNU/Linux 6.11.0-24-generic x86_64)kai@experiment:~$ sudo snap install openstack --channel 2024.1/candidate
openstack (2024.1/candidate) 2024.1 from Canonical✓ installed
运行依赖安装脚本,并且将当前用户的sudo设置为无密码(NOPASSWD:ALL):
kai@experiment:~$ sunbeam prepare-node-script --bootstrap | bash -x && newgrp snap_daemon
++ lsb_release -sc
...
Bootstrap agent now started
Contacting Juju controller at 10.161.243.43 to verify accessibility...Bootstrap complete, controller "localhost-localhost" is now available
Controller machines are in the "controller" modelNow you can runjuju add-model <model-name>
to create a new model to deploy workloads.
+ echo 'Juju bootstrap complete, you can now bootstrap sunbeam!'
Juju bootstrap complete, you can now bootstrap sunbeam!
在部署openstack之前,设置代理,ubuntu官网的步骤中没有此步骤。192.168.5.191是局域网中的一个代理软件,注意NO_PROXY的配置,本机回环地址和私有地址不需要代理。
kai@experiment:~/work$ cat /etc/environment
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin"
HTTP_PROXY=http://192.168.5.191:7890
HTTPS_PROXY=http://192.168.5.191:7890
NO_PROXY=localhost,experiment,127.0.0.1,10.161.243.43,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16
使用cluster bootstrap部署openstack,并且接收默认的软件。
kai@experiment:~$ sunbeam cluster bootstrap --accept-defaults
Node has been bootstrapped with roles: control, compute
查看创建的cluster信息。
kai@experiment:~$ sunbeam cluster listopenstack-machines
┏━━━━━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━┓
┃ Node ┃ Machine ┃ Compute ┃ Control ┃ Storage ┃
┡━━━━━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━┩
│ 10.161.243.1 │ running │ active │ active │ │
└──────────────┴─────────┴─────────┴─────────┴─────────┘
配置openstack,并且创建demo用户。
kai@experiment:~$ sunbeam configure --accept-defaults --openrc demo-openrc
⠸ Generating openrc for cloud admin usage ... Writing openrc to demo-openrc ... done
The cloud has been configured for sample usage.
You can start using the OpenStack client or access the OpenStack dashboard at http://172.16.1.205:80/openstack-horizon
生成demo-openrc文件在当前目录下,包括demo用户和密码登,内容如下:
kai@experiment:~$ cat demo-openrc
# openrc for demo
export OS_AUTH_URL=http://172.16.1.205/openstack-keystone/v3
export OS_USERNAME=demo
export OS_PASSWORD=SFMcoRPeolQL
export OS_USER_DOMAIN_NAME=users
export OS_PROJECT_DOMAIN_NAME=users
export OS_PROJECT_NAME=demo
export OS_AUTH_VERSION=3
export OS_IDENTITY_API_VERSION=3
安装之后,自带一个ubuntu 22.04 LTS的镜像,如下:
kai@experiment:~$ openstack image list
+--------------------------------------+--------+--------+
| ID | Name | Status |
+--------------------------------------+--------+--------+
| a48cfdb9-1b61-4fcd-94ad-6b1a466102d9 | ubuntu | active |
+--------------------------------------+--------+--------+
使用此镜像创建实例test:
kai@experiment:~$ sunbeam launch ubuntu --name test
Launching an OpenStack instance ...
Access the instance by running the following command:
`ssh -i /home/kai/snap/openstack/712/sunbeam ubuntu@172.16.2.81`
实例创建需要等待一会,1,2分钟左右,时长和机器配置相关。使用ssh可以登录。
kai@experiment:~$ ssh -i /home/kai/snap/openstack/712/sunbeam ubuntu@172.16.2.81
The authenticity of host '172.16.2.81 (172.16.2.81)' can't be established.
ED25519 key fingerprint is SHA256:oZ9wg4nS/JFil9zI0lGM45NVU5KWn58Mt4qFllCf67o.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
openstack cli
在命令行使用CLI,需要admin账户,如下创建管理账户。
kai@experiment:~$ sunbeam openrc > admin-openrc
管理账户信息如下。
kai@experiment:~$ cat admin-openrc
# openrc for access to OpenStack
export OS_USERNAME=admin
export OS_PASSWORD=7FP1eYYRsWah
export OS_AUTH_URL=http://172.16.1.205/openstack-keystone/v3
export OS_USER_DOMAIN_NAME=admin_domain
export OS_PROJECT_DOMAIN_NAME=admin_domain
export OS_PROJECT_NAME=admin
export OS_AUTH_VERSION=3
export OS_IDENTITY_API_VERSION=3
使用source命令,当前shell环境下就可以使用openstack命令了。
kai@experiment:~$ source admin-openrc
如下查看flavor和network信息:
kai@experiment:~$ openstack flavor list
+--------------------------------------+---------------+------+------+-----------+-------+-----------+
| ID | Name | RAM | Disk | Ephemeral | VCPUs | Is Public |
+--------------------------------------+---------------+------+------+-----------+-------+-----------+
| 2eb5b677-055f-4c21-97e4-e94ca16beb58 | m1.small-sev | 2048 | 30 | 0 | 1 | True |
| 6e58ec21-a9d1-45ca-b1f4-5af869ddda7b | m1.tiny | 512 | 4 | 0 | 1 | True |
| 77b6286d-7608-410b-9ee2-9ddd69c09472 | m1.large | 8192 | 90 | 0 | 4 | True |
| 8fa11a91-4b25-4ce0-9a6a-2b90cef64927 | m1.medium | 4096 | 60 | 0 | 2 | True |
| 933768c4-887e-4f0a-bfbd-67f7321d3fca | m1.large-sev | 8192 | 90 | 0 | 4 | True |
| b661abdc-4547-4ab9-85ca-37e97bd56c91 | m1.tiny-sev | 512 | 4 | 0 | 1 | True |
| ed89d1c4-44fb-4270-a822-49806ada1801 | m1.small | 2048 | 30 | 0 | 1 | True |
| fd8a3d1b-f698-4e9d-a6d6-8639d9476cd8 | m1.medium-sev | 4096 | 60 | 0 | 2 | True |
+--------------------------------------+---------------+------+------+-----------+-------+-----------+
kai@experiment:~$ openstack network list
+--------------------------------------+------------------+--------------------------------------+
| ID | Name | Subnets |
+--------------------------------------+------------------+--------------------------------------+
| 013c13c6-ee6f-4b40-8c32-a16d8fecf93e | demo-network | 3202009a-dd39-4e48-b2d1-3ccf6c10a1fa |
| ee93b934-1533-4a09-a477-22621b5a7ccc | external-network | 11ad87f2-d8ff-45da-a8be-925741b840d4 |
+--------------------------------------+------------------+--------------------------------------+