钢铁侠头盔制作图纸下载 |
您所在的位置:网站首页 › 自制钢铁侠头盔教程图纸简单 › 钢铁侠头盔制作图纸下载 |
钢铁侠头盔制作图纸下载 我每天的大部分时间都涉及创建,修改和部署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版。 要进行设置,请执行以下操作。 请按照此处的出色文档下载和配置minikube。 使用此处列出的您喜欢的软件包管理器下载或配置Helm ,或者从发行版中手动进行配置。 创建舵图首先确认我们已安装了先决条件: $ 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.yaml和values.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密钥)的设置。 接下来是nameOverride和fullnameOverride 。 从您开始掌控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浏览器: 恭喜你! 您已经通过使用Helm图表部署了Nginx Web服务器! 在探索Helm图表可以做的事情时,有很多东西要学习。 如果您想再次检查您的工作,请访问我在GitHub上的示例存储库 。 翻译自: https://opensource.com/article/20/5/helm-charts 钢铁侠头盔制作图纸下载 |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |