钢铁侠头盔制作图纸下载_如何在10分钟内制作头盔图

钢铁侠头盔制作图纸下载

我每天的大部分时间都涉及创建,修改和部署Helm图表以管理应用程序的部署。 Helm是Kubernetes的应用程序包管理器,负责协调应用程序的下载,安装和部署。 Helm图表是我们将应用程序定义为相关Kubernetes资源的集合的方式。

那么,为什么有人会使用头盔? Helm通过模板化的方法使在Kubernetes内部管理应用程序部署更加容易。 所有Helm图表都遵循相同的结构,同时仍具有足够的灵活性以表示可以在Kubernetes上运行的任何类型的应用程序。 Helm还支持版本控制,因为可以保证部署需求会随时间变化。 替代方法是使用多个配置文件,这些文件手动应用于Kubernetes集群以启动应用程序。 如果我们从将基础结构视为代码中学到了任何东西,那就是手动处理不可避免地会导致错误。 Helm图表使我们有机会将相同的课程应用于Kubernetes领域。

在此示例中,我们将逐步介绍如何将Helm与minikube结合使用,minikube是Kubernetes的单节点测试环境。 我们将制作一个小的Nginx Web服务器应用程序。 对于此示例,我在Linux笔记本电脑上安装了minikube 1.9.2版和Helm 3.0.0版。 要进行设置,请执行以下操作。

创建舵图

首先确认我们已安装了先决条件:


   
   
$ which helm ## this can be in any folder as long as it returns in the path
/ usr / local / bin / helm
$ minikube status ## if it shows Stopped, run `minikube start`
host: Running
kubelet: Running
apiserver: Running
kubeconfig: Configured

启动新的Helm图表需要一个简单的命令:

 $  helm create mychartname 

就本教程而言,将图表命名为buildachart


   
   
$ helm create buildachart
Creating buildachart
$ ls buildachart/
Chart.yaml   charts/      templates/   values.yaml

检查图表的结构

现在,您已经创建了图表,请查看其结构以查看内部内容。 您看到的前两个文件Chart.yamlvalues.yaml定义了什么是图表以及在部署时其中将包含哪些值。

查看Chart.yaml ,您可以看到Helm图表结构的轮廓:


   
   
apiVersion : v2
name
: buildachart
description
: A Helm chart for Kubernetes

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type
: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
version
: 0.1.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application.
appVersion
: 1.16.0

第一部分包括图表正在使用的API版本(这是必需的),图表的名称以及图表的描述。 下一部分描述了图表的类型(默认情况下为应用程序),将要部署的图表的版本以及应用程序的版本(在进行更改时应递增)。

图表中最重要的部分是模板目录。 它包含将部署到群集中的应用程序的所有配置。 如下所示,该应用程序具有基本的部署,入口,服务帐户和服务。 该目录还包括一个测试目录,其中包括一个测试连接到应用程序的测试。 这些应用程序功能中的每一个都在templates /下具有其自己的模板文件:


   
   
$ ls templates/
NOTES.txt            _helpers.tpl         deployment.yaml      ingress.yaml         service.yaml         serviceaccount.yaml  tests/
charts ,它是空的。 它允许您添加部署应用程序所需的从属图表。 一些针对应用程序的Helm图表最多具有四个额外的图表,这些图表需要与主应用程序一起部署。 发生这种情况时,将使用每个图表的值来更新文件,以便同时配置和部署应用程序。 这是高级得多的配置(在本介绍性文章中我不会介绍),因此将图表/文件夹留空。

了解和编辑值

模板文件的格式设置可从values.yaml文件收集部署信息。 因此,要自定义Helm图表,您需要编辑值文件。 默认情况下, values.yaml文件如下所示:


   
   
# Default values for buildachart.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

replicaCount
: 1

image
:
  repository
: nginx
  pullPolicy
: IfNotPresent

imagePullSecrets
: [ ]
nameOverride
: ""
fullnameOverride
: ""

serviceAccount
:
  # Specifies whether a service account should be created
  create
: true
  # Annotations to add to the service account
  annotations
: { }
  # The name of the service account to use.
  # If not set and create is true, a name is generated using the fullname template
  name
:

podSecurityContext
: { }
  # fsGroup: 2000

