gke google

Update: 2020年7月25日 Resources with blog source code link

更新 :2020年7月25日资源与博客源代码链接

When deploying a web application, it is preferable to use a name like hello.mycompany.com rather than 34.98.86.241. This requires configuring DNS records when you deploy your web application, which be done with the Kubernetes add-on ExternalDNS.

部署Web应用程序时,最好使用诸如hello.mycompany.com类的名称,而不要使用34.98.86.241 。 这需要在部署Web应用程序时配置DNS记录,这需要使用Kubernetes完成 附加的ExternalDNS

This article covers how install configure ExternalDNS to integrate Cloud DNS with Google Kubernetes Engine (GKE), so that you can automatically configure DNS records when deploying web applications. We’ll demonstrate use this facility using these Endpoints:

本文介绍如何安装配置外部DNS 整合Cloud DNS 使用Google Kubernetes Engine ( GKE ),以便在部署Web应用程序时可以自动配置DNS记录。 我们将通过以下端点演示如何使用此功能:

  • Service Resource服务资源
  • Ingress Resource入口资源

以前的文章 (Previous Articles)

服务或入口端点 (Service or Ingress EndPoints)

In a previous article, we covered how to configure endpoints in GKE using either a service resource or an Ingress resource.

在上一篇文章中,我们介绍了如何在GKE中配置端点 使用服务资源或Ingress资源。

使用Cloud SDK进行配置 (Provisioning using Cloud SDK)

使用Terraform进行配置 (Provisioning using Terraform)

先决条件 (Prerequisites)

You will need to setup Google Cloud account and ownership of a registered domain name.

您将需要设置Google Cloud帐户和注册域名的所有权。

工具要求 (Tool Requirements)

  • Google Cloud SDK that is authorized to your google account.

    已授权您的Google帐户使用的Google Cloud SDK

  • Kubectl (pronounced koob-cuttle) is the Kubernetes client command line tool to interaction with the cluster and installing Kubernetes manifests.

    Kubectl (发音为koob-cuttle )是Kubernetes客户端命令行工具,用于与集群交互并安装Kubernetes清单。

  • Helm 3 to install packages called charts on the cluster. Helm charts are essentially packaged Kubernetes manifests templates.

    Helm 3在群集上安装称为图表的软件包。 Helm图表本质上是打包的Kubernetes清单模板。

Google Cloud Project和注册域名 (Google Cloud Project and Registered Domain)

You will also need the following requirements.

您还将需要满足以下要求。

  • registered domain or subdomain in Cloud DNS.

    Cloud DNS中的注册域或子域。

  • Single Project for both Cloud DNS and GKE.

    Cloud DNSGKE的单个项目

For this tutorial we’ll use the following fictional names:

在本教程中,我们将使用以下虚构名称:

  • Domain: test.acme.com.

    域: test.acme.com.

  • Zone: acme-test

    区域: acme-test

  • Project containing GKE and Cloud DNS: acme-quality-team

    项目GKE云DNSacme-quality-team

Replace the fictional names in the exercise with values that you have setup in your infrastructure.

用在基础架构中设置的值替换练习中的虚构名称。

测试云DNS (Testing Cloud DNS)

You can use gcloud dns record-sets list to verify you have a name server setup correctly.

您可以使用gcloud dns record-sets list来验证您是否正确设置了名称服务器。

gcloud dns record-sets list \ --project acme-quality-team \ --zone acme-test \ --filter "type=NS OR type=SOA" \ --format json

After creating an initial setup and registering a NS, you may see something like this from the above command.

创建初始设置并注册NS后,您可能会从上述命令中看到类似的内容。

创建GKE集群 (Creating the GKE Cluster)

In previous articles (see above), I covered how to provision GKE with either Google Cloud SDK or Terraform. You can follow through either of those articles to meet the requirements.

在之前的文章(请参见上文)中,我介绍了如何通过Google Cloud SDKTerraform来配置GKE。 您可以按照其中任何一篇文章进行操作以满足要求。

使用您自己的脚本配置GKE (Provision GKE with Your Own Scripts)

You can craft your own configuration scripts with tools like Terraform, Ansible, Pulumi to provision the GKE cluster. Be sure to include the following scope for the worker nodes:

您可以使用TerraformAnsiblePulumi之类的工具来制作自己的配置脚本,以配置GKE集群。 确保为工作程序节点包括以下范围:

"https://www.googleapis.com/auth/ndev.clouddns.readwrite"

示例Cloud SDK配置脚本 (Example Cloud SDK Provision Script)

