教程:在 Azure Stack HCI 上的 Azure Kubernetes 服务中部署 Linux 应用程序Tutorial: Deploy Linux applications in Azure Kubernetes Service on Azure Stack HCI

12/02/2020

本文内容

适用于 Azure Stack HCI 上的 AKS、Windows Server 2019 Datacenter 上的 AKS 运行时Applies to: AKS on Azure Stack HCI, AKS runtime on Windows Server 2019 Datacenter

在本教程中,你会在 Azure Stack HCI 上的 Azure Kubernetes 服务群集中部署包含 web 前端和 Redis 数据库实例的多容器应用程序。In this tutorial, you deploy a multi-container application that includes a web front end and a Redis database instance in your Azure Kubernetes Service on Azure Stack HCI cluster. 随后会了解如何测试和缩放应用程序。You then see how to test and scale your application.

本教程假定你对 Kubernetes 概念有基本的了解。This tutorial assumes a basic understanding of Kubernetes concepts.

开始之前Before you begin

验证是否已满足以下要求:Verify you have the following requirements ready:

Azure Stack HCI 上的 Azure Kubernetes 服务群集,其中至少有一个启动并运行的 Linux 工作器节点。An Azure Kubernetes Service on Azure Stack HCI cluster with at least one Linux worker node that is up and running.

用于访问群集的 kubeconfig 文件。A kubeconfig file to access the cluster.

安装了 Azure Stack HCI 上的 Azure Kubernetes 服务 PowerShell 模块。Have the Azure Kubernetes Service on Azure Stack HCI PowerShell module installed.

在 PowerShell 管理窗口中运行本文档中的命令。Run the commands in this document in a PowerShell administrative window.

确保特定于操作系统的工作负荷位于适当的容器主机上。Ensure that OS-specific workloads land on the appropriate container host. 如果具有混合 Linux 和 Windows 工作器节点 Kubernetes 群集,则可以使用节点选择器或是排斥和容许。If you have a mixed Linux and Windows worker nodes Kubernetes cluster, you can either use node selectors or taints and tolerations.

部署应用程序Deploy the application

Kubernetes 清单文件定义群集的所需状态,例如,要运行哪些容器映像。A Kubernetes manifest file defines a desired state for the cluster, such as what container images to run. 在本快速入门中,清单用于创建运行 Azure Vote 应用程序所需的所有对象。In this quickstart, a manifest is used to create all objects needed to run the Azure vote application. 此清单包括两个 Kubernetes 部署 - 一个用于 Azure Vote Python 示例应用程序,另一个用于 Redis 实例。This manifest includes two Kubernetes deployments - one for the sample Azure Vote Python applications, and the other for a Redis instance. 此外,还会创建两个 Kubernetes 服务 - 一个内部服务用于 Redis 实例,一个外部服务用于从 Internet 访问 Azure Vote 应用程序。Two Kubernetes services are also created - an internal service for the Redis instance, and an external service to access the Azure Vote application from the internet.

创建名为 azure-vote.yaml 的文件,并将其复制到以下 YAML 定义中。Create a file named azure-vote.yaml and copy in the following YAML definition.

apiVersion: apps/v1

kind: Deployment

metadata:

name: azure-vote-back

spec:

replicas: 1

selector:

matchLabels:

app: azure-vote-back

template:

metadata:

labels:

app: azure-vote-back

spec:

nodeSelector:

"beta.kubernetes.io/os": linux

containers:

- name: azure-vote-back

image: redis

resources:

requests:

cpu: 100m

memory: 128Mi

limits:

cpu: 250m

memory: 256Mi

ports:

- containerPort: 6379

name: redis

---

apiVersion: v1

kind: Service

metadata:

name: azure-vote-back

spec:

ports:

- port: 6379

selector:

app: azure-vote-back

---

apiVersion: apps/v1

kind: Deployment

metadata:

name: azure-vote-front

spec:

replicas: 1

selector:

matchLabels:

app: azure-vote-front

template:

metadata:

labels:

app: azure-vote-front

spec:

nodeSelector:

"beta.kubernetes.io/os": linux

containers:

- name: azure-vote-front

image: mcr.microsoft.com/azuredocs/azure-vote-front:v1

resources:

requests:

cpu: 100m

memory: 128Mi

limits:

cpu: 250m

memory: 256Mi

ports:

- containerPort: 80

env:

- name: REDIS

value: "azure-vote-back"

---

apiVersion: v1

kind: Service

metadata:

name: azure-vote-front

spec:

type: LoadBalancer

ports:

- port: 80

selector:

app: azure-vote-front