securityContext
: { }
  # capabilities:
  #   drop:
  #   - ALL
  # readOnlyRootFilesystem: true
  # runAsNonRoot: true
  # runAsUser: 1000

service
:
  type
: ClusterIP
  port
: 80

ingress
:
  enabled
: false
  annotations
: { }
    # kubernetes.io/ingress.class: nginx
    # kubernetes.io/tls-acme: "true"
  hosts
:
    - host
: chart-example.local
      paths
: [ ]
  tls
: [ ]
  #  - secretName: chart-example-tls
  #    hosts:
  #      - chart-example.local

resources
: { }
  # We usually recommend not to specify default resources and to leave this as a conscious
  # choice for the user. This also increases chances charts run on environments with little
  # resources, such as Minikube. If you do want to specify resources, uncomment the following
  # lines, adjust them as necessary, and remove the curly braces after 'resources:'.
  # limits:
  #   cpu: 100m
  #   memory: 128Mi
  # requests:
  #   cpu: 100m
  #   memory: 128Mi

nodeSelector
: { }

tolerations
: [ ]

affinity
: { }

基本配置

从顶部开始,您可以看到repeaterCount自动设置为1,这意味着只会出现一个pod。 在此示例中,您只需要一个Pod,但是您可以看到告诉Kubernetes运行多个Pod以实现冗余是多么容易。

图像部分需要查看两件事:提取图像的存储库pullPolicy 。 pullPolicy设置为IfNotPresent ; 这意味着如果群集中不存在该映像,则该映像将下载该映像的新版本。 有两个其他选项: Always ,这意味着它将在每次部署或重新启动时拉映像(我总是建议在映像失败的情况下这样做),而Latest则将始终拉取最新版本的。可用的图像。 如果您相信映像存储库与部署环境兼容,则最新消息可能会很有用,但并非总是如此。

将值更改为Always

之前:


   
   
image :
  repository
: nginx
  pullPolicy
: IfNotPresent

后:


   
   
image :
  repository
: nginx
  pullPolicy
: Always

命名和秘密

接下来,查看图表中的替代。 第一个替代是imagePullSecrets ,它是提取秘密(例如,您已将其作为私有注册表的凭据生成的密码或API密钥)的设置。 接下来是nameOverridefullnameOverride 。 从您开始掌控create的那一刻起,它的名称(buildachart)就添加到了许多配置文件中-从上面的YAML文件到template / helper.tpl文件。 如果在创建图表后需要重命名图表,则此部分是执行此操作的最佳位置,因此您不会错过任何配置文件。

使用替代更改图表的名称。

之前:


   
   
imagePullSecrets : [ ]
nameOverride
: ""
fullnameOverride
: ""

后:


   
   
imagePullSecrets : [ ]
nameOverride
: "cherry-awesome-app"
fullnameOverride
: "cherry-chart"

帐目

服务帐户提供用户身份以在群集内的Pod中运行。 如果保留为空白,则将使用helpers.tpl文件根据全名生成名称。 我建议始终设置服务帐户,以便将应用程序直接与图表中控制的用户相关联。

作为管理员,如果使用默认服务帐户,则权限太少或太多,因此请更改此设置。

之前:


   
   
serviceAccount :
  # Specifies whether a service account should be created
  create
: true
  # Annotations to add to the service account
  annotations
: { }
  # The name of the service account to use.
  # If not set and create is true, a name is generated using the fullname template
  Name:

后:


   
   
serviceAccount :
  # Specifies whether a service account should be created
  create
: true
  # Annotations to add to the service account
  annotations
: { }
  # The name of the service account to use.
  # If not set and create is true, a name is generated using the fullname template
  Name
: cherrybomb

安全

您可以配置Pod安全性,以设置要使用的文件系统组类型或可以使用和不能使用哪个用户的限制。 了解这些选项对于保护Kubernetes吊舱很重要,但是在本示例中,我将不再赘述。


   
   
podSecurityContext : { }
  # fsGroup: 2000

securityContext
: { }
  # capabilities:
  #   drop:
  #   - ALL
  # readOnlyRootFilesystem: true
  # runAsNonRoot: true
  # runAsUser: 1000

联网