I provided a small script here that you can use to stand up a cluster needed for this exercise:

我在这里提供了一个小脚本,您可以使用它来建立此练习所需的集群:

You can download and run this like this:

您可以像这样下载并运行:

# download scriptGIST_URL=https://gist.githubusercontent.com/darkn3rd/f913dc0876e9352999154b135e447ac4/raw/curl --silent $GIST_URL > create_gke_cluster.sh# run script:  create_gke_cluster.sh PROJECT CLUSTER_NAMEbash create_gke_cluster.sh acme-quality-team test-cluster

安装ExternalDNS (Installing ExternalDNS)

For installation of external-dns, we’ll use the bitnami/external-dns chart. We can add Bitnami’s Helm charts with this command:

要安装external-dns ,我们将使用bitnami/external-dns图表。 我们可以使用以下命令添加Bitnami的Helm图表:

helm repo add bitnami https://charts.bitnami.com/bitnami

Afterward, we need to create chart values that will override the default values. We can use these set of helm chart values.

之后,我们需要创建将覆盖默认值的图表值。 我们可以使用这些舵图 值集

Some things to note about these values.

关于这些值的一些注意事项。

  • policy is set to sync, which allows ExternalDNS to delete records. For test environments this is fine, but for environments where you do not want ExternalDNS to delete records, change this to upsert-only.

    policy设置为sync ,这允许ExternalDNS 删除记录。 对于测试环境,这很好,但是对于不需要外部DNS的环境, 要删除记录,请将其更改为upsert-only

  • domainFilters restricts domains that ExternalDNS can update.

    domainFilters限制ExternalDNS可以更新的域。

  • IMPORTANT: These settings only work if both the GKE cluster and the Cloud DNS are in the same project.

    重要说明 :仅当GKE群集和Cloud DNS都在同一项目中时,这些设置才有效。

Once you have a local copy of gcp-external-dns.values.yaml configured with the settings you want, you can install this into your GKE cluster with this command:

一旦使用所需设置配置了gcp-external-dns.values.yaml的本地副本,就可以使用以下命令将其安装到GKE群集中:

helm install "acme-externaldns" \  --values gcp-external-dns.values.yaml \  bitnami/external-dns

配置端点 (Configuring an EndPoint)

You can expose your application to an Endpoint that is accessible outside of your Kubernetes cluster using a Service resource or an Ingress resource.

您可以将应用程序公开给端点 可以使用服务资源或Ingress资源在Kubernetes集群外部访问该文件。

使用服务资源进行部署 (Deploy using an Service Resource)

A service resource will define logical set of pods and policy to access them. We’ll deploy a sample application, hello-kubernetes, using a service resource with a service type of LoadBalancer.

服务资源将定义Pod的逻辑集和访问它们的策略。 我们将使用服务类型为LoadBalancer的服务资源来部署示例应用程序hello-kubernetes

When defining our service resource, we use an annotation to configure the desired DNS record:

在定义我们的服务资源时,我们使用注释来配置所需的DNS记录:

external-dns.alpha.kubernetes.io/hostname: hello-svc.test.acme.com

Below is a manifest you can use to deploy this service. Save this as hello_k8s_lb.yaml.

以下是可用于部署此服务的清单。 将其另存为hello_k8s_lb.yaml

This manifest containers two resources:

此清单包含两个资源:

  • deployment controller to deploy three pods to the Kubernetes cluster部署控制器将三个Pod部署到Kubernetes集群
  • a service resource to provide access to those pods using a LoadBalancer type to get a public IP address, and through the external-dns annotation (line 27), register a DNS address record, e.g. hello-svc.test.acme.com, to point to the public IP address.

    服务资源以使用LoadBalancer提供对这些Pod的访问 键入以获取公共IP地址,并通过external-dns注释(第27行)注册DNS地址记录,例如hello-svc.test.acme.com ,以指向公共IP地址。

When ready to deploy run:

准备部署运行时:

kubectl apply --filename hello_k8s_lb.yaml

验证服务端点 (Verify Service EndPoint)

We can see the results in few moments by typing:

通过输入以下内容,我们很快就会看到结果:

kubectl get service --field-selector metadata.name=hello-k8s-lb

The results may look something similar to this:

结果可能类似于以下内容:

We can query CloudDNS with the glcoud dns record-sets list command to see if the DNS record was added:

我们可以使用glcoud dns record-sets list命令查询CloudDNS,以查看是否添加了DNS记录:

