当前位置:网站首页>Multipass中文文档-使用Packer打包Multipass镜像
Multipass中文文档-使用Packer打包Multipass镜像
2022-06-26 04:35:00 【但老师】
总目录(待翻译完完善)
1. 概览
2. 教程
3. 使用指引
3.1 安装Multipass
3.1.1 基于Linux
3.1.2 基于macOS
3.1.3 基于Windows
3.2 管理实例
3.2.1 创建实例
3.2.2 修改实例
3.2.3 使用实例
3.2.4 使用实例命令别名
3.2.5 与实例共享数据
3.2.6 移除实例
3.3 管理Multipass
3.3.1 设置驱动
3.3.2 授权客户端使用Multipass服务
3.3.3 远程使用Multipass
3.3.4 提高挂载性能
3.3.5 使用Packer打包Multipass镜像
3.3.6 设置图像界面
3.3.7 使用不同的macOS终端
3.4 问题排查
3.4.1 连接日志
3.4.2 网络问题排查
如何使用Packer打包Multipass镜像
Packer是一个可以让你(重新)打包镜像以在不同环境下运行的实用程序. Multipass也可以运行那些镜像, 只需要满足一条件(意即, 镜像必须在虚拟机启动, 并且云端启动(cloud-init)需要可用.
内容:
基础
最简单的方式是从现有的Ubuntu云镜像(Ubuntu Cloud image)启动, 然后是一些基础的项目设置(你可以点击文件名看具体内容, meta-data是特意留空的):
|- cloud-data
| |- meta-data
| |- user-data
|---- template.json
1个目录, 3份文件
你需要安装QEMU(例如sudo apt install qemu), 可以从此运行:
$ packer build template.json
$ multipass launch file://$PWD/output-qemu/packer-qemu --disk 5G
...
Launched: tolerant-hammerhead
$ multipass shell tolerant-hammerhead
...
[email protected] ~:$
定制镜像
现在上面步骤起作用了, 使用multipass delete --purge tolerant-hammerhead删除测试实例, 然后在template.json文件中编辑下面部分:
{
"type": "shell",
"inline": ["echo Your steps go here."]
},
任何你在这所在都会影响到最终镜像. 你可以安装包, 配置服务, 做任何你可以在运行中系统上可做的事情. 有可能需要sudo(无需密码)处理任何需要管理权限的事务, 或者你可以将下面这些加到过程中以有权限执行完整脚本:
"execute_command": "sudo sh -c '{
{ .Vars }} {
{ .Path }}'",
为了让镜像对让人也有用, 你可能需要"普遍化"镜像, 以使它可以在其他机器上也能平稳运行, 例如其他网络, 甚至是在不同的虚拟机上. 这是template.json文件中最后一个词条在设置过程中所做的事.
解析过程
长话短说, Packer使用下载好的镜像启动虚拟机, 然后在运行中的系统上运行所有设置过程.
云端启动
Ubuntu云端镜像被默认设置为仅允许基于密钥的SSH登录. Packer的qemu builder仅支持密码授权, 所以我们在镜像打包过程中, 使用cloud-init预设一个带有简单密码的packer用户. 这些是通过JSON模板文件中下面这部分完成的:
"http_directory": "cloud-data",
"qemuargs": [
["-smbios", "type=1,serial=ds=nocloud-net;instance-id=packer;seedfrom=http://{
{ .HTTPIP }}:{
{ .HTTPPort }}/"]
],
这让Packer通过HTTP服务cloud-data目录, 然后cloud-init通过NoCloud数据源(Nocloud datasource)消费它. 参考cloud-init文档以理解user-data词条的意思.
清理
为了让Multipass能够消费此镜像, cloud-init需要去执行另一套指令, 所以需要重置. 镜像中的Packer用户需要被移除, 并且其他修改会被恢复(例如SSH密码授权). 这些是模板中设置过程的最后一步, 也不需要被解释.
你所作修改也有可能需要一些清理, 你可以挂载qemu镜像, 然后使用Meld工具比较这两个树(trees), 看看是否所有修改确实都是有意而为.
译者注: trees应被理解为git中的历史记录树
后续步骤
前往Packer文档学习关于QEMU编辑器, 其他设置过程和相关的配置, 和其他可能派上用场的内容. 可选方案, 你可以扩展user-data到其他cloud-init目录以扩充你的镜像.
请访问我们的讨论空间(our discourse space), 让我们了解你的镜像!
原文链接
边栏推荐
- CTF PHP audit bypasses filtering learning from topics
- numpy 索引及切片
- Sixtool- source code of multi-functional and all in one generation hanging assistant
- Alipay failed to verify the signature (sandbox test indicates fishing risk?) [original]
- 1.13 learning summary
- 一幅脑图总结一下需求分析(工作上实际遇到的情况的补充)
- SSH password free login, my server password free login to the other server, the other server password free login to your server
- Simple use of redis in laravel
- Video label forbids downloading. The test is valid. Hide button. The test is valid at three points
- Install cenos in the virtual machine
猜你喜欢

2021/11/6-burpsuit packet capturing and web page source code modification
![[H5 development] 02 take you to develop H5 list page ~ including query, reset and submission functions](/img/39/64df931d5ec54d7d19ae444fa372ba.jpg)
[H5 development] 02 take you to develop H5 list page ~ including query, reset and submission functions

Database design (3): database maintenance and optimization

35 year old programmer fired Luna millions of assets and returned to zero in three days. Netizen: it's the same as gambling

1.11 learning summary

企业的产品服务怎么进行口碑营销?口碑营销可以找人代做吗?
![ctf [RoarCTF 2019]easy_ calc](/img/c7/16adb8e4b64a4be2129a6c53c5aaa7.jpg)
ctf [RoarCTF 2019]easy_ calc
![[geek challenge 2019] rce me](/img/92/978c54fb42391198300c76ae92893d.jpg)
[geek challenge 2019] rce me

Svn error command revert error previous operation has not finished; run ‘ cleanup‘ if

PIP batch complete uninstall package
随机推荐
[Qunhui] Internet access + custom port
numpy 索引及切片
PHP syntax summary
PHP small factory moves bricks for three years - interview series - my programming life
MySQL index details
Thinkphp6 using kindeditor
Tips for using idea
1.14 learning summary
2021/11/6-burpsuit packet capturing and web page source code modification
Text horizontal alignment attribute text align and element vertical alignment attribute vertical align
Laravel file stream download file
An unexpected attempt (Imperial CMS list template filters spaces and newlines in smalltext introduction)
条件查询
NFT creation and binding of BSC and HT chains
MySQL enable logbin in Qunhui docker
Understand CGI and fastcgi
Nightmare
C generic
1064 (42000) error occurred when installing MySQL and modifying root password
Redis cache data consistency solution analysis