使用 kubectl apply 命令部署应用程序,并指定 YAML 清单的名称:Deploy the application using the kubectl apply command and specify the name of your YAML manifest:

kubectl apply -f azure-vote.yaml

以下示例输出显示已成功创建了部署和服务:The following example output shows the Deployments and Services created successfully:

deployment "azure-vote-back" created

service "azure-vote-back" created

deployment "azure-vote-front" created

service "azure-vote-front" created

测试应用程序Test the application

应用程序运行时,Kubernetes 服务将向 Internet 公开应用程序前端。When the application runs, a Kubernetes service exposes the application front end to the internet. 此过程可能需要几分钟才能完成。This process can take a few minutes to complete.

若要监视进度,请将 kubectl get service 命令与 --watch 参数配合使用。To monitor progress, use the kubectl get service command with the --watch argument.

kubectl get service azure-vote-front --watch

最初,azure-vote-front 服务的 EXTERNAL-IP 显示为 pending。Initially the EXTERNAL-IP for the azure-vote-front service is shown as pending.

NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE

azure-vote-front LoadBalancer 10.0.37.27 80:30572/TCP 22m

当 EXTERNAL-IP 地址从 pending 更改为实际公共 IP 地址时,请使用 CTRL-C 停止 kubectl 监视进程。When the EXTERNAL-IP address changes from pending to an actual public IP address, use CTRL-C to stop the kubectl watch process. 以下示例输出显示向服务分配了有效的公共 IP 地址:The following example output shows a valid public IP address assigned to the service:

NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE

azure-vote-front LoadBalancer 10.0.37.27 52.179.23.131 80:30572/TCP 24m

若要查看 Azure Vote 应用的实际效果,请打开 Web 浏览器并转到服务的外部 IP 地址。To see the Azure Vote app in action, open a web browser to the external IP address of your service.

缩放应用程序 PodScale application pods

我们已创建 Azure 投票前端和 Redis 实例的单个副本。We have created a single replica of the Azure Vote front end and Redis instance. 若要查看群集中 Pod 的数目和状态,请使用 kubectl get 命令,如下所示:To see the number and state of pods in your cluster, use the kubectl get command as follows:

kubectl get pods -n default

以下示例输出显示一个前端 pod 和一个后端 pod:The following example output shows one front end pod and one back-end pod:

NAME READY STATUS RESTARTS AGE

azure-vote-back-6bdcb87f89-g2pqg 1/1 Running 0 25m

azure-vote-front-84c8bf64fc-cdq86 1/1 Running 0 25m

若要更改 azure-vote-front 部署中的 Pod 数,请使用 kubectl scale 命令。To change the number of pods in the azure-vote-front deployment, use the kubectl scale command. 下面的示例将前端箱数增加到 5:The following example increases the number of front end pods to 5:

kubectl scale --replicas=5 deployment/azure-vote-front

再次运行 kubectl get pods,验证是否已创建了其他 Pod。Run kubectl get pods again to verify that additional pods have been created. 一分钟左右之后,其他 Pod 会在群集中提供:After a minute or so, the additional pods are available in your cluster:

kubectl get pods -n default

Name READY STATUS RESTARTS AGE

azure-vote-back-6bdcb87f89-g2pqg 1/1 Running 0 31m

azure-vote-front-84c8bf64fc-cdq86 1/1 Running 0 31m

azure-vote-front-84c8bf64fc-56h64 1/1 Running 0 80s

azure-vote-front-84c8bf64fc-djkp8 1/1 Running 0 80s

azure-vote-front-84c8bf64fc-jmmvs 1/1 Running 0 80s

azure-vote-front-84c8bf64fc-znc6z 1/1 Running 0 80s

后续步骤Next steps