gcloud dns record-sets list \  --project acme-quality-team \  --zone acme-test \  --filter "name~hello-svc AND type=A" \  --format "table[box](name,type,ttl,rrdatas[0]:label=DATA)"

We should see a record added that looks something like this:

我们应该看到添加了一条类似于以下内容的记录:

测试服务端点的DNS地址 (Test the DNS Address for Service EndPoint)

You can point your web browser to http://hello-svc.test.acme.com and seem something like:

您可以将网络浏览器指向http://hello-svc.test.acme.com ,看起来像这样:

We can also use curl and filter out the pod name several times to see if we can hit all 3 pods:

我们还可以使用curl并多次过滤出豆荚名称,以查看是否可以打满所有3个豆荚:

MAX_TIMES=8for ((i=1; i<=$MAX_TIMES; i++)); do  curl --silent     awk --field-separator='>|<' '/hello-k8s-lb/{ print $3 }' done

The results will definitely vary. Chances are that we will touch all three pods:

结果肯定会有所不同。 我们很可能会碰到所有三个豆荚:

hello-k8s-lb-88c644b78-ckcd7hello-k8s-lb-88c644b78-2td6zhello-k8s-lb-88c644b78-2td6zhello-k8s-lb-88c644b78-ckcd7hello-k8s-lb-88c644b78-ckcd7hello-k8s-lb-88c644b78-x5vxdhello-k8s-lb-88c644b78-ckcd7hello-k8s-lb-88c644b78-2td6z

使用Ingress进行部署 (Deploy using an Ingress)

An Ingress resource exposes HTTP(S) routes from outside the cluster to services within the cluster, where L7 traffic is sent to the service resource by rules defined in the ingress resource configuration.

入口资源公开了从群集外部到群集内服务的HTTP(S)路由,其中​​L7流量通过入口资源配置中定义的规则发送到服务资源。

For this exercise, we’ll use the default ingress controller that comes with GKE called gce.

在本练习中,我们将使用GKE附带的默认入口控制器gce

We can define the desired DNS record by configuring a virtual hostname using the host key:

我们可以通过使用host密钥配置虚拟主机名来定义所需的DNS记录:

spec:  rules:    - host: 

Below is the full manifest that includes deployment, service, and ingress. Copy this and save it as hello_k8s_gce.yaml.

以下是包含部署,服务和入口的完整清单。 复制此文件并将其另存为hello_k8s_gce.yaml

NOTE: For the service resource, normally when using an ingress resource, you use a service type of ClusterIP, but this will not work with the default ingress on GKE, where only NodePort and LoadBalancer are supported. As we only wish to expose the hello-kubernetes application through the ingress, we chose NodePort.

注意 :对于服务资源 ,通常在使用入口资源时,使用的是ClusterIP服务类型,但这不适用于GKE上的默认入口,其中仅支持NodePortLoadBalancer 。 因为我们只希望通过入口公开hello-kubernetes应用程序,所以我们选择NodePort

For the ingress resource, the key host is used use to route on virtualhost and with ExternalDNS install will also configure DNS records on Cloud DNS. For this definition, we set an ingress class of gce to document we are using default ingress in GKE. This is not necessary, but generally a good practice to follow, and avoids side effects in case another ingress was configured as the new default.

对于入口资源 ,密钥host用于在虚拟主机上和与外部 DNS进行路由 安装还将在Cloud DNS上配置DNS记录。 对于此定义,我们将gce入口类设置为文档,以证明我们在GKE中使用默认入口。 这不是必需的,但通常是一个好的做法,并且在将另一个入口配置为新的默认值的情况下避免了副作用。

To deploy all of this, run the following command:

要部署所有这些,请运行以下命令:

kubectl apply --filename 

测试入口端点 (Testing the Ingress EndPoint)

After a few moments, you can the ingress created with:

片刻之后,您可以使用以下方法创建入口:

kubectl get ingress --field-selector metadata.name=hello-k8s-gce

This should show something like:

这应该显示如下内容:

We can check to see our DNS record is registered in Cloud DNS with:

我们可以检查一下我们的DNS记录是否已在Cloud DNS中通过以下方式注册:

gcloud dns record-sets list \  --project acme-quality-team \  --zone acme-test \  --filter "name~hello-ing AND type=A" \  --format "table[box](name,type,ttl,rrdatas[0]:label=DATA)"

This will show us something like the following:

这将向我们显示如下内容:

测试服务端点的DNS地址 (Test the DNS Address for Service EndPoint)

