优书网小说台州专业关键词优化

当前位置: 首页 > news >正文

优书网小说,台州专业关键词优化,做我女朋友套路网站,优秀网站建设价格Helm 1、引入2、概述2.1 重点2.2 V3版本的Helm2.2.1 与之前版本的不同之处2.2.2 V3版本的运行流程 3、安装和配置仓库、一些附带操作3.1 安装3.2 配置仓库3.3 常用命令3.4 添加helm的自动补齐 4、快速部署应用(weave应用)5、 自行创建Chart5.1 Chart目录内容解析5.2 简单安装部… Helm 1、引入2、概述2.1 重点2.2 V3版本的Helm2.2.1 与之前版本的不同之处2.2.2 V3版本的运行流程 3、安装和配置仓库、一些附带操作3.1 安装3.2 配置仓库3.3 常用命令3.4 添加helm的自动补齐 4、快速部署应用(weave应用)5、 自行创建Chart5.1 Chart目录内容解析5.2 简单安装部署5.3 应用升级回退 6、Chart模板实现高效复用6.1 在values.yaml文件中定义全局变量6.2 在templates中的yaml文件中定义变量 1、引入 K8S 上的应用对象都是由特定的资源描述组成包括 deployment、service 等。都保存 各自文件中或者集中写到一个配置文件。然后 kubectl apply –f 部署。如果应用只由一 个或几个这样的服务组成上面部署方式足够了。而对于一个复杂的应用会有很多类似 上面的资源描述文件例如微服务架构应用组成应用的服务可能多达十个几十个。如 果有更新或回滚应用的需求可能要修改和维护所涉及的大量资源文件而这种组织和管 理应用的方式就显得力不从心了。且由于缺少对发布过的应用版本管理和控制使 Kubernetes 上的应用维护和更新等面临诸多的挑战主要面临以下问题1如何将这 些服务作为一个整体管理 2这些资源文件如何高效复用 3不支持应用级别的版本管理 2、概述 2.1 重点 Helm 是一个 Kubernetes 的包管理工具就像 Linux 下的包管理器如 yum/apt 等可以 很方便的将之前打包好的 yaml 文件部署到 kubernetes 上。Helm 有 3 个重要概念 1helm一个命令行客户端工具主要用于 Kubernetes 应用 chart 的创建、打包、发 布和管理。 2Chart简单理解就是把yaml文件进行打包是yaml文件的集合。官方描述为应用描述一系列用于描述 k8s 资源相关文件的集合。 3Release基于 Chart 的部署实体。一个 chart 被 Helm 运行后将会生成对应的一个 release将在 k8s 中创建出真实运行的资源对象。通俗来说每次部署后都会对应一个版本也是所说的release。主要是为了进行版本管理。 2.2 V3版本的Helm 2.2.1 与之前版本的不同之处 删除了Tillerrelease可以在不同命名空间中进行重用可以将Chart直接推送到docker镜像仓库中 2.2.2 V3版本的运行流程 3、安装和配置仓库、一些附带操作 3.1 安装 官网下载V3版本Helm [rootmaster helm]# tar zxvf helm-v3.8.2-linux-amd64.tar.gz linux-amd64/ linux-amd64/helm linux-amd64/LICENSE linux-amd64/README.md [rootmaster helm]# ls helm-v3.0.0-linux-amd64.tar.gz helm-v3.8.2-linux-amd64.tar.gz linux-amd64 [rootmaster helm]# cd linux-amd64/ [rootmaster linux-amd64]# ls helm LICENSE README.md [rootmaster linux-amd64]# mv helm /usr/bin/ #移动
3.2 配置仓库 ##添加仓库 helm repo add 自己起仓库名字 仓库地址 [rootmaster ~]# helm repo add stable http://mirror.azure.cn/kubernetes/charts ##添加微软仓库 stable has been added to your repositories [rootmaster ~]# helm repo add aliyun https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts 添加阿里云仓库 aliyun has been added to your repositories [rootmaster ~]# helm repo update ##更新仓库[rootmaster ~]# helm repo list ##列出仓库信息 NAME URL
stable http://mirror.azure.cn/kubernetes/charts
aliyun https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts[rootmaster ~]# helm repo remove stable ##删除仓库 stable has been removed from your repositories [rootmaster ~]# helm repo list NAME URL
aliyun https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts3.3 常用命令 命令描述dependency管理 chart 依赖get下载一个 release。可用子命令all、hooks、manifest、notes、valueshistory获取 release 历史install安装一个 chartlist列出 releasepackage将 chart 目录打包到 chart 存档文件中pull从远程仓库中下载 chart 并解压到本地 # helm pull stable/mysql – untarrepo添加列出移除更新和索引 chart 仓库。可用子命令add、index、 list、remove、updaterollback从之前版本回滚search根据关键字搜索 chart。可用子命令hub、reposhow查看 chart 详细信息。可用子命令all、chart、readme、valuesstatus显示已命名版本的状态template本地呈现模板uninstall卸载一个 releaseupgrade更新一个 releaseversion查看 helm 客户端版本 3.4 添加helm的自动补齐 [rootmaster bash_completion.d]# echo source (helm completion bash) ~/.bash_profile [rootmaster bash_completion.d]# source ~/.bash_profile [rootmaster bash_completion.d]# helm completion bash /usr/share/bash-completion/completions/helm 4、快速部署应用(weave应用) [rootmaster ~]# helm install ui aliyun/weave-scope #出现下面错误是因为仓库的问题阿里云可能没事实时匹配到k8s换成微软源可以解决 Error: INSTALLATION FAILED: unable to build kubernetes objects from release manifest: [unable to recognize : no matches for kind DaemonSet in version extensions/v1beta1, unable to recognize : no matches for kind Deployment in version apps/v1beta1][rootmaster ~]# helm repo add stable http://mirror.azure.cn/kubernetes/charts/ ##添加微软仓库 [rootmaster ~]# helm repo update [rootmaster ~]# helm repo list NAME URL
aliyun https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts stable http://mirror.azure.cn/kubernetes/charts/ ##部署
[rootmaster ~]# helm search repo weave ##部署的是一个ui界面应用所以需要对外暴露端口需要查看SVC的状态是否为NodePort NAME CHART VERSION APP VERSION DESCRIPTION
aliyun/weave-cloud 0.1.2 Weave Cloud is a add-on to Kubernetes which pro… aliyun/weave-scope 0.9.2 1.6.5 A Helm chart for the Weave Scope cluster visual… stable/weave-cloud 0.3.9 1.4.0 DEPRECATED - Weave Cloud is a add-on to Kuberne… stable/weave-scope 1.1.12 1.12.0 DEPRECATED - A Helm chart for the Weave Scope c…##helm install 自己起的名称 仓库里包的名称 [rootmaster ~]# helm install ui stable/weave-scope WARNING: This chart is deprecated W0514 11:23:29.545784 20101 warnings.go:70] rbac.authorization.k8s.io/v1beta1 ClusterRole is deprecated in v1.17, unavailable in v1.22; use rbac.authorization.k8s.io/v1 ClusterRole W0514 11:23:29.546481 20101 warnings.go:70] rbac.authorization.k8s.io/v1beta1 ClusterRoleBinding is deprecated in v1.17, unavailable in v1.22; use rbac.authorization.k8s.io/v1 ClusterRoleBinding W0514 11:23:29.567192 20101 warnings.go:70] rbac.authorization.k8s.io/v1beta1 ClusterRole is deprecated in v1.17, unavailable in v1.22; use rbac.authorization.k8s.io/v1 ClusterRole W0514 11:23:29.569900 20101 warnings.go:70] rbac.authorization.k8s.io/v1beta1 ClusterRoleBinding is deprecated in v1.17, unavailable in v1.22; use rbac.authorization.k8s.io/v1 ClusterRoleBinding NAME: ui LAST DEPLOYED: Sat May 14 11:23:29 2022 NAMESPACE: default STATUS: deployed REVISION: 1 NOTES: You should now be able to access the Scope frontend in your web browser, by using kubectl port-forward:kubectl -n default port-forward \((kubectl -n default get endpoints \ ui-weave-scope -o jsonpath{.subsets[0].addresses[0].targetRef.name}) 8080:4040then browsing to http://localhost:8080/. For more details on using Weave Scope, see the Weave Scope documentation:https://www.weave.works/docs/scope/latest/introducing/[rootmaster ~]# helm list ##查看部署的应用 NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION ui default 1 2022-05-14 11:23:29.478377222 0800 CST deployed weave-scope-1.1.12 1.12.0 [rootmaster ~]# helm status ui #查看部署应用的状态 NAME: ui LAST DEPLOYED: Sat May 14 11:23:29 2022 NAMESPACE: default STATUS: deployed REVISION: 1 NOTES: You should now be able to access the Scope frontend in your web browser, by using kubectl port-forward: kubectl -n default port-forward \)(kubectl -n default get endpoints
ui-weave-scope -o jsonpath{.subsets[0].addresses[0].targetRef.name}) 8080:4040 then browsing to http://localhost:8080/. For more details on using Weave Scope, see the Weave Scope documentation: https://www.weave.works/docs/scope/latest/introducing/##查看部署情况 [rootmaster ~]# kubectl get pods ##查看部署的pod NAME READY STATUS RESTARTS AGE weave-scope-agent-ui-d7fv8 11 Running 0 9m21s weave-scope-agent-ui-mrnb5 11 Running 0 9m21s weave-scope-agent-ui-nrtrn 11 Running 0 9m21s weave-scope-cluster-agent-ui-5cbc84db49-fzf7f 11 Running 0 9m21s weave-scope-frontend-ui-6698fd5545-pn8tc 11 Running 0 9m21s web-96d5df5c8-zcshb 11 Running 1 15h [rootmaster ~]# kubectl get svc ##ui-weave-scope的svc状态没有暴露端口 NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE kubernetes ClusterIP 10.96.0.1 none 443/TCP 65d ui-weave-scope ClusterIP 10.101.125.54 none 80/TCP 9m25s web NodePort 10.96.63.223 none 80:31281/TCP 15h
[rootmaster ~]# kubectl edit svc ui-weave-scope ## 编辑内部yaml文件将状态换为NodePort service/ui-weave-scope edited [rootmaster ~]# kubectl describe svc ui-weave-scope Name: ui-weave-scope Namespace: default Labels: appweave-scopeapp.kubernetes.io/managed-byHelmchartweave-scope-frontend-1.1.10componentfrontendheritageHelmreleaseui Annotations: cloud.weave.works/launcher-info:{server-version: master-4fe8efe,original-request: {url: /k8s/v1.7/scope.yaml},email-address: supportweave.works,source-app: weave-scope,weave-cloud-component: scope}meta.helm.sh/release-name: uimeta.helm.sh/release-namespace: default Selector: appweave-scope,componentfrontend,releaseui Type: NodePort ##状态已经修改 IP Families: none IP: 10.101.125.54 IPs: 10.101.125.54 Port: http 80/TCP TargetPort: http/TCP NodePort: http 31055/TCP Endpoints: 10.244.2.36:4040 Session Affinity: None External Traffic Policy: Cluster Events: none [rootmaster ~]# kubectl get svc NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE kubernetes ClusterIP 10.96.0.1 none 443/TCP 65d ui-weave-scope NodePort 10.101.125.54 none 80:31055/TCP 15m web NodePort 10.96.63.223 none 80:31281/TCP 15h 最终布置效果
5、 自行创建Chart 5.1 Chart目录内容解析 chart.yaml 指当前chart属性配置信息templates 编写的yaml文件放到当前目录values.yaml yaml文件可以使用全局变量 5.2 简单安装部署 [rootmaster ~]# helm create mychart ##创建Chart[rootmaster ~]# cd mychart/ [rootmaster mychart]# ls charts Chart.yaml templates values.yaml [rootmaster mychart]# cd templates/ [rootmaster templates]# ls deployment.yaml hpa.yaml NOTES.txt service.yaml
_helpers.tpl ingress.yaml serviceaccount.yaml tests[rootmaster mychart]# kubectl create deployment web1 –imagenginx –dry-run -o yaml deployment.yaml[rootmaster mychart]# kubectl create deployment web1 –imagenginx ##后续创建svc需要web1存在 [rootmaster templates]# kubectl expose deployment web1 –port80 –target-port80 –typeNodePort –dry-run -o yaml service.yaml ##创建service.yaml [rootmaster ~]# kubectl delete deployments.apps web1 ##删除一会通过helm进行安装 [rootmaster templates]# ls deployment.yaml service.yaml# helm安装 [rootmaster ~]# helm install web1 mychart/ ##install 自己起名称 Chart目录 NAME: web1 LAST DEPLOYED: Sat May 14 20:15:51 2022 NAMESPACE: default STATUS: deployed REVISION: 1 TEST SUITE: None [rootmaster ~]# kubectl get svc NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE kubernetes ClusterIP 10.96.0.1 none 443/TCP 66d ui-weave-scope NodePort 10.101.125.54 none 80:31055/TCP 8h web NodePort 10.96.63.223 none 80:31281/TCP 24h web1 NodePort 10.108.249.102 none 80:30502/TCP 7s [rootmaster ~]# kubectl get pod NAME READY STATUS RESTARTS AGE web1-6fbb48567f-pdgxv 11 Running 0 13s 5.3 应用升级回退 [rootmaster ~]# helm history web1 REVISION UPDATED STATUS CHART APP VERSION DESCRIPTION
1 Sat May 14 20:15:51 2022 superseded mychart-0.1.0 1.16.0 Install complete 2 Sat May 14 20:18:18 2022 superseded mychart-0.1.0 1.16.0 Upgrade complete 3 Sat May 14 20:18:31 2022 deployed mychart-0.1.0 1.16.0 Rollback to 1
[rootmaster ~]# helm upgrade web1 mychart/ ##升级 Release web1 has been upgraded. Happy Helming! NAME: web1 LAST DEPLOYED: Sat May 14 20:18:18 2022 NAMESPACE: default STATUS: deployed REVISION: 2 TEST SUITE: None [rootmaster ~]# helm rollback web1 ##回退到上一版本 Rollback was a success! Happy Helming! [rootmaster ~]# helm rollback web1 2 ##回退到指定版本 6、Chart模板实现高效复用 通过传递参数动态渲染模板yaml文件内容动态传入参数生成。主要是通过value.yaml文件 实现主要分为两步1、通过values.yaml文件定义变量和值2、在具体的模板下的yaml文件中进行获取变量 一般情况下yaml文件中不同的有name、label、replicas、tag、port
6.1 在values.yaml文件中定义全局变量 [rootmaster ~]# cd mychart/ [rootmaster mychart]# ls charts Chart.yaml templates values.yaml [rootmaster mychart]# vim values.yaml [rootmaster mychart]# cat values.yaml ##主要修改的变量信息 image: nginx replicas: 1 tag: 1.16 label: nginx port: 80 6.2 在templates中的yaml文件中定义变量 通过表达式形式定义变量 {{ .Values.变量名称}} 还有一种常用的定义名字的{{ .Release.Name}} [rootmaster templates]# pwd /root/mychart/templates[rootmaster templates]# cat deployment.yaml apiVersion: apps/v1 kind: Deployment metadata:creationTimestamp: nulllabels:app: {{ .Values.label}}name: {{ .Release.Name}}-deploy spec:replicas: {{ .Values.replicas}}selector:matchLabels:app: {{ .Values.label}}strategy: {}template:metadata:creationTimestamp: nulllabels:app: {{ .Values.label}}spec:containers:- image: {{ .Values.image}}name: {{ .Values.label}}resources: {} status: {}[rootmaster templates]# cat service.yaml apiVersion: v1 kind: Service metadata:creationTimestamp: nulllabels:app: {{ .Values.label}}name: {{ .Release.Name}}-svc spec:ports:- port: {{ .Values.port}}protocol: TCPtargetPort: {{ .Values.port}}selector:app: {{ .Release.Name}}-svctype: NodePort status:loadBalancer: {}[rootmaster ~]# helm install web2 mychart/ –dry-run ##生成说明成功了 NAME: web2 LAST DEPLOYED: Sat May 14 21:33:23 2022 NAMESPACE: default STATUS: pending-install REVISION: 1 TEST SUITE: None HOOKS:

MANIFEST:

Source: mychart/templates/service.yaml

apiVersion: v1 kind: Service metadata:creationTimestamp: nulllabels:app: nginxname: web2-svc spec:ports:- port: 80protocol: TCPtargetPort: 80selector:app: web2-svctype: NodePort

status:loadBalancer: {}

Source: mychart/templates/deployment.yaml

apiVersion: apps/v1 kind: Deployment metadata:creationTimestamp: nulllabels:app: nginxname: web2-deploy spec:replicas: 1selector:matchLabels:app: nginxstrategy: {}template:metadata:creationTimestamp: nulllabels:app: nginxspec:containers:- image: nginxname: nginxresources: {} status: {} [rootmaster ~]# helm install web2 mychart/ NAME: web2 LAST DEPLOYED: Sat May 14 21:35:06 2022 NAMESPACE: default STATUS: deployed REVISION: 1 TEST SUITE: None [rootmaster ~]# kubectl get pods NAME READY STATUS RESTARTS AGE web2-deploy-6799fc88d8-8khvj 11 Running 0 25s [rootmaster ~]# kubectl get svc NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE web2-svc NodePort 10.101.45.10 none 80:30704/TCP 30s