教程:使用社区模板创建 VMTutorial: Create a VM using a community template

Azure Stack Hub 操作员或用户可以使用自定义 GitHub 快速入门模板来创建虚拟机 (VM),不需通过 Azure Stack Hub 市场来手动部署模板。As an Azure Stack Hub operator or user, you can create a virtual machine (VM) using custom GitHub quickstart templates rather than deploying a template manually from the Azure Stack Hub Marketplace.

本教程介绍如何执行下列操作:In this tutorial, you learn how to:

  • 使用 Azure Stack Hub 快速启动模板Use Azure Stack Hub quickstart templates
  • 使用自定义 GitHub 模板创建 VMCreate a VM using a custom GitHub template
  • 启动 Minikube 并安装应用程序Start Minikube and install an application

Azure Stack Hub 快速启动模板Azure Stack Hub quickstart templates

Azure Stack Hub 快速启动模板存储在 GitHub 上的全球 Azure Stack Hub 快速启动模板存储库中。Azure Stack Hub quickstart templates are stored in the GitHub global Azure Stack Hub quickstart templates repository. 此存储库包含的 Azure 资源管理器部署模板已经使用 Microsoft Azure Stack 开发工具包 (ASDK) 测试过。This repo contains Azure Resource Manager deployment templates that have been tested with the Microsoft Azure Stack Development Kit (ASDK). 可以通过这些模板更轻松地评估 Azure Stack Hub 并使用 ASDK 环境。You can use them to make it easier for you to evaluate Azure Stack Hub and use the ASDK environment.

许多 GitHub 用户不断地向存储库贡献模板,使集合中的部署模板数已超过 400 个。Over time, many GitHub users have contributed to the repo, resulting in a collection of more than 400 deployment templates. 可以从此存储库着手,更好地了解如何将各种环境部署到 Azure Stack Hub。This repo is a good starting point for understanding how you can deploy various kinds of environments to Azure Stack Hub.

重要

这些模板中的部分模板是由社区成员创建的,不是由 Microsoft 创建的。Some of these templates are created by members of the community and not by Microsoft. 每个模板按照其所有者而非 Microsoft 的许可协议进行许可。Each template is licensed under a license agreement by its owner, not Microsoft. Microsoft 不对这些模板负责,也不检查其安全性、符合性或性能方面的问题。Microsoft is not responsible for these templates and does not screen for security, compatibility, or performance. 社区模板不受任何 Microsoft 支持计划或服务的支持,按“原样”提供,且没有任何形式的保证。Community templates are not supported under any Microsoft support program or service, and are made available "AS IS," without warranty of any kind.

若要将 Azure 资源管理器模板贡献给 GitHub,请将其添加到 AzureStack-QuickStart-Templates 存储库。If you want to contribute Azure Resource Manager templates to GitHub, make your contribution to the AzureStack-QuickStart-Templates repo. 若要详细了解此存储库,以及如何向其贡献内容,请参阅自述文件To learn more about this repo and how to contribute to it, see the readme file.

使用自定义 GitHub 模板创建 VMCreate a VM using a custom GitHub template

在本示例教程中,101-vm-linux-minikube Azure Stack Hub 快速启动模板用于在运行 Minikube 的 Azure Stack Hub 上部署 Ubuntu 16.04 VM 来管理 Kubernetes 群集。In this example tutorial, the 101-vm-linux-minikube Azure Stack Hub quickstart template is used to deploy an Ubuntu 16.04 VM on Azure Stack Hub running Minikube to manage a Kubernetes cluster.

Minikube 是一种工具,方便用户在本地运行 Kubernetes。Minikube is a tool that makes it easy to run Kubernetes locally. Minikube 在 VM 中运行单节点 Kubernetes 群集,使你可以试用 Kubernetes 或使用它进行日常开发。Minikube runs a single-node Kubernetes cluster inside a VM, enabling you to try out Kubernetes or develop with it day-to-day. 它支持在 Linux VM 上运行的简单的单节点 Kubernetes 群集。It supports a simple, one-node Kubernetes cluster running on a Linux VM. Minikube 是运行功能齐全的 Kubernetes 群集的最快、最直接的方法。Minikube is the fastest and most straightforward way to get a fully functional Kubernetes cluster running. 开发人员可以使用它在本地计算机上开发和测试基于 Kubernetes 的应用程序部署。It enables developers to develop and test their Kubernetes-based application deployments on their local machines. 从体系结构来说,Minikube VM 同时在本地运行主节点组件和代理节点组件:Architecturally, the Minikube VM runs both master and agent node components locally:

  • 主节点组件(例如 API 服务器、计划程序和 etcd 服务器)在名为 LocalKube 的单个 Linux 进程中运行。Master node components such as API Server, Scheduler, and etcd Server are run in a single Linux process called LocalKube.
  • 代理节点组件在 Docker 容器中运行,运行方式与在正常代理节点上的运行方式一样。Agent node components are run inside docker containers exactly as they would run on a normal agent node. 从应用程序部署角度来看,将应用程序部署在 Minikube 上与部署在常规 Kubernetes 群集上并无区别。From an application deployment standpoint, there's no difference between deploying the application on a Minikube or in a regular Kubernetes cluster.