You can point your web browser to http://hello-ing.test.acme.com and seem something like:

您可以将网络浏览器指向http://hello-ing.test.acme.com ,看起来像这样:

Using the same URL, we can use curl to hit the DNS name a few times and filter for the pod name. We should be able to land on all three pods after a few tries:

使用相同的URL,我们可以使用curl多次单击DNS名称并过滤pod的名称。 经过几次尝试,我们应该能够在所有三个豆荚上着陆:

MAX_TIMES=8for ((i=1; i<=$MAX_TIMES; i++)); do  curl --silent     awk --field-separator='>|<' '/hello-k8s-gce/{ print $3 }' done

This should result in something like this, showing three different types of pods:

这应导致如下所示,显示三种不同类型的豆荚:

hello-k8s-gce-8686784b4f-d85qfhello-k8s-gce-8686784b4f-8xfvbhello-k8s-gce-8686784b4f-8xfvbhello-k8s-gce-8686784b4f-8xfvbhello-k8s-gce-8686784b4f-fmgqphello-k8s-gce-8686784b4f-d85qfhello-k8s-gce-8686784b4f-d85qfhello-k8s-gce-8686784b4f-8xfvb

资源资源 (Resources)

Here are some other articles and resources that you may find useful in the area of GKE + ExternalDNS + Cloud DNS.

以下是在GKE + ExternalDNS + Cloud DNS领域中可能有用的其他文章和资源。

博客源代码 (Blog Source Code)

  • https://github.com/darkn3rd/blog_tutorials/tree/master/kubernetes/gke_4_externaldns

    https://github.com/darkn3rd/blog_tutorials/tree/master/kubernetes/gke_4_externaldns

翻译自: https://medium.com/swlh/extending-gke-with-externaldns-d02c09157793

gke google


http://www.taodudu.cc/news/show-2460601.html

相关文章:

  • 带格式字符串反转
  • java 变位词,变位词 java
  • 学习笔记之Python的六种内置对象
  • C语言中的频率函数,请计算下列C语言程式片断或函数的频率计数和时间复杂度,如下所示 .DOC...
  • Python的6种内置对象
  • mysql套接字连接_无法通过Remote上的套接字连接到本地MySQL服务器
  • python_lintcode_52翻转字符串_128哈希函数
  • XYOJ1234出租车费
  • 【python学习笔记】Python的六种内置对象
  • C基础:45道练习题汇总(初学者加油)
  • 关于用数组实现输入字符串以单词为元素反转输出思路
  • 妙计旅行一面试题:字符串反转
  • 判断两个单词是否互为变位词,如“book”,“koob”,代码如下
  • 两个日期区间跨度是否超过一年,开始日期距当前日期是否超过一年——js实现
  • vue 判断元素内容是否超过宽度
  • 微信小程序打包超过2M 解决方法
  • sql in关键字使用长度超过1000问题处理
  • uniapp开发微信小程序,主包(分包超过限制)
  • Oracle in 不能超过1000的解决方案
  • csv文件超过104万数据怎么办
  • 饼图出现超过100%的比例——基础积累
  • elementUi——table表格中字段内容超过2行后,省略号...展示,不超过两行不处理。超过两行再显示全部。
  • web服务器超过访问上限显示,当Web服务器访问人数超过了设计访问人数上限,将可能出现的HTTP状态...
  • 超过2t硬盘分区_超过2T和3T及以上硬盘的MBR与GPT分区形式
  • AndroidStudio 导出AAB格式上传谷歌提示超过150M 解决方案
  • 一个USB设备超过其集线器端口的电源限制
  • java 判断时间24小时_Java 判断时间是否超过24小时
  • bert中最大处理序列长度超过512的处理策略
  • 苹果关掉200m限制_苹果下载超过200兆怎么设置
  • 给char赋超过范围的值会发生什么