此图表中有两种不同类型的网络选项。 一个使用带有ClusterIP地址的本地服务网络,该网络将服务公开在群集内部的IP上。 选择此值可使与您的应用程序关联的服务仅可从群集内部访问(并通过ingress ,默认情况下设置为false )。 另一个网络选项是NodePort ,它在静态分配的端口上在每个Kubernetes节点的IP地址上公开服务。 建议使用此选项来运行minikube ,因此可将其用于此方法。

之前:


   
   
service :
  type
: ClusterIP
  port
: 80

ingress
:
  enabled
: false

后:


   
   
service :
  type
: NodePort
  port
: 80

ingress
:
  enabled
: false

资源资源

Helm允许您显式分配硬件资源。 您可以配置Helm图表可以请求的最大资源量以及可以接收的最大限制。 由于我在笔记本电脑上使用Minikube,因此我将通过删除花括号和哈希值(将注释转换为命令)来设置一些限制。

之前:


   
   
resources : { }
  # We usually recommend not to specify default resources and to leave this as a conscious
  # choice for the user. This also increases chances charts run on environments with little
  # resources, such as Minikube. If you do want to specify resources, uncomment the following
  # lines, adjust them as necessary, and remove the curly braces after 'resources:'.
  # limits:
  #   cpu: 100m
  #   memory: 128Mi
  # requests:
  #   cpu: 100m
  #   memory: 128Mi

后:


   
   
resources :
  # We usually recommend not to specify default resources and to leave this as a conscious
  # choice for the user. This also increases chances charts run on environments with little
  # resources, such as Minikube. If you do want to specify resources, uncomment the following
  # lines, adjust them as necessary, and remove the curly braces after 'resources:'.
   limits
:
     cpu
: 100m
     memory
: 128Mi
   requests
:
     cpu
: 100m
     memory
: 128Mi

公差,节点选择器和关联性

最后三个值基于节点配置。 尽管我无法在本地配置中使用它们中的任何一个,但我仍将说明它们的用途。

想要将应用程序的一部分分配给Kubernetes集群中的特定节点时, nodeSelector会派上用场。 如果您具有特定于基础架构的应用程序,则可以设置节点选择器名称,并在Helm图表中匹配该名称。 然后,在部署应用程序时,它将与匹配选择器的节点关联。

容差污点亲和力共同起作用,以确保Pod在单独的节点上运行。 节点相似性Pod的一种属性,可将Pod 吸引到一组节点上(作为首选项或硬性要求)。 污染是相反的-它们允许节点 排斥一组豆荚。

实际上,如果节点受到污染,则意味着该节点无法正常工作或可能没有足够的资源来容纳应用程序部署。 公差被设置为调度程序监视的键/值对,以确认节点将与部署一起使用。

节点相似性在概念上类似于nodeSelector:它使您可以根据节点上的标签来限制Pod可以调度哪些节点。 但是,标签不同,因为它们与适用于schedule的规则匹配。


   
   
nodeSelector : { }

tolerations
: [ ]

affinity
: { }

部署哦!

现在,您已经进行了必要的修改以创建Helm图表,可以使用Helm命令对其进行部署,在图表上添加名称点,添加值文件并将其发送到命名空间:


   
   
$ helm install my-cherry-chart buildachart/ --values buildachart/values.yaml
Release “my-cherry-chart” has been upgraded. Happy Helming!

该命令的输出将为您提供连接到应用程序的后续步骤,包括设置端口转发,以便您可以从本地主机访问该应用程序。 要遵循这些说明并连接到Nginx负载均衡器:


   
   
$ export POD_NAME=$ ( kubectl get pods -l "app.kubernetes.io/name=buildachart,app.kubernetes.io/instance=my-cherry-chart" -o jsonpath= "{.items[0].metadata.name}" )
$ echo "Visit http://127.0.0.1:8080 to use your application"
Visit http://127.0.0.1:8080 to use your application
$ kubectl port-forward $POD_NAME 8080:80
Forwarding from 127.0.0.1:8080 -> 80
Forwarding from [ ::1 ] :8080 -> 80

查看已部署的应用程序

要查看您的应用程序,请打开Web浏览器:

Nginx welcome screen

恭喜你! 您已经通过使用Helm图表部署了Nginx Web服务器!