此模板安装以下组件:This template installs the following components:

重要

在执行这些步骤之前,必须已将 Ubuntu VM 映像(在此示例中为 Ubuntu Server 16.04 LTS)添加到 Azure Stack Hub 市场。The Ubuntu VM image (Ubuntu Server 16.04 LTS, in this example) must already have been added to the Azure Stack Hub Marketplace before performing these steps.

  1. 依次选择“+ 创建资源”、“自定义”、“模板部署”。 Select + Create a resource, then Custom, then Template deployment.

    创建模板

  2. 选择“编辑模板”。Select Edit template.

    编辑模板

  3. 选择“快速入门模板”。Select Quickstart template.

    快速入门模板

  4. 使用“选择模板”下拉列表从可用模板中选择 101-vm-linux-minikube,然后单击“确定”。Select 101-vm-linux-minikube from the available templates using the Select a template dropdown list, and then click OK.

    选择模板

  5. 如果要对模板 JSON 进行修改,可以这样做。If you want to make modifications to the template JSON, you can do so. 如果不想要进行修改或者已完成操作,请选择“保存”关闭“编辑模板”对话框。 If not, or when complete, select Save to close the Edit template dialog.

    保存模板

  6. 选择“参数”,根据需要填充或修改适用的字段,然后单击“确定”。 Select Parameters, fill in or modify the available fields as necessary, and then click OK.

    parameters

  7. 选择要使用的订阅,然后创建或选择现有的资源组名称。Choose the subscription to use and then create or choose an existing resource group name. 然后,选择“创建”以开始部署模板。Then, select Create to start the template deployment.

    选择订阅

  8. 资源组部署需要数分钟的时间来创建基于模板的自定义 VM。The resource group deployment takes several minutes to create the custom template-based VM. 可以通过通知和资源组属性来监视安装状态。You can monitor the installation status through notifications and from the resource group properties.

    部署

    备注

    部署完成后,VM 将处于运行状态。The VM will be running when the deployment completes.

启动 Minikube 并安装应用程序Start Minikube and install an application

成功创建 Linux VM 后,可以登录,以便启动 Minikube 并安装应用程序。Now that the Linux VM has been successfully created, you can sign in to start Minikube and install an application.

  1. 部署完成后,请选择“连接”,以查看要用来连接到 Linux VM 的公共 IP 地址。After the deployment completes, select Connect to view the public IP address that will be used to connect to the Linux VM.

    连接

  2. 在提升的命令提示符下运行 mstsc.exe,打开远程桌面连接并连接到在上一步发现的 Linux VM 的公共 IP 地址。From an elevated command prompt, run mstsc.exe to open Remote Desktop Connection and connect to the Linux VM public IP address discovered in the previous step. 当系统提示你登录 xRDP 时,请使用在创建 VM 时指定的凭据。When prompted to sign in to xRDP, use the credentials you specified when creating the VM.

    Remote

  3. 打开终端模拟器并输入以下命令,启动 Minikube:Open Terminal Emulator and enter the following commands to start Minikube:

    sudo minikube start --vm-driver=none
    sudo minikube addons enable dashboard
    sudo minikube dashboard --url
    

    运行命令

  4. 打开浏览器,访问 Kubernetes 仪表板地址。Open a browser and go to the Kubernetes dashboard address. 祝贺你,现已使用 Minikube 完成了一个功能完全正常的 Kubernetes 安装!Congratulations, you now have a fully working Kubernetes installation using Minikube!

    仪表板

  5. 若要部署示例应用程序,请访问 Kubernetes 的官方文档页,跳过“创建 Minikube 群集”部分,因为已经创建了一个。To deploy a sample application, visit the official Kubernetes documentation page, and skip the "Create Minikube Cluster" section as you've already created one. 转到创建 Node.js 应用程序部分。Go to the section Create your Node.js application.

后续步骤Next steps

在本教程中,你已学习了如何执行以下操作:In this tutorial, you learned how to:

  • 了解 Azure Stack Hub 快速启动模板Learn about Azure Stack Hub quickstart templates
  • 使用自定义 GitHub 模板创建 VMCreate a VM using a custom GitHub template
  • 启动 minikube 并安装应用程序Start minikube and install an application