gke google_使用ExternalDNS扩展GKE相关推荐

  1. 使用Spring Boot和Kubernetes构建微服务架构

    "我喜欢编写身份验证和授权代码." 〜从来没有Java开发人员. 厌倦了一次又一次地建立相同的登录屏幕? 尝试使用Okta API进行托管身份验证,授权和多因素身份验证. 在本教程 ...

  2. 从Kubernetes安全地访问AWS服务,告诉你多云场景下如何管理云凭据!

    作者| Alexey Ledenev 翻译 | 天道酬勤,责编 | Carol 出品 | CSDN云计算(ID:CSDNcloud) 随着企业与各种云提供商合作,多云场景已经变得十分常见. 在谷歌Ku ...

  3. 多云场景下,程序员该如何管理云凭据?

    作者| Alexey Ledenev 翻译 | 天道酬勤,责编 | Carol 出品 | CSDN云计算(ID:CSDNcloud) 随着企业与各种云提供商合作,多云场景已经变得十分常见. 在谷歌Ku ...

  4. 重磅!京东云自研第四代云主机发布;曝国外物理学家开发出用于量子计算机的汇编语言...

    开发者社区技术周刊又和大家见面了,快来看看这周有哪些值得我们开发者关注的重要新闻吧. 谷歌推出了GKE Autopilot用于交付Kubernetes 曝微软将发布基于Excel的低代码语言:Powe ...

  5. ultimate grid_Ultimate Kubernetes资源规划指南

    ultimate grid Understanding allocatable CPU/memory on Kubernetes nodes and optimizing resource usage ...

  6. 保姆级教程!手把手教你使用Longhorn管理云原生分布式SQL数据库!

    作者简介 Jimmy Guerrero,在开发者关系团队和开源社区拥有20多年的经验.他目前领导YugabyteDB的社区和市场团队. 本文来自Rancher Labs Longhorn是Kubern ...

  7. 国内外公有云容器服务备份恢复中文指南

    公众号关注 「奇妙的 Linux 世界」 设为「星标」,每天带你玩转 Linux ! 因为业务需求,需要针对自建的集群进行备份和恢复,所以针对国内外友商的容器服务备份恢复方案做了一个简单的调研分析. ...

  8. 加速业务交付,从 GKE 上使用 Kubernetes 和 Istio 开始

    原文来源于:谷歌云技术博客 许多企业机构正在把全部或部分 IT 业务迁移到云端,帮助企业更好的运营.不过这样的大规模迁移,在企业的实际操作中也有一定难度.不少企业保存在本地服务器的重要资源,并不支持直 ...

  9. (二)GKE上MLOps的Jenkins作业和部署

    目录 作业YAML文件 部署YAML文件 文件结构 下一步 在之前的系列文章中,我们解释了如何编写要在我们的Docker容器组中执行的脚本作为 CI/CD  MLOps管道的一部分.在本系列中,我们将 ...

  10. (一)在GKE上创建MLOps Kubernetes集群

    目录 Kubernetes简述 设置GKE集群 启动GKE集群 创建secrets.yaml文件 下一步 在之前的系列文章中,我们讨论了在一组Docker容器中作为CI/CD  MLOps管道的一部分 ...

最新文章

  1. 叛逆的仔:不听老板的话,还要用行动给老板来个响亮耳光!
  2. 库壳的一些有趣面试题
  3. android jni通过cmake使用第三方静态库和动态库
  4. 代码大全 MSIL语言程序设计
  5. Google File System 学习笔记
  6. 如何优化网页转化率?(下篇)
  7. neo4j 增 create
  8. Maven入门:使用Nexus搭建Maven私服及上传下载jar包
  9. 分子动力学模拟软件VMD的安装与使用
  10. 对主机或 Docker 镜像进行漏洞扫描
  11. python的计算_python计算smoothed PSSM(二)
  12. 终于得空,写两句了......
  13. 职业规划 软件开发职业规划的10个建议
  14. OpenFPGA系列(四) OpenFPGA 架构描述文件和仿真配置文件
  15. Redis 缓存清理策略
  16. 驱动开发:Win10内核枚举SSDT表基址
  17. Make it Divisible by 25
  18. 惠普HP LaserJet M5035 打印机驱动
  19. 将投影矩阵P利用QR分解分解出摄像机内外参数(Opencv)
  20. python键盘键值表_Python怎么记录键盘鼠标敲击次数|Python统计鼠标点击次数 - PS下...

热门文章

  1. 计算机语音发展,计算机语音合成技术研究及发展方向
  2. 达梦(DM)数据库常见问题详解
  3. CTFSHOW 愚人节欢乐赛WP
  4. android绘画时钟,Android画个时钟玩玩
  5. matlab突然打不开,点击运行没有任何反应
  6. 6410裸机加载linux内核,KG—Tiny6410裸机环境搭建(补充篇)
  7. python中head是什么意思_python爬虫中header是什么?怎么用?
  8. autocad2007二维图画法_CAD2007如何画平面图
  9. 闲谈IPv6-IPv4的TCP和NAT让互联网变得畸形
  10. 机器人三大定律只是人类的一厢情愿 AI可能并不遵守