在探索Helm图表可以做的事情时,有很多东西要学习。 如果您想再次检查您的工作,请访问我在GitHub上的示例存储库

翻译自: https://opensource.com/article/20/5/helm-charts

钢铁侠头盔制作图纸下载

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
实现这个任务,我们需要使用Python的一个形库——turtle。下面是实现绘制钢铁的代码: ```python import turtle # 设置画笔属性 turtle.pensize(5) turtle.pencolor('#D63433') turtle.fillcolor('#D63433') # 绘制头部 turtle.begin_fill() turtle.circle(100) turtle.end_fill() # 绘制眼睛 turtle.penup() turtle.goto(-50, 160) turtle.pendown() turtle.fillcolor('#FFFFFF') turtle.begin_fill() turtle.circle(20) turtle.end_fill() turtle.penup() turtle.goto(50, 160) turtle.pendown() turtle.begin_fill() turtle.circle(20) turtle.end_fill() # 绘制眼球 turtle.pencolor('#000000') turtle.fillcolor('#000000') turtle.penup() turtle.goto(-40, 170) turtle.pendown() turtle.begin_fill() turtle.circle(5) turtle.end_fill() turtle.penup() turtle.goto(40, 170) turtle.pendown() turtle.begin_fill() turtle.circle(5) turtle.end_fill() # 绘制嘴巴 turtle.pencolor('#000000') turtle.penup() turtle.goto(-50, 100) turtle.pendown() turtle.circle(50, 180) # 绘制身体 turtle.penup() turtle.goto(0, 0) turtle.pendown() turtle.fillcolor('#2D3436') turtle.begin_fill() turtle.forward(200) turtle.right(90) turtle.forward(150) turtle.right(90) turtle.forward(200) turtle.right(90) turtle.forward(150) turtle.end_fill() # 绘制胸部反光部分 turtle.penup() turtle.goto(0, 75) turtle.pendown() turtle.fillcolor('#FFFFFF') turtle.begin_fill() turtle.circle(50) turtle.end_fill() # 绘制手臂 turtle.penup() turtle.goto(-100, 0) turtle.pendown() turtle.fillcolor('#D63433') turtle.begin_fill() turtle.right(30) turtle.forward(100) turtle.left(60) turtle.forward(50) turtle.left(60) turtle.forward(100) turtle.end_fill() turtle.penup() turtle.goto(100, 0) turtle.pendown() turtle.fillcolor('#D63433') turtle.begin_fill() turtle.left(30) turtle.forward(100) turtle.right(60) turtle.forward(50) turtle.right(60) turtle.forward(100) turtle.end_fill() # 绘制手掌 turtle.penup() turtle.goto(-75, -50) turtle.pendown() turtle.fillcolor('#FFFFFF') turtle.begin_fill() turtle.circle(30) turtle.end_fill() turtle.penup() turtle.goto(75, -50) turtle.pendown() turtle.fillcolor('#FFFFFF') turtle.begin_fill() turtle.circle(30) turtle.end_fill() # 绘制腿 turtle.penup() turtle.goto(-50, -150) turtle.pendown() turtle.fillcolor('#D63433') turtle.begin_fill() turtle.right(30) turtle.forward(100) turtle.left(60) turtle.forward(50) turtle.left(60) turtle.forward(100) turtle.end_fill() turtle.penup() turtle.goto(50, -150) turtle.pendown() turtle.fillcolor('#D63433') turtle.begin_fill() turtle.left(30) turtle.forward(100) turtle.right(60) turtle.forward(50) turtle.right(60) turtle.forward(100) turtle.end_fill() turtle.penup() turtle.goto(-75, -200) turtle.pendown() turtle.fillcolor('#000000') turtle.begin_fill() turtle.circle(30) turtle.end_fill() turtle.penup() turtle.goto(75, -200) turtle.pendown() turtle.fillcolor('#000000') turtle.begin_fill() turtle.circle(30) turtle.end_fill() turtle.done() ``` 代码中,我们首先设置画笔属性,然后依次绘制头部、眼睛、眼球、嘴巴、身体、胸部反光部分、手臂、手掌、腿和脚。最后调用turtle.done()方法显示绘制结果。运行代码后,你将看到一个钢铁形象的绘制结果。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值