linux hci0 进程,教程 - 在 Azure Stack HCI 上的 AKS 中部署 Linux 应用程序 - AKS-HCI | Microsoft Docs...相关推荐

  1. linux下把进程绑定到特定cpu核上运行

    现在大家使用的基本上都是多核cpu,一般是4核的.平时应用程序在运行时都是由操作系统管理的.操作系统对应用进程进行调度,使其在不同的核上轮番运行. 对于普通的应用,操作系统的默认调度机制是没有问题的. ...

  2. linux关闭无响应文件夹,4种强制关闭Ubuntu中无响应应用程序的方法

    4种强制关闭Ubuntu中无响应应用程序的方法 在使用Ubuntu时,我们的一个或多个进程和应用程序可能会经常挂起.重新启动我们的系统并不总是最佳解决方案,我们发现自己在寻找能够快速.轻松和安全地摆脱 ...

  3. 在vmware server中部署linux redhat 5.4 ORACLE RAC11g +ASM

    在vmware server中部署ORACLE RAC 11g 部署oracle rac on redhat5.4 第一部分   准备环境: 1.  硬件配置 电脑:I3, 8G, 500G 虚机配置 ...

  4. linux怎么在终端里查系统信息,Neofetch:在终端中显示Linux系统信息

    Neofetch 是一个简单但有用的命令行系统信息工具,它用 Bash 编写.它会收集有关系统软硬件的信息,并在终端中显示结果.默认情况下,系统信息将与操作系统的 logo 一起显示.但是,你可以进一 ...

  5. linux模拟树莓派,树莓派使用入门:树莓派上的模拟器和原生 Linux 游戏

    原标题:树莓派使用入门:树莓派上的模拟器和原生 Linux 游戏 树莓派是一个很棒的游戏平台.在我们的系列文章的第九篇中学习如何开始使用树莓派. -- Anderson Silva 回到我们关于树莓派 ...

  6. 如何安装腾讯视频linux版,在优麒麟Ubuntu Kylin系统上安装腾讯视频Linux版DEB软件包...

    本文教你在优麒麟Ubuntu Kylin系统上安装腾讯视频Linux版Tenvideo_universal_1.0.10_amd64.deb软件包的方法. 一.下载腾讯视频Linux版客户端 由于优麒 ...

  7. qc linux mysql 安装教程_mysql5.7在centos上安装的完整教程以及相关的“坑”

    安装前的准备 Step1: 如果你系统已经有mysql,如一般centos自带mysql5.1系列,那么你需要删除它,先检查一下系统是否自带mysql yum list installed | gre ...

  8. linux gns3使用教程,《GNS3实战指南》——2.4 在Ubuntu Linux上安装

    本节书摘来自异步社区<GNS3实战指南>一书中的第2章,第2.4节,做者: [美]Jason C. Neumann(詹森 C. 诺伊曼) 更多章节内容能够访问云栖社区"异步社区& ...

  9. linux c 进程策略 优先级,当两个线程拥有相同优先级时,linux c的线程调度策略问题...

    /* critical.c * * compile with gcc critical.c -o critical -lrt -lpthread * * 当主线程和A,B优先级相同时,结果为aaaaa ...

  10. linux安装nuke教程下载,Nuke7.0v8下载为windonws、Mac和Linux

    <安装说明> 单台机器安装: 1.安装Foundry旗下的软件,如:NUKE,MARI,HIERO等. 2.安装FLT7,打开FLT7.0v2文件夹找当相应操作系统的版本安装. (tar ...

最新文章

  1. 公路病害检测有了“智慧眼”,思谋AI“助力”广东省高速公路
  2. PMP-【第4章 项目整合管理】-2021-1-18(88页-115页)
  3. 用户思维模型,围绕用户核心四大模块,拉新、养熟、成交、裂变循环的效果...
  4. java 参数代替所有类_Java中的常用类
  5. 解决为什么JDK要带着JRE一起下载
  6. Shiro Shiro Web Support and EnvironmentLoaderListener
  7. 接口测试--apipost如何自定义header中的content-type
  8. Redis info信息(转载)
  9. android studio无app项,Android studio 3.0:无法解析依赖:app @ dexOptions
  10. 网易云课堂测试微专业前置课
  11. 表上作业法求解运输问题----python生成初始解
  12. exec还原oracle,symantec Backup exec 恢复Recovery Oracle 数据库
  13. 微信网页第三方登录原理
  14. 云知声终止IPO:持续亏损7.9亿、毛利率低于行业均值、市场份额被指“造假”
  15. Lync2013扩展开发
  16. C语言lseek()函数和 fseek()函数 rewind函数
  17. 如果真的存在外星人,AI终将找到它
  18. 全国计算机四级——操作系统原理笔记
  19. js对日期加减指定天、时、分、秒
  20. 随机获取歌曲信息播放php,网易云热评随机获取PHP代码

热门文章

  1. mipi的dsi全称_高通mipi dsi代码理解
  2. linux测试upnp,UPnP linux新手入门
  3. python抓取网页图片示例
  4. win10 u盘 修复计算机,怎么用u盘修复windows10专业版系统
  5. 黑暗幽灵(DCM)木马详细分析
  6. 逻辑推理题-用C++实现(2)--黑与白
  7. hive函数中的operators, UDF, UDAF, UDTF, PTF
  8. SAS数据导入input要点
  9. 纽约州立石溪分校计算机科学排名,2019上海软科世界一流学科排名计算机科学与工程专业排名纽约州立大学石溪分校排名第101-150...
  10. 专访京东科技张亮:本土开源需形成吸纳开发者的靶心